Subversion Repositories ALCASAR

Rev

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

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