Subversion Repositories ALCASAR

Rev

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

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