Subversion Repositories ALCASAR

Rev

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