Subversion Repositories ALCASAR

Rev

Rev 1240 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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