Subversion Repositories ALCASAR

Rev

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

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