Subversion Repositories ALCASAR

Rev

Rev 2867 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2867 Rev 2868
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-urpmi.sh 2867 2020-10-24 14:33:04Z rexy $
2
# $Id: alcasar-urpmi.sh 2868 2020-10-26 21:22:24Z rexy $
3
 
3
 
4
# alcasar-urpmi.sh
4
# alcasar-urpmi.sh
5
# by 3abtux and Rexy
5
# by 3abtux and Rexy
6
# This script is distributed under the Gnu General Public License (GPL)
6
# This script is distributed under the Gnu General Public License (GPL)
7
 
7
 
8
# script de mise en place des dépots RPM
8
# script de mise en place des dépots RPM
9
# configure the RPM repository
9
# configure the RPM repository
10
 
10
 
11
Lang=`echo $LANG|cut -c 1-2`
11
Lang=`echo $LANG|cut -c 1-2`
12
VERSION="7"
12
VERSION="7"
13
ARCH="x86_64"
13
ARCH="x86_64"
14
# The kernel version we compile netflow for
14
# The kernel version we compile netflow for
15
KERNEL="kernel-server-5.7.19-3.mga7-1-1.mga7"
15
KERNEL="kernel-server-5.7.19-3.mga7-1-1.mga7"
16
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
16
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
17
# (old) perl-Socket6 : needed by nfsen
17
# (old) perl-Socket6 : needed by nfsen
18
# "fonts-dejavu-common" & "fonts-ttf-dejavu" : fonts needed by wkhtmltopdf
18
# "fonts-dejavu-common" & "fonts-ttf-dejavu" : fonts needed by wkhtmltopdf
19
# "lsscsi" & nvme-cli" : needed by phpsysinfo
19
# "lsscsi" & nvme-cli" : needed by phpsysinfo
-
 
20
# "socat" : avoid a warning when run the install script of letsencrypt ("acme.sh")
20
# "sudo" : needed after a reinstallation (to be investigated)
21
# "sudo" : needed after a reinstallation (to be investigated)
21
PACKAGES="vim-enhanced freeradius freeradius-mysql freeradius-ldap lighttpd lighttpd-mod_auth php-fpm php-gd php-ldap php-mysqli php-mbstring php-sockets php-curl php-pdo_sqlite php-cli php-rrd unbound e2guardian postfix mariadb ntp bind-utils openssh-server rng-utils rsync clamd fail2ban gnupg2 ulogd pm-fallback-policy ipset usb_modeswitch vnstat dos2unix p7zip msec kernel-userspace-headers kernel-firmware-nonfree dnsmasq dhcp-server tcpdump fonts-dejavu-common fonts-ttf-dejavu lsscsi nvme-cli sudo"
22
PACKAGES="vim-enhanced freeradius freeradius-mysql freeradius-ldap lighttpd lighttpd-mod_auth php-fpm php-gd php-ldap php-mysqli php-mbstring php-sockets php-curl php-pdo_sqlite php-cli php-rrd unbound e2guardian postfix mariadb ntp bind-utils openssh-server rng-utils rsync clamd fail2ban gnupg2 ulogd pm-fallback-policy ipset usb_modeswitch vnstat dos2unix p7zip msec kernel-userspace-headers kernel-firmware-nonfree dnsmasq dhcp-server tcpdump fonts-dejavu-common fonts-ttf-dejavu lsscsi nvme-cli sudo socat"
22
 
23
 
23
rpm_repository_sync ()
24
rpm_repository_sync ()
24
{
25
{
25
cat <<EOF > /etc/urpmi/urpmi.cfg
26
cat <<EOF > /etc/urpmi/urpmi.cfg
26
{
27
{
27
downloader: wget
28
downloader: wget
28
}
29
}
29
EOF
30
EOF
30
echo ${!MIRRORLIST}
31
echo ${!MIRRORLIST}
31
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
32
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
32
urpmi.addmedia core-updates --update --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/updates
33
urpmi.addmedia core-updates --update --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/updates
33
urpmi.addmedia nonfree --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/nonfree/release
34
urpmi.addmedia nonfree --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/nonfree/release
34
urpmi.addmedia nonfree-updates --update --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/nonfree/updates
35
urpmi.addmedia nonfree-updates --update --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/nonfree/updates
35
}
36
}
36
 
37
 
37
rpm_error ()
38
rpm_error ()
38
{
39
{
39
echo
40
echo
40
if [ $Lang == "fr" ]
41
if [ $Lang == "fr" ]
41
then
42
then
42
	echo "Relancez l'installation ultérieurement."
43
	echo "Relancez l'installation ultérieurement."
43
	echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
44
	echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
44
else
45
else
45
	echo "Try an other install later."
46
	echo "Try an other install later."
46
	echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
47
	echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
47
fi
48
fi
48
}
49
}
49
 
50
 
50
# extract the current Mageia version and hardware architecture (i586 ou X64)
51
# extract the current Mageia version and hardware architecture (i586 ou X64)
51
fic=`cat /etc/product.id`
52
fic=`cat /etc/product.id`
52
old="$IFS"
53
old="$IFS"
53
IFS=","
54
IFS=","
54
set $fic
55
set $fic
55
for i in $*
56
for i in $*
56
do
57
do
57
	if [ "`echo $i|grep distribution|cut -d'=' -f1`" == "distribution" ]
58
	if [ "`echo $i|grep distribution|cut -d'=' -f1`" == "distribution" ]
58
	then
59
	then
59
		DISTRIBUTION=`echo $i|cut -d"=" -f2`
60
		DISTRIBUTION=`echo $i|cut -d"=" -f2`
60
	fi
61
	fi
61
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
62
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
62
	then
63
	then
63
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
64
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
64
	fi
65
	fi
65
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
66
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
66
	then
67
	then
67
		ARCH=`echo $i|cut -d"=" -f2`
68
		ARCH=`echo $i|cut -d"=" -f2`
68
	fi
69
	fi
69
done
70
done
70
IFS="$old"
71
IFS="$old"
71
 
72
 
72
# We prefer wget than curl
73
# We prefer wget than curl
73
urpmi --no-verify-rpm --auto rpms/$ARCH/wget*.rpm
74
urpmi --no-verify-rpm --auto rpms/$ARCH/wget*.rpm
74
 
75
 
75
# Set the RPM repository (if not already set)
76
# Set the RPM repository (if not already set)
76
ACTIVE_REPO=`cat /etc/urpmi/urpmi.cfg|grep "mageia.org"|wc -l`
77
ACTIVE_REPO=`cat /etc/urpmi/urpmi.cfg|grep "mageia.org"|wc -l`
77
MIRROR_NBR=2
78
MIRROR_NBR=2
78
#                       For Europeans
79
#                       For Europeans
79
MIRRORLIST1="https://www.mirrorservice.org/pub/mageia/distrib/$VERSION/$ARCH"
80
MIRRORLIST1="https://www.mirrorservice.org/pub/mageia/distrib/$VERSION/$ARCH"
80
#                       For International install
81
#                       For International install
81
MIRRORLIST2="https://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
82
MIRRORLIST2="https://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
82
try_nb="0"; nb_repository="0"
83
try_nb="0"; nb_repository="0"
83
while [ "$nb_repository" != "4" ]
84
while [ "$nb_repository" != "4" ]
84
do
85
do
85
	try_nb=`expr $try_nb + 1`
86
	try_nb=`expr $try_nb + 1`
86
	MIRRORLIST="MIRRORLIST$try_nb"
87
	MIRRORLIST="MIRRORLIST$try_nb"
87
	rpm_repository_sync
88
	rpm_repository_sync
88
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
89
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
89
	if [ "$nb_repository" != "4" ]
90
	if [ "$nb_repository" != "4" ]
90
	then
91
	then
91
		if [ $Lang == "fr" ]
92
		if [ $Lang == "fr" ]
92
		then
93
		then
93
			echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
94
			echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
94
		else
95
		else
95
			echo "An error occurs when synchronising the repositories N°$try_nb"
96
			echo "An error occurs when synchronising the repositories N°$try_nb"
96
		fi
97
		fi
97
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
98
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
98
		then
99
		then
99
			rpm_error
100
			rpm_error
100
			exit 1
101
			exit 1
101
		fi
102
		fi
102
		if [ $Lang == "fr" ]
103
		if [ $Lang == "fr" ]
103
		then
104
		then
104
			echo "Voulez-vous tenter une synchronisation avec un autre dépôt ? (O/n)"
105
			echo "Voulez-vous tenter une synchronisation avec un autre dépôt ? (O/n)"
105
		else
106
		else
106
			echo "Do you want to try a synchronisation with an other repository? (Y/n)"
107
			echo "Do you want to try a synchronisation with an other repository? (Y/n)"
107
		fi
108
		fi
108
		response=0
109
		response=0
109
		PTN='^[oOnNyY]?$'
110
		PTN='^[oOnNyY]?$'
110
		until [[ "$response" =~ $PTN ]]
111
		until [[ "$response" =~ $PTN ]]
111
		do
112
		do
112
			read response
113
			read response
113
		done
114
		done
114
		if [ "$response" = "n" ] || [ "$response" = "N" ]
115
		if [ "$response" = "n" ] || [ "$response" = "N" ]
115
		then
116
		then
116
			exit 1
117
			exit 1
117
		fi
118
		fi
118
	fi
119
	fi
119
done
120
done
120
# fix some RPM versions
-
 
121
echo "/^kernel/" > /etc/urpmi/skip.list
-
 
122
echo "/^freeradius/" >> /etc/urpmi/skip.list
-
 
123
echo "/^wkhtmltopdf/" >> /etc/urpmi/skip.list
-
 
124
echo "/^clamd/" >> /etc/urpmi/skip.list
-
 
125
echo "/^clamav/" >> /etc/urpmi/skip.list
-
 
126
# download the kernel used by ALCASAR
121
# download the kernel used by ALCASAR
127
if [ $Lang == "fr" ]
122
if [ $Lang == "fr" ]
128
then
123
then
129
	echo "Récupération du noyau Linux exploité par ALCASAR. Veuillez patienter ..."
124
	echo "Récupération du noyau Linux exploité par ALCASAR. Veuillez patienter ..."
130
else
125
else
131
	echo "Download the Linux kernel used by ALCASAR. Please wait ..."
126
	echo "Download the Linux kernel used by ALCASAR. Please wait ..."
132
fi
127
fi
133
urpmi --auto --quiet $KERNEL
128
urpmi --auto --quiet $KERNEL
134
# download updated RPM in cache
129
# download updated RPM in cache
135
if [ $Lang == "fr" ]
130
if [ $Lang == "fr" ]
136
then
131
then
137
	echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
132
	echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
138
	echo "Il est temps d'aller prendre un café (ou une bonne bière) ;-)"
133
	echo "Il est temps d'aller prendre un café (ou une bonne bière) ;-)"
139
else
134
else
140
	echo "Updated RPM download. Please wait ..."
135
	echo "Updated RPM download. Please wait ..."
141
	echo "You should now take a coffe (or a good beer) ;-)"
136
	echo "You should now take a coffe (or a good beer) ;-)"
142
fi
137
fi
143
urpmi --auto --auto-update --quiet --test --retry 2
138
urpmi --auto --auto-update --quiet --test --retry 2
144
if [ "$?" != "0" ]
139
if [ "$?" != "0" ]
145
then
140
then
146
	echo
141
	echo
147
	if [ $Lang == "fr" ]
142
	if [ $Lang == "fr" ]
148
	then
143
	then
149
		echo "Une erreur a été détectée lors de la récupération des paquetages."
144
		echo "Une erreur a été détectée lors de la récupération des paquetages."
150
	else
145
	else
151
		echo "An error occurs when downloading RPMS"
146
		echo "An error occurs when downloading RPMS"
152
	fi
147
	fi
153
	rpm_error
148
	rpm_error
154
	exit 1
149
	exit 1
155
fi
150
fi
156
 
151
 
157
# update with cached RPM
152
# update with cached RPM
158
urpmi --auto --auto-update
153
urpmi --auto --auto-update
159
if [ "$?" != "0" ]
154
if [ "$?" != "0" ]
160
then
155
then
161
	echo
156
	echo
162
	if [ $Lang == "fr" ]
157
	if [ $Lang == "fr" ]
163
	then
158
	then
164
		echo "Une erreur a été détectée lors de la mise à jour des paquetages."
159
		echo "Une erreur a été détectée lors de la mise à jour des paquetages."
165
	else
160
	else
166
		echo "An error occurs when updating packages"
161
		echo "An error occurs when updating packages"
167
	fi
162
	fi
168
	rpm_error
163
	rpm_error
169
	exit 1
164
	exit 1
170
fi
165
fi
171
# Clean the RPM cache
166
# Clean the RPM cache
172
urpmi --clean
167
urpmi --clean
173
 
168
 
174
# Download of ALCASAR specifics RPM in cache (and test)
169
# Download of ALCASAR specifics RPM in cache (and test)
175
if [ $Lang == "fr" ]
170
if [ $Lang == "fr" ]
176
then
171
then
177
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
172
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
178
else
173
else
179
	echo "Download of complementary packages. Please wait ..."
174
	echo "Download of complementary packages. Please wait ..."
180
fi
175
fi
181
urpmi --auto --no-recommends $PACKAGES --quiet --test --retry 2
176
urpmi --auto --no-recommends $PACKAGES --quiet --test --retry 2
182
if [ "$?" != "0" ]
177
if [ "$?" != "0" ]
183
then
178
then
184
	echo
179
	echo
185
	if [ $Lang == "fr" ]
180
	if [ $Lang == "fr" ]
186
	then
181
	then
187
		echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
182
		echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
188
	else
183
	else
189
		echo "An error occurs when downloading complementary packages"
184
		echo "An error occurs when downloading complementary packages"
190
	fi
185
	fi
191
	rpm_error
186
	rpm_error
192
	exit 1
187
	exit 1
193
fi
188
fi
194
 
189
 
195
# update with cached RPM
190
# update with cached RPM
196
urpmi --auto --no-recommends $PACKAGES
191
urpmi --auto --no-recommends $PACKAGES
197
if [ "$?" != "0" ]
192
if [ "$?" != "0" ]
198
then
193
then
199
	echo
194
	echo
200
	if [ $Lang == "fr" ]
195
	if [ $Lang == "fr" ]
201
	then
196
	then
202
		echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
197
		echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
203
	else
198
	else
204
		echo "An error occurs when installing complementary packages"
199
		echo "An error occurs when installing complementary packages"
205
	fi
200
	fi
206
	rpm_error
201
	rpm_error
207
	exit 1
202
	exit 1
208
fi
203
fi
209
 
204
 
210
# Keep only the kernel version we compil netflow with, and remove all others
205
# Keep only the kernel version we compil netflow with, and remove all others
211
kernelVersion=$(rpm -qa | grep -e ^kernel-server -e ^kernel-desktop)
206
kernelVersion=$(rpm -qa | grep -e ^kernel-server -e ^kernel-desktop)
212
for i in $kernelVersion
207
for i in $kernelVersion
213
do
208
do
214
	if [ $i != $KERNEL ];then
209
	if [ $i != $KERNEL ];then
215
		urpme --auto $i
210
		urpme --auto $i
216
	fi
211
	fi
217
done
212
done
218
# delete unused RPMs
213
# delete unused RPMs
219
if [ $Lang == "fr" ]
214
if [ $Lang == "fr" ]
220
then
215
then
221
	echo "Cleaning the system : "
216
	echo "Cleaning the system : "
222
else
217
else
223
	echo "Nettoyage du système : "
218
	echo "Nettoyage du système : "
224
fi
219
fi
225
rm_rpm="shorewall mandi plymouth cpupower squid"
220
rm_rpm="shorewall mandi plymouth cpupower squid"
226
/usr/sbin/urpme --auto -a $rm_rpm
221
/usr/sbin/urpme --auto -a $rm_rpm
227
/usr/sbin/urpme --auto --auto-orphans
222
/usr/sbin/urpme --auto --auto-orphans
228
 
223
 
229
# Save chilli launch script (erase with new rpm one)
224
# Save chilli launch script (erase with new rpm one)
230
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
225
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
231
# Install home made RPMs
226
# Install home made RPMs
232
for pkg in `ls rpms/$ARCH/*.rpm`
227
for pkg in `ls rpms/$ARCH/*.rpm`
233
do
228
do
234
    urpmi --no-verify --auto $pkg
229
    urpmi --no-verify --auto $pkg
235
done
230
done
236
# restore chilli launch script
231
# restore chilli launch script
237
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
232
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
238
# Clean the RPM cache
233
# Clean the RPM cache
239
urpmi --clean
234
urpmi --clean
240
# the ipt-netflow RPM add the kernel module ipt_NETFLOW (the modules dependance tree need to be updated). "2>/dev/null" in order not to display a error (the running kernel is not the ALCASAR one during the installation process)
235
# the ipt-netflow RPM add the kernel module ipt_NETFLOW (the modules dependance tree need to be updated). "2>/dev/null" in order not to display a error (the running kernel is not the ALCASAR one during the installation process)
241
/sbin/depmod -a 2>/dev/null
236
/sbin/depmod -a 2>/dev/null
242
# test if all needed rpms are correctly installed
237
# test if all needed rpms are correctly installed
243
count_pkg=0; nb_pkg=0;
238
count_pkg=0; nb_pkg=0;
244
for pkg in $PACKAGES
239
for pkg in $PACKAGES
245
do
240
do
246
	nb_pkg=`expr $nb_pkg + 1`
241
	nb_pkg=`expr $nb_pkg + 1`
247
	if rpm -q --quiet $pkg ; then
242
	if rpm -q --quiet $pkg ; then
248
		count_pkg=`expr $count_pkg + 1`
243
		count_pkg=`expr $count_pkg + 1`
249
	else
244
	else
250
		echo "error installing $pkg"
245
		echo "error installing $pkg"
251
	fi
246
	fi
252
done
247
done
253
if [ $count_pkg -ne $nb_pkg ]
248
if [ $count_pkg -ne $nb_pkg ]
254
then
249
then
255
	exit 1
250
	exit 1
256
fi
251
fi
257
# test if all custom rpms are correctly installed
252
# test if all custom rpms are correctly installed
258
count_pkg=0; nb_pkg=0;
253
count_pkg=0; nb_pkg=0;
259
for pkg in `ls rpms/$ARCH/|sed 's/.x86_64.rpm//'`
254
for pkg in `ls rpms/$ARCH/|sed 's/.x86_64.rpm//'`
260
do
255
do
261
	nb_pkg=`expr $nb_pkg + 1`
256
	nb_pkg=`expr $nb_pkg + 1`
262
	if rpm -q --quiet $pkg ; then
257
	if rpm -q --quiet $pkg ; then
263
		count_pkg=`expr $count_pkg + 1`
258
		count_pkg=`expr $count_pkg + 1`
264
	else
259
	else
265
		echo "error installing $pkg"
260
		echo "error installing $pkg"
266
	fi
261
	fi
267
done
262
done
268
if [ $count_pkg -ne $nb_pkg ]
263
if [ $count_pkg -ne $nb_pkg ]
269
then
264
then
270
	exit 1
265
	exit 1
271
fi
266
fi
-
 
267
# fix some RPM versions
-
 
268
echo "/^kernel/" > /etc/urpmi/skip.list
-
 
269
echo "/^freeradius/" >> /etc/urpmi/skip.list
-
 
270
echo "/^wkhtmltopdf/" >> /etc/urpmi/skip.list
-
 
271
echo "/^clamd/" >> /etc/urpmi/skip.list
-
 
272
echo "/^clamav/" >> /etc/urpmi/skip.list
272
exit 0
273
exit 0
273
 
274