Subversion Repositories ALCASAR

Rev

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

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