Subversion Repositories ALCASAR

Rev

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

Rev 958 Rev 972
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-urpmi.sh 958 2012-07-19 09:01:30Z franck $
2
# $Id: alcasar-urpmi.sh 972 2012-08-13 19:49:27Z richard $
3
 
3
 
4
# alcasar-urpmi.sh
4
# alcasar-urpmi.sh
5
# by Franck BOUIJOUX and Richard REY
5
# by Franck BOUIJOUX and Richard REY
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
VERSION="2010.2"
11
VERSION="2010.2"
12
ARCH="i586" 
12
ARCH="i586" 
13
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
13
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
14
PACKAGES="freeradius freeradius-mysql freeradius-ldap freeradius-web apache-mpm-prefork apache-mod_ssl apache-mod_php squid dansguardian postfix MySQL logwatch ntp awstats buffer vim-enhanced bind-utils arpscan ulogd openssh-server php-xml php-ldap pam_ccreds rng-utils lsb-release dnsmasq sudo syslinux rsync cronie-anacron pciutils clamav pm-fallback-policy "
14
PACKAGES="freeradius freeradius-mysql freeradius-ldap freeradius-web apache-mpm-prefork apache-mod_ssl apache-mod_php squid dansguardian postfix MySQL logwatch ntp awstats buffer vim-enhanced bind-utils arpscan ulogd openssh-server php-xml php-ldap pam_ccreds rng-utils lsb-release dnsmasq sudo syslinux rsync cronie-anacron pciutils clamav pm-fallback-policy "
15
 
15
 
16
rpm_repository_sync ()
16
rpm_repository_sync ()
17
{
17
{
18
cat <<EOF > /etc/urpmi/urpmi.cfg
18
cat <<EOF > /etc/urpmi/urpmi.cfg
19
{
19
{
20
downloader: wget
20
downloader: wget
21
}
21
}
22
EOF
22
EOF
23
urpmi.addmedia --probe-synthesis --mirrorlist ${!MIRRORLIST} main /media/main/release
23
urpmi.addmedia --probe-synthesis --mirrorlist ${!MIRRORLIST} main /media/main/release
24
urpmi.addmedia --update --probe-synthesis --mirrorlist ${!MIRRORLIST} main_updates /media/main/updates
24
urpmi.addmedia --update --probe-synthesis --mirrorlist ${!MIRRORLIST} main_updates /media/main/updates
25
urpmi.addmedia --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib /media/contrib/release
25
urpmi.addmedia --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib /media/contrib/release
26
urpmi.addmedia --update --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib_updates /media/contrib/updates
26
urpmi.addmedia --update --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib_updates /media/contrib/updates
27
}
27
}
28
 
28
 
29
rpm_error ()
29
rpm_error ()
30
{
30
{
31
echo
31
echo
32
echo "Relancez l'installation ultérieurement."
32
echo "Relancez l'installation ultérieurement."
33
echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
33
echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
34
echo "Try an other install later."
34
echo "Try an other install later."
35
echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
35
echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
36
}
36
}
37
# extract the current Mandriva version and hardware architecture (i586 ou X64)
37
# extract the current Mandriva version and hardware architecture (i586 ou X64)
38
fic=`cat /etc/product.id`
38
fic=`cat /etc/product.id`
39
old="$IFS"
39
old="$IFS"
40
IFS=","
40
IFS=","
41
set $fic
41
set $fic
42
for i in $*
42
for i in $*
43
do
43
do
44
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
44
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
45
	then 
45
	then 
46
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
46
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
47
		if [ $CURRENT_VERSION != "2009.0" ] && [ $CURRENT_VERSION != "2009.1" ] && [ $CURRENT_VERSION != "2010.0" ] && [ $CURRENT_VERSION != "2010.1" ] && [ $CURRENT_VERSION != "2010.2" ] 
47
		if [ $CURRENT_VERSION != "2009.0" ] && [ $CURRENT_VERSION != "2009.1" ] && [ $CURRENT_VERSION != "2010.0" ] && [ $CURRENT_VERSION != "2010.1" ] && [ $CURRENT_VERSION != "2010.2" ] 
48
		then
48
		then
49
		      echo "La migration automatique du système ne peut être réalisée."
49
		      echo "La migration automatique du système ne peut être réalisée."
50
		      echo "Réalisez une mise à jour manuelle (cf. doc)."
50
		      echo "Réalisez une mise à jour manuelle (cf. doc)."
51
		      echo "The automatic system update can't perform."
51
		      echo "The automatic system update can't perform."
52
		      echo "Do a manual update (see doc)."
52
		      echo "Do a manual update (see doc)."
53
		exit 1		
53
		exit 1		
54
		fi
54
		fi
55
	fi
55
	fi
56
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
56
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
57
	then 
57
	then 
58
		ARCH=`echo $i|cut -d"=" -f2`
58
		ARCH=`echo $i|cut -d"=" -f2`
59
	fi
59
	fi
60
done
60
done
61
IFS="$old"
61
IFS="$old"
62
# We prefer wget than curl
62
# We prefer wget than curl
63
urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
63
urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
64
# Set the RPM repository
64
# Set the RPM repository
65
MIRROR_NBR=2
65
MIRROR_NBR=2
66
#                       For french ALCASARistes
66
#                       For french ALCASARistes
67
MIRRORLIST1="http://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/official/$VERSION/$ARCH"
67
MIRRORLIST1="http://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/official/$VERSION/$ARCH"
68
#                       For International install
68
#                       For International install
69
MIRRORLIST2="http://api.mandriva.com/mirrors/basic.$VERSION.$ARCH.list"
69
MIRRORLIST2="http://api.mandriva.com/mirrors/basic.$VERSION.$ARCH.list"
70
try_nb="0"; nb_repository="0"
70
try_nb="0"; nb_repository="0"
71
while [ "$nb_repository" != "4" ]
71
while [ "$nb_repository" != "4" ]
72
do
72
do
73
	try_nb=`expr $try_nb + 1`
73
	try_nb=`expr $try_nb + 1`
74
	MIRRORLIST="MIRRORLIST$try_nb"
74
	MIRRORLIST="MIRRORLIST$try_nb"
75
	rpm_repository_sync 
75
	rpm_repository_sync 
76
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
76
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
77
	if [ "$nb_repository" != "4" ]
77
	if [ "$nb_repository" != "4" ]
78
	then
78
	then
79
		echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
79
		echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
80
		echo "An error occurs when synchronising the repositories N°$try_nb"
80
		echo "An error occurs when synchronising the repositories N°$try_nb"
81
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
81
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
82
		then
82
		then
83
			rpm_error
83
			rpm_error
84
			exit 1
84
			exit 1
85
		fi
85
		fi
86
		echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
86
		echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
87
		echo "Do you wan't to try a synchronisation with an other repository?"
87
		echo "Do you wan't to try a synchronisation with an other repository?"
88
		response=0
88
		response=0
89
		PTN='^[oOnNyY]$'
89
		PTN='^[oOnNyY]$'
90
		until [[ $(expr $response : $PTN) -gt 0 ]]
90
		until [[ $(expr $response : $PTN) -gt 0 ]]
91
		do
91
		do
92
			read response
92
			read response
93
		done
93
		done
94
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
94
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
95
		then
95
		then
96
			exit 1
96
			exit 1
97
		fi
97
		fi
98
	fi
98
	fi
99
done
99
done
100
# delete unused RPMs
100
# delete unused RPMs
101
echo "Cleaning the system : "
101
echo "Cleaning the system : "
102
for rm_rpm in shorewall dhcp-server cyrus-sasl distcache-server avahi mandi radeontool mondo mindi
102
for rm_rpm in shorewall dhcp-server cyrus-sasl distcache-server avahi mandi radeontool mondo mindi
103
do
103
do
104
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
104
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
105
	echo -n "."
105
	echo -n "."
106
done
106
done
107
echo
107
echo
108
# download RPM in cache 
108
# download RPM in cache 
109
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
109
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
110
echo "Updated RPM download. Please wait ..."
110
echo "Updated RPM download. Please wait ..."
111
echo "Il est temps d'aller prendre un café :-) "
111
echo "Il est temps d'aller prendre un café :-) "
112
echo "You should now take a Beer ;-) "
112
echo "You should now take a Beer ;-) "
113
urpmi --auto --auto-update --quiet --test --retry 2
113
urpmi --auto --auto-update --quiet --test --retry 2
114
if [ "$?" != "0" ]
114
if [ "$?" != "0" ]
115
then
115
then
116
	echo
116
	echo
117
	echo "Une erreur a été détectée lors de la récupération des paquetages."
117
	echo "Une erreur a été détectée lors de la récupération des paquetages."
118
	echo "An error occurs when downloading RPMS"
118
	echo "An error occurs when downloading RPMS"
119
	rpm_error
119
	rpm_error
120
	exit 1
120
	exit 1
121
fi
121
fi
122
# update with cached RPM
122
# update with cached RPM
123
urpmi --auto --auto-update
123
urpmi --auto --auto-update
124
if [ "$?" != "0" ]
124
if [ "$?" != "0" ]
125
then
125
then
126
	echo
126
	echo
127
	echo "Une erreur a été détectée lors de la mise à jour des paquetages."
127
	echo "Une erreur a été détectée lors de la mise à jour des paquetages."
128
	echo "An error occurs when updating packages"
128
	echo "An error occurs when updating packages"
129
	rpm_error
129
	rpm_error
130
	exit 1
130
	exit 1
131
fi
131
fi
132
# Clean the RPM cache
132
# Clean the RPM cache
133
urpmi --clean
133
urpmi --clean
134
# Download of ALCASAR specifics RPM in cache (and test)
134
# Download of ALCASAR specifics RPM in cache (and test)
135
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
135
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
136
echo "Download of complementary packages. Please wait ..."
136
echo "Download of complementary packages. Please wait ..."
137
urpmi --auto $PACKAGES --quiet --test --retry 2
137
urpmi --auto $PACKAGES --quiet --test --retry 2
138
if [ "$?" != "0" ]
138
if [ "$?" != "0" ]
139
then
139
then
140
	echo
140
	echo
141
	echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
141
	echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
142
	echo "An error occurs when downloading complementary packages"
142
	echo "An error occurs when downloading complementary packages"
143
	rpm_error
143
	rpm_error
144
	exit 1
144
	exit 1
145
fi
145
fi
146
# update with cached RPM
146
# update with cached RPM
147
urpmi --auto $PACKAGES 
147
urpmi --auto $PACKAGES 
148
if [ "$?" != "0" ]
148
if [ "$?" != "0" ]
149
then
149
then
150
	echo
150
	echo
151
	echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
151
	echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
152
	echo "An error occurs when installing complementary packages"
152
	echo "An error occurs when installing complementary packages"
153
	rpm_error
153
	rpm_error
154
	exit 1
154
	exit 1
155
fi
155
fi
156
# delete old alcasar RPMs
156
# delete old alcasar RPMs
157
for rm_rpm in c-icap-server lib64chilli0 libchilli0 python-coova-chilli
157
for rm_rpm in c-icap-server lib64chilli0 libchilli0 python-coova-chilli
158
do
158
do
159
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
159
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
160
done
160
done
161
# On installe les RPMs spécifiques à la version
161
# Save chilli launch script (erase with new rpm one)
-
 
162
cp /etc/chilli.conf /tmp/
-
 
163
# Install home made RPMs
162
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
164
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
-
 
165
# restore chilli launch script
-
 
166
mv -f /tmp/chilli.conf /etc/
163
# On empêche les mises à jour de coova-chilli et freeradius par le biais des dépôts
167
# Don't upgrade coova-chilli and freeradius via repository
164
for rpmskip in coova-chilli freeradius 
168
for rpmskip in coova-chilli freeradius 
165
do
169
do
166
	echo -n "/^$rpmskip/" >> /etc/urpmi/skip.list
170
	echo -n "/^$rpmskip/" >> /etc/urpmi/skip.list
167
done
171
done
168
# Clean the RPM cache
172
# Clean the RPM cache
169
urpmi --clean
173
urpmi --clean
170
exit 0
174
exit 0
171
 
175
 
172
 
176