Subversion Repositories ALCASAR

Rev

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

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