Subversion Repositories ALCASAR

Rev

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

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