Subversion Repositories ALCASAR

Rev

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

Rev 1164 Rev 1207
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-urpmi.sh 1164 2013-08-16 08:39:19Z crox53 $
2
# $Id: alcasar-urpmi.sh 1207 2013-09-14 16:21:46Z richard $
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="2"
12
VERSION="2"
13
ARCH="i586" 
13
ARCH="i586" 
-
 
14
# The kernel version we compile netflow for
-
 
15
KERNEL="kernel-desktop-3.4.45-1.mga2-1-1.mga2"
14
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
16
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
15
PACKAGES="sudo freeradius freeradius-mysql freeradius-ldap freeradius-web apache-mpm-prefork apache-mod_ssl apache-mod_php iptables squid dansguardian postfix mariadb logwatch ntp bind-utils openssh-server php-xml php-ldap php-mysql pam_ccreds rng-utils dnsmasq syslinux rsync cronie-anacron clamav pm-fallback-policy php-mbstring perl-rrdtool perl-MailTools perl-Socket6 php-sockets kernel-desktop-3.4.45-1.mga2-1-1.mga2 fail2ban"
17
PACKAGES="sudo freeradius freeradius-mysql freeradius-ldap freeradius-web apache-mpm-prefork apache-mod_ssl apache-mod_php iptables squid dansguardian postfix mariadb logwatch ntp bind-utils openssh-server php-xml php-ldap php-mysql pam_ccreds rng-utils dnsmasq syslinux rsync cronie-anacron clamav pm-fallback-policy php-mbstring perl-rrdtool perl-MailTools perl-Socket6 php-sockets fail2ban"
-
 
18
 
16
rpm_repository_sync ()
19
rpm_repository_sync ()
17
{
20
{
18
cat <<EOF > /etc/urpmi/urpmi.cfg
21
cat <<EOF > /etc/urpmi/urpmi.cfg
19
{
22
{
20
downloader: wget
23
downloader: wget
21
}
24
}
22
EOF
25
EOF
23
echo ${!MIRRORLIST}
26
echo ${!MIRRORLIST}
24
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
27
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
25
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
26
}
29
}
27
 
30
 
28
rpm_error ()
31
rpm_error ()
29
{
32
{
30
echo
33
echo
31
if [ $Lang == "fr" ]
34
if [ $Lang == "fr" ]
32
then	
35
then	
33
	echo "Relancez l'installation ultérieurement."
36
	echo "Relancez l'installation ultérieurement."
34
	echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
37
	echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
35
else
38
else
36
	echo "Try an other install later."
39
	echo "Try an other install later."
37
	echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
40
	echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
38
fi
41
fi
39
}
42
}
40
# extract the current Mandriva/Mageia version and hardware architecture (i586 ou X64)
43
# extract the current Mandriva/Mageia version and hardware architecture (i586 ou X64)
41
fic=`cat /etc/product.id`
44
fic=`cat /etc/product.id`
42
unknown_os=0
45
unknown_os=0
43
old="$IFS"
46
old="$IFS"
44
IFS=","
47
IFS=","
45
set $fic
48
set $fic
46
for i in $*
49
for i in $*
47
do
50
do
48
	if [ "`echo $i|grep distribution|cut -d'=' -f1`" == "distribution" ]
51
	if [ "`echo $i|grep distribution|cut -d'=' -f1`" == "distribution" ]
49
	then 
52
	then 
50
		DISTRIBUTION=`echo $i|cut -d"=" -f2`
53
		DISTRIBUTION=`echo $i|cut -d"=" -f2`
51
		unknown_os=`expr $unknown_os + 1`
54
		unknown_os=`expr $unknown_os + 1`
52
	fi
55
	fi
53
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
56
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
54
	then 
57
	then 
55
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
58
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
56
		unknown_os=`expr $unknown_os + 1`
59
		unknown_os=`expr $unknown_os + 1`
57
	fi
60
	fi
58
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
61
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
59
	then 
62
	then 
60
		ARCH=`echo $i|cut -d"=" -f2`
63
		ARCH=`echo $i|cut -d"=" -f2`
61
		unknown_os=`expr $unknown_os + 1`
64
		unknown_os=`expr $unknown_os + 1`
62
	fi
65
	fi
63
done
66
done
64
IFS="$old"
67
IFS="$old"
65
if [[ ( $unknown_os != 3 || "$DISTRIBUTION" != "Mageia" ) && ( "$CURRENT_VERSION" != "2" ) ]]
68
if [[ ( $unknown_os != 3 || "$DISTRIBUTION" != "Mageia" ) && ( "$CURRENT_VERSION" != "2" ) ]]
66
then
69
then
67
	if [ $Lang == "fr" ]
70
	if [ $Lang == "fr" ]
68
	then	
71
	then	
69
		echo "La migration automatique d'ALCASAR ne peut pas être réalisée."
72
		echo "La migration automatique d'ALCASAR ne peut pas être réalisée."
70
		echo "Le système d'exploitation doit être remplacé"
73
		echo "Le système d'exploitation doit être remplacé"
71
	else
74
	else
72
		echo "The automatic update of ALCASAR can't be performed."
75
		echo "The automatic update of ALCASAR can't be performed."
73
		echo "The OS must be replaced"
76
		echo "The OS must be replaced"
74
	fi
77
	fi
75
	if [ -e /tmp/alcasar-conf.tar.gz ]
78
	if [ -e /tmp/alcasar-conf.tar.gz ]
76
	then
79
	then
77
		echo
80
		echo
78
		if [ $Lang == "fr" ]
81
		if [ $Lang == "fr" ]
79
		then	
82
		then	
80
			echo "1 - Récupérez le fichier de configuration actuel (/tmp/alcasar-conf.tar.gz)."
83
			echo "1 - Récupérez le fichier de configuration actuel (/tmp/alcasar-conf.tar.gz)."
81
			echo "2 - Installez Linux-Mageia2 (cf. doc d'installation)"
84
			echo "2 - Installez Linux-Mageia2 (cf. doc d'installation)"
82
			echo "3 - copiez le fichier 'alcasar-conf.tar.gz' dans le répertoire '/tmp' avant de lancer l'installation d'ALCASAR"
85
			echo "3 - copiez le fichier 'alcasar-conf.tar.gz' dans le répertoire '/tmp' avant de lancer l'installation d'ALCASAR"
83
		else
86
		else
84
			echo "1 - Retrieve the configuration file (/tmp/alcasar-conf.tar.gz)"
87
			echo "1 - Retrieve the configuration file (/tmp/alcasar-conf.tar.gz)"
85
			echo "2 - Install Linux-Mageia2 (cf. installation doc)"
88
			echo "2 - Install Linux-Mageia2 (cf. installation doc)"
86
			echo "3 - Copy the file 'alcasar-conf.tar.gz' in the folder '/tmp' before launching the installation of ALCASAR"
89
			echo "3 - Copy the file 'alcasar-conf.tar.gz' in the folder '/tmp' before launching the installation of ALCASAR"
87
		fi
90
		fi
88
	fi
91
	fi
89
	exit 1
92
	exit 1
90
fi
93
fi
91
# We prefer wget than curl
94
# We prefer wget than curl
92
urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
95
urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
93
# Set the RPM repository
96
# Set the RPM repository
94
MIRROR_NBR=2
97
MIRROR_NBR=2
95
#                       For Europeans 
98
#                       For Europeans 
96
MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
99
MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
97
#                       For International install
100
#                       For International install
98
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
101
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
99
try_nb="0"; nb_repository="0"
102
try_nb="0"; nb_repository="0"
100
while [ "$nb_repository" != "2" ]
103
while [ "$nb_repository" != "2" ]
101
do
104
do
102
	try_nb=`expr $try_nb + 1`
105
	try_nb=`expr $try_nb + 1`
103
	MIRRORLIST="MIRRORLIST$try_nb"
106
	MIRRORLIST="MIRRORLIST$try_nb"
104
	rpm_repository_sync 
107
	rpm_repository_sync 
105
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
108
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
106
	if [ "$nb_repository" != "2" ]
109
	if [ "$nb_repository" != "2" ]
107
	then
110
	then
108
		if [ $Lang == "fr" ]
111
		if [ $Lang == "fr" ]
109
		then	
112
		then	
110
			echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
113
			echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
111
		else
114
		else
112
			echo "An error occurs when synchronising the repositories N°$try_nb"
115
			echo "An error occurs when synchronising the repositories N°$try_nb"
113
		fi
116
		fi
114
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
117
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
115
		then
118
		then
116
			rpm_error
119
			rpm_error
117
			exit 1
120
			exit 1
118
		fi
121
		fi
119
		if [ $Lang == "fr" ]
122
		if [ $Lang == "fr" ]
120
		then	
123
		then	
121
			echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
124
			echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
122
		else
125
		else
123
			echo "Do you wan't to try a synchronisation with an other repository?"
126
			echo "Do you wan't to try a synchronisation with an other repository?"
124
		fi
127
		fi
125
		response=0
128
		response=0
126
		PTN='^[oOnNyY]$'
129
		PTN='^[oOnNyY]$'
127
		until [[ $(expr $response : $PTN) -gt 0 ]]
130
		until [[ $(expr $response : $PTN) -gt 0 ]]
128
		do
131
		do
129
			read response
132
			read response
130
		done
133
		done
131
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
134
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
132
		then
135
		then
133
			exit 1
136
			exit 1
134
		fi
137
		fi
135
	fi
138
	fi
136
done
139
done
137
# delete unused RPMs
140
# delete unused RPMs
-
 
141
if [ $Lang == "fr" ]
-
 
142
then
138
echo "Cleaning the system : "
143
	echo "Cleaning the system : "
-
 
144
else
-
 
145
	echo "Nettoyage du système : "
-
 
146
fi
139
for rm_rpm in shorewall mandi radeontool avahi
147
for rm_rpm in shorewall mandi radeontool avahi
140
do
148
do
141
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
149
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
142
	echo -n "."
150
	echo -n "."
143
done
151
done
-
 
152
# download the kernel used by ALCASAR and fix its version
-
 
153
if [ $Lang == "fr" ]
-
 
154
then	
-
 
155
	echo "Récupération du noyau Linux exploité par ALCASAR. Veuillez patienter ..."
144
echo
156
else
-
 
157
	echo "Download the Linux kernel used by ALCASAR. Please wait ..."
-
 
158
fi
-
 
159
urpmi --auto --quiet $KERNEL
-
 
160
echo "/^kernel/" > /etc/urpmi/skip.list
145
# download RPM in cache 
161
# download updated RPM in cache 
146
if [ $Lang == "fr" ]
162
if [ $Lang == "fr" ]
147
then	
163
then	
148
	echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
164
	echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
149
	echo "Il est temps d'aller prendre un café (ou une bonne bière) ;-)"
165
	echo "Il est temps d'aller prendre un café (ou une bonne bière) ;-)"
150
else
166
else
151
	echo "Updated RPM download. Please wait ..."
167
	echo "Updated RPM download. Please wait ..."
152
	echo "You should now take a coffe (or a good beer) ;-)"
168
	echo "You should now take a coffe (or a good beer) ;-)"
153
fi
169
fi
154
urpmi --auto --auto-update --quiet --test --retry 2
170
urpmi --auto --auto-update --quiet --test --retry 2
155
if [ "$?" != "0" ]
171
if [ "$?" != "0" ]
156
then
172
then
157
	echo
173
	echo
158
	if [ $Lang == "fr" ]
174
	if [ $Lang == "fr" ]
159
	then	
175
	then	
160
		echo "Une erreur a été détectée lors de la récupération des paquetages."
176
		echo "Une erreur a été détectée lors de la récupération des paquetages."
161
	else
177
	else
162
		echo "An error occurs when downloading RPMS"
178
		echo "An error occurs when downloading RPMS"
163
	fi
179
	fi
164
	rpm_error
180
	rpm_error
165
	exit 1
181
	exit 1
166
fi
182
fi
167
# update with cached RPM
183
# update with cached RPM
168
urpmi --auto --auto-update
184
urpmi --auto --auto-update
169
if [ "$?" != "0" ]
185
if [ "$?" != "0" ]
170
then
186
then
171
	echo
187
	echo
172
	if [ $Lang == "fr" ]
188
	if [ $Lang == "fr" ]
173
	then	
189
	then	
174
		echo "Une erreur a été détectée lors de la mise à jour des paquetages."
190
		echo "Une erreur a été détectée lors de la mise à jour des paquetages."
175
	else
191
	else
176
		echo "An error occurs when updating packages"
192
		echo "An error occurs when updating packages"
177
	fi
193
	fi
178
	rpm_error
194
	rpm_error
179
	exit 1
195
	exit 1
180
fi
196
fi
181
# Clean the RPM cache
197
# Clean the RPM cache
182
urpmi --clean
198
urpmi --clean
183
# Download of ALCASAR specifics RPM in cache (and test)
199
# Download of ALCASAR specifics RPM in cache (and test)
184
if [ $Lang == "fr" ]
200
if [ $Lang == "fr" ]
185
then	
201
then	
186
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
202
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
187
else
203
else
188
	echo "Download of complementary packages. Please wait ..."
204
	echo "Download of complementary packages. Please wait ..."
189
fi
205
fi
190
urpmi --auto $PACKAGES --quiet --test --retry 2
206
urpmi --auto $PACKAGES --quiet --test --retry 2
191
if [ "$?" != "0" ]
207
if [ "$?" != "0" ]
192
then
208
then
193
	echo
209
	echo
194
	if [ $Lang == "fr" ]
210
	if [ $Lang == "fr" ]
195
	then	
211
	then	
196
		echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
212
		echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
197
	else
213
	else
198
		echo "An error occurs when downloading complementary packages"
214
		echo "An error occurs when downloading complementary packages"
199
	fi
215
	fi
200
	rpm_error
216
	rpm_error
201
	exit 1
217
	exit 1
202
fi
218
fi
203
# update with cached RPM
219
# update with cached RPM
204
urpmi --auto $PACKAGES 
220
urpmi --auto $PACKAGES 
205
if [ "$?" != "0" ]
221
if [ "$?" != "0" ]
206
then
222
then
207
	echo
223
	echo
208
	if [ $Lang == "fr" ]
224
	if [ $Lang == "fr" ]
209
	then	
225
	then	
210
		echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
226
		echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
211
	else
227
	else
212
		echo "An error occurs when installing complementary packages"
228
		echo "An error occurs when installing complementary packages"
213
	fi
229
	fi
214
	rpm_error
230
	rpm_error
215
	exit 1
231
	exit 1
216
fi
232
fi
-
 
233
# Keep only the kernel version we compil netflow with, and remove all others
-
 
234
kernelVersion=$(rpm -qa | grep "kernel-desktop")
-
 
235
for i in $kernelVersion
-
 
236
do
-
 
237
	if [ ! $i = $KERNEL ];then
-
 
238
		urpme --auto $i
-
 
239
	fi
-
 
240
done
217
# delete old alcasar RPMs and unused services
241
# delete old alcasar RPMs and unused services
218
for rm_rpm in c-icap-server lib64chilli0 libchilli0 python-coova-chilli cyrus-sasl mageia-gfxboot-theme
242
for rm_rpm in c-icap-server lib64chilli0 libchilli0 python-coova-chilli cyrus-sasl mageia-gfxboot-theme
219
do
243
do
220
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
244
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
221
done
245
done
-
 
246
 
222
# Save chilli launch script (erase with new rpm one)
247
# Save chilli launch script (erase with new rpm one)
223
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
248
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
224
# Install home made RPMs
249
# Install home made RPMs
225
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
250
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
226
# restore chilli launch script
251
# restore chilli launch script
227
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
252
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
228
# Clean the RPM cache
253
# Clean the RPM cache
229
urpmi --clean
254
urpmi --clean
230
 
255
 
231
#Keep only kernel-desktop-3.4.45-1.mga2-1-1.mga2 version, and remove all others
-
 
232
kernelVersion=$(rpm -qa | grep "kernel-desktop")
-
 
233
for i in $kernelVersion
-
 
234
do
-
 
235
	if [ ! $i = "kernel-desktop-3.4.45-1.mga2-1-1.mga2" ];then
-
 
236
		urpme $i
-
 
237
	fi
-
 
238
done
-
 
239
 
-
 
240
#Fix the kernel version to : kernel-desktop-3.4.45-1.mga2-1-1.mga2
-
 
241
	echo "/^kernel-desktop/" > /etc/urpmi/skip.list 
-
 
242
 
-
 
243
#update tht kernel modules list
-
 
244
depmod -a
-
 
245
 
-
 
246
exit 0
256
exit 0
247
 
257