Subversion Repositories ALCASAR

Rev

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

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