Subversion Repositories ALCASAR

Rev

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