Subversion Repositories ALCASAR

Rev

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

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