Subversion Repositories ALCASAR

Rev

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

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