Subversion Repositories ALCASAR

Rev

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

Rev 806 Rev 835
1
#!/bin/sh
1
#!/bin/sh
2
# $Id: alcasar-urpmi.sh 806 2012-02-05 22:19:41Z richard $
2
# $Id: alcasar-urpmi.sh 835 2012-03-11 22:21: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 cdrecord buffer vim-enhanced bind-utils wget arpscan ulogd openssh-server php-xml php-ldap pam_ccreds rng-utils lsb-release dnsmasq sudo syslinux 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 cdrecord buffer vim-enhanced bind-utils arpscan ulogd openssh-server php-xml php-ldap pam_ccreds rng-utils lsb-release dnsmasq sudo syslinux cronie-anacron pciutils clamav pm-fallback-policy "
15
 
15
 
16
rpm_repository_sync ()
16
rpm_repository_sync ()
17
{
17
{
18
echo ${!MIRRORLIST}
18
cat <<EOF > /etc/urpmi/urpmi.cfg
-
 
19
{
19
urpmi.removemedia -a
20
downloader: wget
-
 
21
}
-
 
22
EOF
20
urpmi.addmedia --wget --probe-synthesis --mirrorlist ${!MIRRORLIST} main /media/main/release
23
urpmi.addmedia --probe-synthesis --mirrorlist ${!MIRRORLIST} main /media/main/release
21
urpmi.addmedia --wget --update --probe-synthesis --mirrorlist ${!MIRRORLIST} main_updates /media/main/updates
24
urpmi.addmedia --update --probe-synthesis --mirrorlist ${!MIRRORLIST} main_updates /media/main/updates
22
urpmi.addmedia --wget --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib /media/contrib/release
25
urpmi.addmedia --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib /media/contrib/release
23
urpmi.addmedia --wget --update --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib_updates /media/contrib/updates
26
urpmi.addmedia --update --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib_updates /media/contrib/updates
24
}
27
}
25
 
28
 
26
rpm_error ()
29
rpm_error ()
27
{
30
{
28
echo
31
echo
29
echo "Relancez l'installation ultérieurement."
32
echo "Relancez l'installation ultérieurement."
30
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'"
31
echo "Try an other install later."
34
echo "Try an other install later."
32
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'"
33
}
36
}
34
# extract the current Mandriva version and hardware architecture (i586 ou X64)
37
# extract the current Mandriva version and hardware architecture (i586 ou X64)
35
fic=`cat /etc/product.id`
38
fic=`cat /etc/product.id`
36
old="$IFS"
39
old="$IFS"
37
IFS=","
40
IFS=","
38
set $fic
41
set $fic
39
for i in $*
42
for i in $*
40
do
43
do
41
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
44
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
42
	then 
45
	then 
43
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
46
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
44
		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" ] 
45
		then
48
		then
46
		      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."
47
		      echo "Réalisez une mise à jour manuelle (cf. doc)."
50
		      echo "Réalisez une mise à jour manuelle (cf. doc)."
48
		      echo "The automatic system update can't perform."
51
		      echo "The automatic system update can't perform."
49
		      echo "Do a manual update (see doc)."
52
		      echo "Do a manual update (see doc)."
50
		exit 1		
53
		exit 1		
51
		fi
54
		fi
52
	fi
55
	fi
53
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
56
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
54
	then 
57
	then 
55
		ARCH=`echo $i|cut -d"=" -f2`
58
		ARCH=`echo $i|cut -d"=" -f2`
56
	fi
59
	fi
57
done
60
done
58
IFS="$old"
61
IFS="$old"
59
# We prefer wget than curl
62
# We prefer wget than curl
60
urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
63
urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
61
# Set the RPM repository
64
# Set the RPM repository
62
MIRROR_NBR=2
65
MIRROR_NBR=2
63
#                       For french ALCASARistes
66
#                       For french ALCASARistes
64
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"
65
#                       For International install
68
#                       For International install
66
MIRRORLIST2="http://api.mandriva.com/mirrors/basic.$VERSION.$ARCH.list"
69
MIRRORLIST2="http://api.mandriva.com/mirrors/basic.$VERSION.$ARCH.list"
67
try_nb="0"; nb_repository="0"
70
try_nb="0"; nb_repository="0"
68
while [ "$nb_repository" != "4" ]
71
while [ "$nb_repository" != "4" ]
69
do
72
do
70
	try_nb=`expr $try_nb + 1`
73
	try_nb=`expr $try_nb + 1`
71
	MIRRORLIST="MIRRORLIST$try_nb"
74
	MIRRORLIST="MIRRORLIST$try_nb"
72
	rpm_repository_sync 
75
	rpm_repository_sync 
73
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
76
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
74
	if [ "$nb_repository" != "4" ]
77
	if [ "$nb_repository" != "4" ]
75
	then
78
	then
76
		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."
77
		echo "An error occurs when synchronising the repositories N°$try_nb"
80
		echo "An error occurs when synchronising the repositories N°$try_nb"
78
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
81
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
79
		then
82
		then
80
			rpm_error
83
			rpm_error
81
			exit 1
84
			exit 1
82
		fi
85
		fi
83
		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?"
84
		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?"
85
		response=0
88
		response=0
86
		PTN='^[oOnNyY]$'
89
		PTN='^[oOnNyY]$'
87
		until [[ $(expr $response : $PTN) -gt 0 ]]
90
		until [[ $(expr $response : $PTN) -gt 0 ]]
88
		do
91
		do
89
			read response
92
			read response
90
		done
93
		done
91
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
94
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
92
		then
95
		then
93
			exit 1
96
			exit 1
94
		fi
97
		fi
95
	fi
98
	fi
96
done
99
done
97
# delete unused RPMs
100
# delete unused RPMs
98
echo "Cleaning the system : "
101
echo "Cleaning the system : "
99
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
100
do
103
do
101
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
104
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
102
	echo -n "."
105
	echo -n "."
103
done
106
done
104
echo
107
echo
105
# download RPM in cache 
108
# download RPM in cache 
106
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
109
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
107
echo "Updated RPM download. Please wait ..."
110
echo "Updated RPM download. Please wait ..."
108
echo "Il est temps d'aller prendre un café :-) "
111
echo "Il est temps d'aller prendre un café :-) "
109
echo "You should now take a Beer ;-) "
112
echo "You should now take a Beer ;-) "
110
urpmi --downloader wget --auto --auto-update --quiet --test --retry 2
113
urpmi --auto --auto-update --quiet --test --retry 2
111
if [ "$?" != "0" ]
114
if [ "$?" != "0" ]
112
then
115
then
113
	echo
116
	echo
114
	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."
115
	echo "An error occurs when downloading RPMS"
118
	echo "An error occurs when downloading RPMS"
116
	rpm_error
119
	rpm_error
117
	exit 1
120
	exit 1
118
fi
121
fi
119
# update with cached RPM
122
# update with cached RPM
120
urpmi --auto --auto-update
123
urpmi --auto --auto-update
121
if [ "$?" != "0" ]
124
if [ "$?" != "0" ]
122
then
125
then
123
	echo
126
	echo
124
	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."
125
	echo "An error occurs when updating packages"
128
	echo "An error occurs when updating packages"
126
	rpm_error
129
	rpm_error
127
	exit 1
130
	exit 1
128
fi
131
fi
129
# Clean the RPM cache
132
# Clean the RPM cache
130
urpmi --clean
133
urpmi --clean
131
# Download of ALCASAR specifics RPM in cache (and test)
134
# Download of ALCASAR specifics RPM in cache (and test)
132
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
135
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
133
echo "Download of complementary packages. Please wait ..."
136
echo "Download of complementary packages. Please wait ..."
134
urpmi --downloader wget --auto $PACKAGES --quiet --test --retry 2
137
urpmi --auto $PACKAGES --quiet --test --retry 2
135
if [ "$?" != "0" ]
138
if [ "$?" != "0" ]
136
then
139
then
137
	echo
140
	echo
138
	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."
139
	echo "An error occurs when downloading complementary packages"
142
	echo "An error occurs when downloading complementary packages"
140
	rpm_error
143
	rpm_error
141
	exit 1
144
	exit 1
142
fi
145
fi
143
# update with cached RPM
146
# update with cached RPM
144
urpmi --auto $PACKAGES 
147
urpmi --auto $PACKAGES 
145
if [ "$?" != "0" ]
148
if [ "$?" != "0" ]
146
then
149
then
147
	echo
150
	echo
148
	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."
149
	echo "An error occurs when installing complementary packages"
152
	echo "An error occurs when installing complementary packages"
150
	rpm_error
153
	rpm_error
151
	exit 1
154
	exit 1
152
fi
155
fi
153
# delete old alcasar RPMs
156
# delete old alcasar RPMs
154
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
155
do
158
do
156
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
159
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
157
done
160
done
158
# On installe les RPMs spécifiques à la version
161
# On installe les RPMs spécifiques à la version
159
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
162
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
160
# On empêche les mises à jour de coova-chilli et freeradius par le biais des dépôts
163
# On empêche les mises à jour de coova-chilli et freeradius par le biais des dépôts
161
for rpmskip in coova-chilli freeradius 
164
for rpmskip in coova-chilli freeradius 
162
do
165
do
163
	echo -n "/^$rpmskip/" >> /etc/urpmi/skip.list
166
	echo -n "/^$rpmskip/" >> /etc/urpmi/skip.list
164
done
167
done
165
# Clean the RPM cache
168
# Clean the RPM cache
166
urpmi --clean
169
urpmi --clean
167
exit 0
170
exit 0
168
 
171
 
169
 
172