Subversion Repositories ALCASAR

Rev

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

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