Subversion Repositories ALCASAR

Rev

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

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