Subversion Repositories ALCASAR

Rev

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

Rev 1154 Rev 1157
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-urpmi.sh 1154 2013-07-15 14:27:10Z crox53 $
2
# $Id: alcasar-urpmi.sh 1157 2013-07-16 10:48:11Z stephane $
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
Lang=`echo $LANG|cut -c 1-2`
11
Lang=`echo $LANG|cut -c 1-2`
12
VERSION="2"
12
VERSION="2"
13
ARCH="i586" 
13
ARCH="i586" 
14
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
14
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
15
PACKAGES="sudo freeradius freeradius-mysql freeradius-ldap freeradius-web apache-mpm-prefork apache-mod_ssl apache-mod_php iptables squid dansguardian postfix mariadb logwatch ntp bind-utils openssh-server php-xml php-ldap php-mysql pam_ccreds rng-utils dnsmasq syslinux rsync cronie-anacron clamav pm-fallback-policy php-mbstring perl-rrdtool perl-MailTools perl-Socket6 php-sockets kernel-desktop-3.4.45-1.mga2-1-1.mga2"
15
PACKAGES="sudo 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 php-mbstring"
-
 
16
 
16
rpm_repository_sync ()
17
rpm_repository_sync ()
17
{
18
{
18
cat <<EOF > /etc/urpmi/urpmi.cfg
19
cat <<EOF > /etc/urpmi/urpmi.cfg
19
{
20
{
20
downloader: wget
21
downloader: wget
21
}
22
}
22
EOF
23
EOF
23
echo ${!MIRRORLIST}
24
echo ${!MIRRORLIST}
24
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
25
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
25
urpmi.addmedia core-updates --update --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/updates
26
urpmi.addmedia core-updates --update --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/updates
26
}
27
}
27
 
28
 
28
rpm_error ()
29
rpm_error ()
29
{
30
{
30
echo
31
echo
31
if [ $Lang == "fr" ]
32
if [ $Lang == "fr" ]
32
then	
33
then	
33
	echo "Relancez l'installation ultérieurement."
34
	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'"
35
	echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
35
else
36
else
36
	echo "Try an other install later."
37
	echo "Try an other install later."
37
	echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
38
	echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
38
fi
39
fi
39
}
40
}
40
# extract the current Mandriva/Mageia version and hardware architecture (i586 ou X64)
41
# extract the current Mandriva/Mageia version and hardware architecture (i586 ou X64)
41
fic=`cat /etc/product.id`
42
fic=`cat /etc/product.id`
42
unknown_os=0
43
unknown_os=0
43
old="$IFS"
44
old="$IFS"
44
IFS=","
45
IFS=","
45
set $fic
46
set $fic
46
for i in $*
47
for i in $*
47
do
48
do
48
	if [ "`echo $i|grep distribution|cut -d'=' -f1`" == "distribution" ]
49
	if [ "`echo $i|grep distribution|cut -d'=' -f1`" == "distribution" ]
49
	then 
50
	then 
50
		DISTRIBUTION=`echo $i|cut -d"=" -f2`
51
		DISTRIBUTION=`echo $i|cut -d"=" -f2`
51
		unknown_os=`expr $unknown_os + 1`
52
		unknown_os=`expr $unknown_os + 1`
52
	fi
53
	fi
53
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
54
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
54
	then 
55
	then 
55
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
56
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
56
		unknown_os=`expr $unknown_os + 1`
57
		unknown_os=`expr $unknown_os + 1`
57
	fi
58
	fi
58
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
59
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
59
	then 
60
	then 
60
		ARCH=`echo $i|cut -d"=" -f2`
61
		ARCH=`echo $i|cut -d"=" -f2`
61
		unknown_os=`expr $unknown_os + 1`
62
		unknown_os=`expr $unknown_os + 1`
62
	fi
63
	fi
63
done
64
done
64
IFS="$old"
65
IFS="$old"
65
if [[ ( $unknown_os != 3 || "$DISTRIBUTION" != "Mageia" ) && ( "$CURRENT_VERSION" != "2" ) ]]
66
if [[ ( $unknown_os != 3 || "$DISTRIBUTION" != "Mageia" ) && ( "$CURRENT_VERSION" != "2" ) ]]
66
then
67
then
67
	if [ $Lang == "fr" ]
68
	if [ $Lang == "fr" ]
68
	then	
69
	then	
69
		echo "La migration automatique d'ALCASAR ne peut pas être réalisée."
70
		echo "La migration automatique d'ALCASAR ne peut pas être réalisée."
70
		echo "Le système d'exploitation doit être remplacé"
71
		echo "Le système d'exploitation doit être remplacé"
71
	else
72
	else
72
		echo "The automatic update of ALCASAR can't be performed."
73
		echo "The automatic update of ALCASAR can't be performed."
73
		echo "The OS must be replaced"
74
		echo "The OS must be replaced"
74
	fi
75
	fi
75
	if [ -e /tmp/alcasar-conf.tar.gz ]
76
	if [ -e /tmp/alcasar-conf.tar.gz ]
76
	then
77
	then
77
		echo
78
		echo
78
		if [ $Lang == "fr" ]
79
		if [ $Lang == "fr" ]
79
		then	
80
		then	
80
			echo "1 - Récupérez le fichier de configuration actuel (/tmp/alcasar-conf.tar.gz)."
81
			echo "1 - Récupérez le fichier de configuration actuel (/tmp/alcasar-conf.tar.gz)."
81
			echo "2 - Installez Linux-Mageia2 (cf. doc d'installation)"
82
			echo "2 - Installez Linux-Mageia2 (cf. doc d'installation)"
82
			echo "3 - copiez le fichier 'alcasar-conf.tar.gz' dans le répertoire '/tmp' avant de lancer l'installation d'ALCASAR"
83
			echo "3 - copiez le fichier 'alcasar-conf.tar.gz' dans le répertoire '/tmp' avant de lancer l'installation d'ALCASAR"
83
		else
84
		else
84
			echo "1 - Retrieve the configuration file (/tmp/alcasar-conf.tar.gz)"
85
			echo "1 - Retrieve the configuration file (/tmp/alcasar-conf.tar.gz)"
85
			echo "2 - Install Linux-Mageia2 (cf. installation doc)"
86
			echo "2 - Install Linux-Mageia2 (cf. installation doc)"
86
			echo "3 - Copy the file 'alcasar-conf.tar.gz' in the folder '/tmp' before launching the installation of ALCASAR"
87
			echo "3 - Copy the file 'alcasar-conf.tar.gz' in the folder '/tmp' before launching the installation of ALCASAR"
87
		fi
88
		fi
88
	fi
89
	fi
89
	exit 1
90
	exit 1
90
fi
91
fi
91
# We prefer wget than curl
92
# We prefer wget than curl
92
urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
93
urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
93
# Set the RPM repository
94
# Set the RPM repository
94
MIRROR_NBR=2
95
MIRROR_NBR=2
95
#                       For Europeans 
96
#                       For Europeans 
96
MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
97
MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
97
#                       For International install
98
#                       For International install
98
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
99
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
99
try_nb="0"; nb_repository="0"
100
try_nb="0"; nb_repository="0"
100
while [ "$nb_repository" != "2" ]
101
while [ "$nb_repository" != "2" ]
101
do
102
do
102
	try_nb=`expr $try_nb + 1`
103
	try_nb=`expr $try_nb + 1`
103
	MIRRORLIST="MIRRORLIST$try_nb"
104
	MIRRORLIST="MIRRORLIST$try_nb"
104
	rpm_repository_sync 
105
	rpm_repository_sync 
105
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
106
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
106
	if [ "$nb_repository" != "2" ]
107
	if [ "$nb_repository" != "2" ]
107
	then
108
	then
108
		if [ $Lang == "fr" ]
109
		if [ $Lang == "fr" ]
109
		then	
110
		then	
110
			echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
111
			echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
111
		else
112
		else
112
			echo "An error occurs when synchronising the repositories N°$try_nb"
113
			echo "An error occurs when synchronising the repositories N°$try_nb"
113
		fi
114
		fi
114
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
115
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
115
		then
116
		then
116
			rpm_error
117
			rpm_error
117
			exit 1
118
			exit 1
118
		fi
119
		fi
119
		if [ $Lang == "fr" ]
120
		if [ $Lang == "fr" ]
120
		then	
121
		then	
121
			echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
122
			echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
122
		else
123
		else
123
			echo "Do you wan't to try a synchronisation with an other repository?"
124
			echo "Do you wan't to try a synchronisation with an other repository?"
124
		fi
125
		fi
125
		response=0
126
		response=0
126
		PTN='^[oOnNyY]$'
127
		PTN='^[oOnNyY]$'
127
		until [[ $(expr $response : $PTN) -gt 0 ]]
128
		until [[ $(expr $response : $PTN) -gt 0 ]]
128
		do
129
		do
129
			read response
130
			read response
130
		done
131
		done
131
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
132
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
132
		then
133
		then
133
			exit 1
134
			exit 1
134
		fi
135
		fi
135
	fi
136
	fi
136
done
137
done
137
# delete unused RPMs
138
# delete unused RPMs
138
echo "Cleaning the system : "
139
echo "Cleaning the system : "
139
for rm_rpm in shorewall mandi radeontool avahi
140
for rm_rpm in shorewall mandi radeontool avahi
140
do
141
do
141
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
142
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
142
	echo -n "."
143
	echo -n "."
143
done
144
done
144
echo
145
echo
145
# download RPM in cache 
146
# download RPM in cache 
146
if [ $Lang == "fr" ]
147
if [ $Lang == "fr" ]
147
then	
148
then	
148
	echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
149
	echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
149
	echo "Il est temps d'aller prendre un café (ou une bonne bière) ;-)"
150
	echo "Il est temps d'aller prendre un café (ou une bonne bière) ;-)"
150
else
151
else
151
	echo "Updated RPM download. Please wait ..."
152
	echo "Updated RPM download. Please wait ..."
152
	echo "You should now take a coffe (or a good beer) ;-)"
153
	echo "You should now take a coffe (or a good beer) ;-)"
153
fi
154
fi
154
urpmi --auto --auto-update --quiet --test --retry 2
155
urpmi --auto --auto-update --quiet --test --retry 2
155
if [ "$?" != "0" ]
156
if [ "$?" != "0" ]
156
then
157
then
157
	echo
158
	echo
158
	if [ $Lang == "fr" ]
159
	if [ $Lang == "fr" ]
159
	then	
160
	then	
160
		echo "Une erreur a été détectée lors de la récupération des paquetages."
161
		echo "Une erreur a été détectée lors de la récupération des paquetages."
161
	else
162
	else
162
		echo "An error occurs when downloading RPMS"
163
		echo "An error occurs when downloading RPMS"
163
	fi
164
	fi
164
	rpm_error
165
	rpm_error
165
	exit 1
166
	exit 1
166
fi
167
fi
167
# update with cached RPM
168
# update with cached RPM
168
urpmi --auto --auto-update
169
urpmi --auto --auto-update
169
if [ "$?" != "0" ]
170
if [ "$?" != "0" ]
170
then
171
then
171
	echo
172
	echo
172
	if [ $Lang == "fr" ]
173
	if [ $Lang == "fr" ]
173
	then	
174
	then	
174
		echo "Une erreur a été détectée lors de la mise à jour des paquetages."
175
		echo "Une erreur a été détectée lors de la mise à jour des paquetages."
175
	else
176
	else
176
		echo "An error occurs when updating packages"
177
		echo "An error occurs when updating packages"
177
	fi
178
	fi
178
	rpm_error
179
	rpm_error
179
	exit 1
180
	exit 1
180
fi
181
fi
181
# Clean the RPM cache
182
# Clean the RPM cache
182
urpmi --clean
183
urpmi --clean
183
# Download of ALCASAR specifics RPM in cache (and test)
184
# Download of ALCASAR specifics RPM in cache (and test)
184
if [ $Lang == "fr" ]
185
if [ $Lang == "fr" ]
185
then	
186
then	
186
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
187
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
187
else
188
else
188
	echo "Download of complementary packages. Please wait ..."
189
	echo "Download of complementary packages. Please wait ..."
189
fi
190
fi
190
urpmi --auto $PACKAGES --quiet --test --retry 2
191
urpmi --auto $PACKAGES --quiet --test --retry 2
191
if [ "$?" != "0" ]
192
if [ "$?" != "0" ]
192
then
193
then
193
	echo
194
	echo
194
	if [ $Lang == "fr" ]
195
	if [ $Lang == "fr" ]
195
	then	
196
	then	
196
		echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
197
		echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
197
	else
198
	else
198
		echo "An error occurs when downloading complementary packages"
199
		echo "An error occurs when downloading complementary packages"
199
	fi
200
	fi
200
	rpm_error
201
	rpm_error
201
	exit 1
202
	exit 1
202
fi
203
fi
203
# update with cached RPM
204
# update with cached RPM
204
urpmi --auto $PACKAGES 
205
urpmi --auto $PACKAGES 
205
if [ "$?" != "0" ]
206
if [ "$?" != "0" ]
206
then
207
then
207
	echo
208
	echo
208
	if [ $Lang == "fr" ]
209
	if [ $Lang == "fr" ]
209
	then	
210
	then	
210
		echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
211
		echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
211
	else
212
	else
212
		echo "An error occurs when installing complementary packages"
213
		echo "An error occurs when installing complementary packages"
213
	fi
214
	fi
214
	rpm_error
215
	rpm_error
215
	exit 1
216
	exit 1
216
fi
217
fi
217
# delete old alcasar RPMs and unused services
218
# delete old alcasar RPMs and unused services
218
for rm_rpm in c-icap-server lib64chilli0 libchilli0 python-coova-chilli cyrus-sasl mageia-gfxboot-theme
219
for rm_rpm in c-icap-server lib64chilli0 libchilli0 python-coova-chilli cyrus-sasl mageia-gfxboot-theme
219
do
220
do
220
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
221
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
221
done
222
done
222
# Save chilli launch script (erase with new rpm one)
223
# Save chilli launch script (erase with new rpm one)
223
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
224
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
224
# Install home made RPMs
225
# Install home made RPMs
225
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
226
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
226
# restore chilli launch script
227
# restore chilli launch script
227
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
228
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
228
# Clean the RPM cache
229
# Clean the RPM cache
229
urpmi --clean
230
urpmi --clean
230
 
-
 
231
#Keep only kernel-desktop-3.4.45-1.mga2-1-1.mga2 version, and remove all others
-
 
232
kernelVersion=$(rpm -qa | grep "kernel-desktop")
-
 
233
for i in $kernelVersion
-
 
234
do
-
 
235
	if [ ! $i = "kernel-desktop-3.4.45-1.mga2-1-1.mga2" ];then
-
 
236
		urpme $i
-
 
237
	fi
-
 
238
done
-
 
239
 
-
 
240
#Fix the kernel version to : kernel-desktop-3.4.45-1.mga2-1-1.mga2
-
 
241
	echo "/^kernel-desktop/" > /etc/urpmi/skip.list 
-
 
242
 
-
 
243
#update tht kernel modules list
-
 
244
depmod -a
-
 
245
 
-
 
246
exit 0
231
exit 0
247
 
232