Subversion Repositories ALCASAR

Rev

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

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