Subversion Repositories ALCASAR

Rev

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

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