Subversion Repositories ALCASAR

Rev

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

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