Subversion Repositories ALCASAR

Rev

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

Rev 1415 Rev 1485
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-urpmi.sh 1415 2014-07-20 20:42:41Z richard $
2
# $Id: alcasar-urpmi.sh 1485 2014-11-12 08:12:40Z 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="vim-enhanced 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-mysqli php-mbstring php-sockets php-cli php-curl php-pdo_sqlite php-json rng-utils dnsmasq rsync clamav perl-rrdtool perl-MailTools perl-Socket6 fail2ban gnupg ulogd dkms-ipt_NETFLOW iptables-NETFLOW pm-fallback-policy ipset cronie-anacron gammu usbutils locales-en usb_modeswitch"
15
PACKAGES="vim-enhanced 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-mysqli php-mbstring php-sockets php-cli php-curl php-pdo_sqlite php-json rng-utils dnsmasq rsync clamav perl-rrdtool perl-MailTools perl-Socket6 fail2ban gnupg ulogd dkms-ipt_NETFLOW iptables-NETFLOW pm-fallback-policy ipset cronie-anacron gammu usbutils locales-en usb_modeswitch tinyproxy"
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 "L'installation ou la mise @ jour d'ALCASAR ne peut pas être réalisée."
70
		echo "L'installation ou la mise @ jour d'ALCASAR ne peut pas être réalisée."
71
		echo "Le système d'exploitation doit être remplacé (Mageia4)"
71
		echo "Le système d'exploitation doit être remplacé (Mageia4)"
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 (Mageia4)"
74
		echo "The OS must be replaced (Mageia4)"
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 (if not already set)
94
# Set the RPM repository (if not already set)
95
ACTIVE_REPO=`cat /etc/urpmi/urpmi.cfg|grep "mageia.org"|wc -l`
95
ACTIVE_REPO=`cat /etc/urpmi/urpmi.cfg|grep "mageia.org"|wc -l`
96
if [ "$ACTIVE_REPO" != "2" ]
96
if [ "$ACTIVE_REPO" != "2" ]
97
	then
97
	then
98
	MIRROR_NBR=2
98
	MIRROR_NBR=2
99
	#                       For Europeans 
99
	#                       For Europeans 
100
	MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
100
	MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
101
	#                       For International install
101
	#                       For International install
102
	MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
102
	MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
103
	try_nb="0"; nb_repository="0"
103
	try_nb="0"; nb_repository="0"
104
	while [ "$nb_repository" != "2" ]
104
	while [ "$nb_repository" != "2" ]
105
	do
105
	do
106
		try_nb=`expr $try_nb + 1`
106
		try_nb=`expr $try_nb + 1`
107
		MIRRORLIST="MIRRORLIST$try_nb"
107
		MIRRORLIST="MIRRORLIST$try_nb"
108
		rpm_repository_sync 
108
		rpm_repository_sync 
109
		nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
109
		nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
110
		if [ "$nb_repository" != "2" ]
110
		if [ "$nb_repository" != "2" ]
111
		then
111
		then
112
			if [ $Lang == "fr" ]
112
			if [ $Lang == "fr" ]
113
			then	
113
			then	
114
				echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
114
				echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
115
			else
115
			else
116
				echo "An error occurs when synchronising the repositories N°$try_nb"
116
				echo "An error occurs when synchronising the repositories N°$try_nb"
117
			fi
117
			fi
118
			if [ $(expr $try_nb) -eq $MIRROR_NBR ]
118
			if [ $(expr $try_nb) -eq $MIRROR_NBR ]
119
			then
119
			then
120
				rpm_error
120
				rpm_error
121
				exit 1
121
				exit 1
122
			fi
122
			fi
123
			if [ $Lang == "fr" ]
123
			if [ $Lang == "fr" ]
124
			then	
124
			then	
125
				echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
125
				echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
126
			else
126
			else
127
				echo "Do you wan't to try a synchronisation with an other repository?"
127
				echo "Do you wan't to try a synchronisation with an other repository?"
128
			fi
128
			fi
129
			response=0
129
			response=0
130
			PTN='^[oOnNyY]$'
130
			PTN='^[oOnNyY]$'
131
			until [[ $(expr $response : $PTN) -gt 0 ]]
131
			until [[ $(expr $response : $PTN) -gt 0 ]]
132
			do
132
			do
133
				read response
133
				read response
134
			done
134
			done
135
			if [ "$response" = "n" ] || [ "$response" = "N" ] 
135
			if [ "$response" = "n" ] || [ "$response" = "N" ] 
136
			then
136
			then
137
			exit 1
137
			exit 1
138
			fi
138
			fi
139
		fi
139
		fi
140
	done
140
	done
141
fi
141
fi
142
# download updated RPM in cache 
142
# download updated RPM in cache 
143
if [ $Lang == "fr" ]
143
if [ $Lang == "fr" ]
144
then	
144
then	
145
	echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
145
	echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
146
	echo "Il est temps d'aller prendre un café (ou une bonne bière) ;-)"
146
	echo "Il est temps d'aller prendre un café (ou une bonne bière) ;-)"
147
else
147
else
148
	echo "Updated RPM download. Please wait ..."
148
	echo "Updated RPM download. Please wait ..."
149
	echo "You should now take a coffe (or a good beer) ;-)"
149
	echo "You should now take a coffe (or a good beer) ;-)"
150
fi
150
fi
151
urpmi --auto --auto-update --quiet --test --retry 2
151
urpmi --auto --auto-update --quiet --test --retry 2
152
if [ "$?" != "0" ]
152
if [ "$?" != "0" ]
153
then
153
then
154
	echo
154
	echo
155
	if [ $Lang == "fr" ]
155
	if [ $Lang == "fr" ]
156
	then	
156
	then	
157
		echo "Une erreur a été détectée lors de la récupération des paquetages."
157
		echo "Une erreur a été détectée lors de la récupération des paquetages."
158
	else
158
	else
159
		echo "An error occurs when downloading RPMS"
159
		echo "An error occurs when downloading RPMS"
160
	fi
160
	fi
161
	rpm_error
161
	rpm_error
162
	exit 1
162
	exit 1
163
fi
163
fi
164
# update with cached RPM
164
# update with cached RPM
165
urpmi --auto --auto-update
165
urpmi --auto --auto-update
166
if [ "$?" != "0" ]
166
if [ "$?" != "0" ]
167
then
167
then
168
	echo
168
	echo
169
	if [ $Lang == "fr" ]
169
	if [ $Lang == "fr" ]
170
	then	
170
	then	
171
		echo "Une erreur a été détectée lors de la mise à jour des paquetages."
171
		echo "Une erreur a été détectée lors de la mise à jour des paquetages."
172
	else
172
	else
173
		echo "An error occurs when updating packages"
173
		echo "An error occurs when updating packages"
174
	fi
174
	fi
175
	rpm_error
175
	rpm_error
176
	exit 1
176
	exit 1
177
fi
177
fi
178
# Clean the RPM cache
178
# Clean the RPM cache
179
urpmi --clean
179
urpmi --clean
180
# Download of ALCASAR specifics RPM in cache (and test)
180
# Download of ALCASAR specifics RPM in cache (and test)
181
if [ $Lang == "fr" ]
181
if [ $Lang == "fr" ]
182
then	
182
then	
183
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
183
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
184
else
184
else
185
	echo "Download of complementary packages. Please wait ..."
185
	echo "Download of complementary packages. Please wait ..."
186
fi
186
fi
187
urpmi --auto $PACKAGES --quiet --test --retry 2
187
urpmi --auto $PACKAGES --quiet --test --retry 2
188
if [ "$?" != "0" ]
188
if [ "$?" != "0" ]
189
then
189
then
190
	echo
190
	echo
191
	if [ $Lang == "fr" ]
191
	if [ $Lang == "fr" ]
192
	then	
192
	then	
193
		echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
193
		echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
194
	else
194
	else
195
		echo "An error occurs when downloading complementary packages"
195
		echo "An error occurs when downloading complementary packages"
196
	fi
196
	fi
197
	rpm_error
197
	rpm_error
198
	exit 1
198
	exit 1
199
fi
199
fi
200
# update with cached RPM
200
# update with cached RPM
201
urpmi --auto $PACKAGES 
201
urpmi --auto $PACKAGES 
202
if [ "$?" != "0" ]
202
if [ "$?" != "0" ]
203
then
203
then
204
	echo
204
	echo
205
	if [ $Lang == "fr" ]
205
	if [ $Lang == "fr" ]
206
	then	
206
	then	
207
		echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
207
		echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
208
	else
208
	else
209
		echo "An error occurs when installing complementary packages"
209
		echo "An error occurs when installing complementary packages"
210
	fi
210
	fi
211
	rpm_error
211
	rpm_error
212
	exit 1
212
	exit 1
213
fi
213
fi
214
# delete unused RPMs
214
# delete unused RPMs
215
if [ $Lang == "fr" ]
215
if [ $Lang == "fr" ]
216
then
216
then
217
	echo "Cleaning the system : "
217
	echo "Cleaning the system : "
218
else
218
else
219
	echo "Nettoyage du système : "
219
	echo "Nettoyage du système : "
220
fi
220
fi
221
for rm_rpm in shorewall mandi radeontool avahi mageia-gfxboot-theme privoxy cpupower
221
for rm_rpm in shorewall mandi radeontool avahi mageia-gfxboot-theme privoxy cpupower
222
do
222
do
223
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
223
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
224
	echo -n "."
224
	echo -n "."
225
done
225
done
226
 
226
 
227
# Save chilli launch script (erase with new rpm one)
227
# Save chilli launch script (erase with new rpm one)
228
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
228
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
229
# Install home made RPMs
229
# Install home made RPMs
230
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
230
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
231
# restore chilli launch script
231
# restore chilli launch script
232
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
232
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
233
# Clean the RPM cache
233
# Clean the RPM cache
234
urpmi --clean
234
urpmi --clean
235
exit 0
235
exit 0
236
 
236