Subversion Repositories ALCASAR

Rev

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

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