Subversion Repositories ALCASAR

Rev

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

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