Subversion Repositories ALCASAR

Rev

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

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