Subversion Repositories ALCASAR

Rev

Rev 1342 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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