Subversion Repositories ALCASAR

Rev

Rev 1336 | 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 1342 2014-05-06 10:10:39Z 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 ******
1342 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 pm-fallback-policy perl-rrdtool perl-MailTools perl-Socket6 fail2ban gnupg man ipset ulogd"
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
 
772 richard 139
# delete unused RPMs
1207 richard 140
if [ $Lang == "fr" ]
141
then
142
	echo "Cleaning the system : "
143
else
144
	echo "Nettoyage du système : "
145
fi
1336 richard 146
for rm_rpm in shorewall mandi radeontool mesa avahi 
772 richard 147
do
148
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
149
	echo -n "."
150
done
1207 richard 151
# download updated RPM in cache 
152
if [ $Lang == "fr" ]
153
then	
1060 richard 154
	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) ;-)"
156
else
157
	echo "Updated RPM download. Please wait ..."
158
	echo "You should now take a coffe (or a good beer) ;-)"
159
fi
835 richard 160
urpmi --auto --auto-update --quiet --test --retry 2
460 richard 161
if [ "$?" != "0" ]
162
then
163
	echo
1060 richard 164
	if [ $Lang == "fr" ]
165
	then	
166
		echo "Une erreur a été détectée lors de la récupération des paquetages."
167
	else
168
		echo "An error occurs when downloading RPMS"
169
	fi
532 richard 170
	rpm_error
470 richard 171
	exit 1
460 richard 172
fi
173
# update with cached RPM
174
urpmi --auto --auto-update
799 richard 175
if [ "$?" != "0" ]
176
then
177
	echo
1060 richard 178
	if [ $Lang == "fr" ]
179
	then	
180
		echo "Une erreur a été détectée lors de la mise à jour des paquetages."
181
	else
182
		echo "An error occurs when updating packages"
183
	fi
799 richard 184
	rpm_error
185
	exit 1
186
fi
772 richard 187
# Clean the RPM cache
188
urpmi --clean
532 richard 189
# Download of ALCASAR specifics RPM in cache (and test)
1060 richard 190
if [ $Lang == "fr" ]
191
then	
192
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
193
else
194
	echo "Download of complementary packages. Please wait ..."
195
fi
835 richard 196
urpmi --auto $PACKAGES --quiet --test --retry 2
532 richard 197
if [ "$?" != "0" ]
198
then
199
	echo
1060 richard 200
	if [ $Lang == "fr" ]
201
	then	
202
		echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
203
	else
204
		echo "An error occurs when downloading complementary packages"
205
	fi
532 richard 206
	rpm_error
207
	exit 1
208
fi
209
# update with cached RPM
210
urpmi --auto $PACKAGES 
799 richard 211
if [ "$?" != "0" ]
212
then
213
	echo
1060 richard 214
	if [ $Lang == "fr" ]
215
	then	
216
		echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
217
	else
218
		echo "An error occurs when installing complementary packages"
219
	fi
799 richard 220
	rpm_error
221
	exit 1
222
fi
1336 richard 223
# delete unused services
1342 richard 224
for rm_rpm in mageia-gfxboot-theme
1207 richard 225
do
532 richard 226
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
227
done
1207 richard 228
 
972 richard 229
# Save chilli launch script (erase with new rpm one)
1007 richard 230
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
972 richard 231
# Install home made RPMs
532 richard 232
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
972 richard 233
# restore chilli launch script
1007 richard 234
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
532 richard 235
# Clean the RPM cache
236
urpmi --clean
230 franck 237
exit 0