Subversion Repositories ALCASAR

Rev

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

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