Subversion Repositories ALCASAR

Rev

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