Subversion Repositories ALCASAR

Rev

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

Rev 1207 Rev 1208
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-urpmi.sh 1207 2013-09-14 16:21:46Z richard $
2
# $Id: alcasar-urpmi.sh 1208 2013-09-16 09:33:36Z crox53 $
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.45-1.mga2-1-1.mga2"
15
KERNEL="kernel-desktop-3.4.52-1.mga2-1-1.mga2"
16
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
16
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
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"
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
 
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
}
29
}
30
 
30
 
31
rpm_error ()
31
rpm_error ()
32
{
32
{
33
echo
33
echo
34
if [ $Lang == "fr" ]
34
if [ $Lang == "fr" ]
35
then	
35
then	
36
	echo "Relancez l'installation ultérieurement."
36
	echo "Relancez l'installation ultérieurement."
37
	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'"
38
else
38
else
39
	echo "Try an other install later."
39
	echo "Try an other install later."
40
	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'"
41
fi
41
fi
42
}
42
}
43
# 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)
44
fic=`cat /etc/product.id`
44
fic=`cat /etc/product.id`
45
unknown_os=0
45
unknown_os=0
46
old="$IFS"
46
old="$IFS"
47
IFS=","
47
IFS=","
48
set $fic
48
set $fic
49
for i in $*
49
for i in $*
50
do
50
do
51
	if [ "`echo $i|grep distribution|cut -d'=' -f1`" == "distribution" ]
51
	if [ "`echo $i|grep distribution|cut -d'=' -f1`" == "distribution" ]
52
	then 
52
	then 
53
		DISTRIBUTION=`echo $i|cut -d"=" -f2`
53
		DISTRIBUTION=`echo $i|cut -d"=" -f2`
54
		unknown_os=`expr $unknown_os + 1`
54
		unknown_os=`expr $unknown_os + 1`
55
	fi
55
	fi
56
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
56
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
57
	then 
57
	then 
58
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
58
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
59
		unknown_os=`expr $unknown_os + 1`
59
		unknown_os=`expr $unknown_os + 1`
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
		unknown_os=`expr $unknown_os + 1`
64
		unknown_os=`expr $unknown_os + 1`
65
	fi
65
	fi
66
done
66
done
67
IFS="$old"
67
IFS="$old"
68
if [[ ( $unknown_os != 3 || "$DISTRIBUTION" != "Mageia" ) && ( "$CURRENT_VERSION" != "2" ) ]]
68
if [[ ( $unknown_os != 3 || "$DISTRIBUTION" != "Mageia" ) && ( "$CURRENT_VERSION" != "2" ) ]]
69
then
69
then
70
	if [ $Lang == "fr" ]
70
	if [ $Lang == "fr" ]
71
	then	
71
	then	
72
		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."
73
		echo "Le système d'exploitation doit être remplacé"
73
		echo "Le système d'exploitation doit être remplacé"
74
	else
74
	else
75
		echo "The automatic update of ALCASAR can't be performed."
75
		echo "The automatic update of ALCASAR can't be performed."
76
		echo "The OS must be replaced"
76
		echo "The OS must be replaced"
77
	fi
77
	fi
78
	if [ -e /tmp/alcasar-conf.tar.gz ]
78
	if [ -e /tmp/alcasar-conf.tar.gz ]
79
	then
79
	then
80
		echo
80
		echo
81
		if [ $Lang == "fr" ]
81
		if [ $Lang == "fr" ]
82
		then	
82
		then	
83
			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)."
84
			echo "2 - Installez Linux-Mageia2 (cf. doc d'installation)"
84
			echo "2 - Installez Linux-Mageia2 (cf. doc d'installation)"
85
			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"
86
		else
86
		else
87
			echo "1 - Retrieve the configuration file (/tmp/alcasar-conf.tar.gz)"
87
			echo "1 - Retrieve the configuration file (/tmp/alcasar-conf.tar.gz)"
88
			echo "2 - Install Linux-Mageia2 (cf. installation doc)"
88
			echo "2 - Install Linux-Mageia2 (cf. installation doc)"
89
			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"
90
		fi
90
		fi
91
	fi
91
	fi
92
	exit 1
92
	exit 1
93
fi
93
fi
94
# We prefer wget than curl
94
# We prefer wget than curl
95
urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
95
urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
96
# Set the RPM repository
96
# Set the RPM repository
97
MIRROR_NBR=2
97
MIRROR_NBR=2
98
#                       For Europeans 
98
#                       For Europeans 
99
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"
100
#                       For International install
100
#                       For International install
101
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
101
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
102
try_nb="0"; nb_repository="0"
102
try_nb="0"; nb_repository="0"
103
while [ "$nb_repository" != "2" ]
103
while [ "$nb_repository" != "2" ]
104
do
104
do
105
	try_nb=`expr $try_nb + 1`
105
	try_nb=`expr $try_nb + 1`
106
	MIRRORLIST="MIRRORLIST$try_nb"
106
	MIRRORLIST="MIRRORLIST$try_nb"
107
	rpm_repository_sync 
107
	rpm_repository_sync 
108
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
108
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
109
	if [ "$nb_repository" != "2" ]
109
	if [ "$nb_repository" != "2" ]
110
	then
110
	then
111
		if [ $Lang == "fr" ]
111
		if [ $Lang == "fr" ]
112
		then	
112
		then	
113
			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."
114
		else
114
		else
115
			echo "An error occurs when synchronising the repositories N°$try_nb"
115
			echo "An error occurs when synchronising the repositories N°$try_nb"
116
		fi
116
		fi
117
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
117
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
118
		then
118
		then
119
			rpm_error
119
			rpm_error
120
			exit 1
120
			exit 1
121
		fi
121
		fi
122
		if [ $Lang == "fr" ]
122
		if [ $Lang == "fr" ]
123
		then	
123
		then	
124
			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?"
125
		else
125
		else
126
			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?"
127
		fi
127
		fi
128
		response=0
128
		response=0
129
		PTN='^[oOnNyY]$'
129
		PTN='^[oOnNyY]$'
130
		until [[ $(expr $response : $PTN) -gt 0 ]]
130
		until [[ $(expr $response : $PTN) -gt 0 ]]
131
		do
131
		do
132
			read response
132
			read response
133
		done
133
		done
134
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
134
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
135
		then
135
		then
136
			exit 1
136
			exit 1
137
		fi
137
		fi
138
	fi
138
	fi
139
done
139
done
140
# delete unused RPMs
140
# delete unused RPMs
141
if [ $Lang == "fr" ]
141
if [ $Lang == "fr" ]
142
then
142
then
143
	echo "Cleaning the system : "
143
	echo "Cleaning the system : "
144
else
144
else
145
	echo "Nettoyage du système : "
145
	echo "Nettoyage du système : "
146
fi
146
fi
147
for rm_rpm in shorewall mandi radeontool avahi
147
for rm_rpm in shorewall mandi radeontool avahi
148
do
148
do
149
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
149
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
150
	echo -n "."
150
	echo -n "."
151
done
151
done
152
# download the kernel used by ALCASAR and fix its version
152
# download the kernel used by ALCASAR and fix its version
153
if [ $Lang == "fr" ]
153
if [ $Lang == "fr" ]
154
then	
154
then	
155
	echo "Récupération du noyau Linux exploité par ALCASAR. Veuillez patienter ..."
155
	echo "Récupération du noyau Linux exploité par ALCASAR. Veuillez patienter ..."
156
else
156
else
157
	echo "Download the Linux kernel used by ALCASAR. Please wait ..."
157
	echo "Download the Linux kernel used by ALCASAR. Please wait ..."
158
fi
158
fi
159
urpmi --auto --quiet $KERNEL
159
urpmi --auto --quiet $KERNEL
160
echo "/^kernel/" > /etc/urpmi/skip.list
160
echo "/^kernel/" > /etc/urpmi/skip.list
161
# download updated RPM in cache 
161
# download updated RPM in cache 
162
if [ $Lang == "fr" ]
162
if [ $Lang == "fr" ]
163
then	
163
then	
164
	echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
164
	echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
165
	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) ;-)"
166
else
166
else
167
	echo "Updated RPM download. Please wait ..."
167
	echo "Updated RPM download. Please wait ..."
168
	echo "You should now take a coffe (or a good beer) ;-)"
168
	echo "You should now take a coffe (or a good beer) ;-)"
169
fi
169
fi
170
urpmi --auto --auto-update --quiet --test --retry 2
170
urpmi --auto --auto-update --quiet --test --retry 2
171
if [ "$?" != "0" ]
171
if [ "$?" != "0" ]
172
then
172
then
173
	echo
173
	echo
174
	if [ $Lang == "fr" ]
174
	if [ $Lang == "fr" ]
175
	then	
175
	then	
176
		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."
177
	else
177
	else
178
		echo "An error occurs when downloading RPMS"
178
		echo "An error occurs when downloading RPMS"
179
	fi
179
	fi
180
	rpm_error
180
	rpm_error
181
	exit 1
181
	exit 1
182
fi
182
fi
183
# update with cached RPM
183
# update with cached RPM
184
urpmi --auto --auto-update
184
urpmi --auto --auto-update
185
if [ "$?" != "0" ]
185
if [ "$?" != "0" ]
186
then
186
then
187
	echo
187
	echo
188
	if [ $Lang == "fr" ]
188
	if [ $Lang == "fr" ]
189
	then	
189
	then	
190
		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."
191
	else
191
	else
192
		echo "An error occurs when updating packages"
192
		echo "An error occurs when updating packages"
193
	fi
193
	fi
194
	rpm_error
194
	rpm_error
195
	exit 1
195
	exit 1
196
fi
196
fi
197
# Clean the RPM cache
197
# Clean the RPM cache
198
urpmi --clean
198
urpmi --clean
199
# Download of ALCASAR specifics RPM in cache (and test)
199
# Download of ALCASAR specifics RPM in cache (and test)
200
if [ $Lang == "fr" ]
200
if [ $Lang == "fr" ]
201
then	
201
then	
202
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
202
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
203
else
203
else
204
	echo "Download of complementary packages. Please wait ..."
204
	echo "Download of complementary packages. Please wait ..."
205
fi
205
fi
206
urpmi --auto $PACKAGES --quiet --test --retry 2
206
urpmi --auto $PACKAGES --quiet --test --retry 2
207
if [ "$?" != "0" ]
207
if [ "$?" != "0" ]
208
then
208
then
209
	echo
209
	echo
210
	if [ $Lang == "fr" ]
210
	if [ $Lang == "fr" ]
211
	then	
211
	then	
212
		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."
213
	else
213
	else
214
		echo "An error occurs when downloading complementary packages"
214
		echo "An error occurs when downloading complementary packages"
215
	fi
215
	fi
216
	rpm_error
216
	rpm_error
217
	exit 1
217
	exit 1
218
fi
218
fi
219
# update with cached RPM
219
# update with cached RPM
220
urpmi --auto $PACKAGES 
220
urpmi --auto $PACKAGES 
221
if [ "$?" != "0" ]
221
if [ "$?" != "0" ]
222
then
222
then
223
	echo
223
	echo
224
	if [ $Lang == "fr" ]
224
	if [ $Lang == "fr" ]
225
	then	
225
	then	
226
		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."
227
	else
227
	else
228
		echo "An error occurs when installing complementary packages"
228
		echo "An error occurs when installing complementary packages"
229
	fi
229
	fi
230
	rpm_error
230
	rpm_error
231
	exit 1
231
	exit 1
232
fi
232
fi
233
# Keep only the kernel version we compil netflow with, and remove all others
233
# Keep only the kernel version we compil netflow with, and remove all others
234
kernelVersion=$(rpm -qa | grep "kernel-desktop")
234
kernelVersion=$(rpm -qa | grep "kernel-desktop")
235
for i in $kernelVersion
235
for i in $kernelVersion
236
do
236
do
237
	if [ ! $i = $KERNEL ];then
237
	if [ ! $i = $KERNEL ];then
238
		urpme --auto $i
238
		urpme --auto $i
239
	fi
239
	fi
240
done
240
done
241
# delete old alcasar RPMs and unused services
241
# delete old alcasar RPMs and unused services
242
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
243
do
243
do
244
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
244
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
245
done
245
done
246
 
246
 
247
# Save chilli launch script (erase with new rpm one)
247
# Save chilli launch script (erase with new rpm one)
248
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
248
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
249
# Install home made RPMs
249
# Install home made RPMs
250
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
250
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
251
# restore chilli launch script
251
# restore chilli launch script
252
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
252
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
253
# Clean the RPM cache
253
# Clean the RPM cache
254
urpmi --clean
254
urpmi --clean
255
 
255
 
256
exit 0
256
exit 0
257
 
257