Subversion Repositories ALCASAR

Rev

Rev 1350 | 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 1352 2014-05-15 16:45:22Z 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 ******
1350 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
1350 richard 94
# Set the RPM repository (if not already set)
1352 richard 95
ACTIVE_REPO=`cat /etc/urpmi/urpmi.cfg|grep "mageia.org"|wc -l`
1350 richard 96
if [ "$ACTIVE_REPO" != "2" ]
497 richard 97
	then
1350 richard 98
	MIRROR_NBR=2
99
	#                       For Europeans 
100
	MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
101
	#                       For International install
102
	MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
103
	try_nb="0"; nb_repository="0"
104
	while [ "$nb_repository" != "2" ]
105
	do
106
		try_nb=`expr $try_nb + 1`
107
		MIRRORLIST="MIRRORLIST$try_nb"
108
		rpm_repository_sync 
109
		nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
110
		if [ "$nb_repository" != "2" ]
497 richard 111
		then
1350 richard 112
			if [ $Lang == "fr" ]
113
			then	
114
				echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
115
			else
116
				echo "An error occurs when synchronising the repositories N°$try_nb"
117
			fi
118
			if [ $(expr $try_nb) -eq $MIRROR_NBR ]
119
			then
120
				rpm_error
121
				exit 1
122
			fi
123
			if [ $Lang == "fr" ]
124
			then	
125
				echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
126
			else
127
				echo "Do you wan't to try a synchronisation with an other repository?"
128
			fi
129
			response=0
130
			PTN='^[oOnNyY]$'
131
			until [[ $(expr $response : $PTN) -gt 0 ]]
132
			do
133
				read response
134
			done
135
			if [ "$response" = "n" ] || [ "$response" = "N" ] 
136
			then
497 richard 137
			exit 1
1350 richard 138
			fi
497 richard 139
		fi
1350 richard 140
	done
141
fi
1207 richard 142
# download updated RPM in cache 
143
if [ $Lang == "fr" ]
144
then	
1060 richard 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) ;-)"
147
else
148
	echo "Updated RPM download. Please wait ..."
149
	echo "You should now take a coffe (or a good beer) ;-)"
150
fi
835 richard 151
urpmi --auto --auto-update --quiet --test --retry 2
460 richard 152
if [ "$?" != "0" ]
153
then
154
	echo
1060 richard 155
	if [ $Lang == "fr" ]
156
	then	
157
		echo "Une erreur a été détectée lors de la récupération des paquetages."
158
	else
159
		echo "An error occurs when downloading RPMS"
160
	fi
532 richard 161
	rpm_error
470 richard 162
	exit 1
460 richard 163
fi
164
# update with cached RPM
165
urpmi --auto --auto-update
799 richard 166
if [ "$?" != "0" ]
167
then
168
	echo
1060 richard 169
	if [ $Lang == "fr" ]
170
	then	
171
		echo "Une erreur a été détectée lors de la mise à jour des paquetages."
172
	else
173
		echo "An error occurs when updating packages"
174
	fi
799 richard 175
	rpm_error
176
	exit 1
177
fi
772 richard 178
# Clean the RPM cache
179
urpmi --clean
532 richard 180
# Download of ALCASAR specifics RPM in cache (and test)
1060 richard 181
if [ $Lang == "fr" ]
182
then	
183
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
184
else
185
	echo "Download of complementary packages. Please wait ..."
186
fi
835 richard 187
urpmi --auto $PACKAGES --quiet --test --retry 2
532 richard 188
if [ "$?" != "0" ]
189
then
190
	echo
1060 richard 191
	if [ $Lang == "fr" ]
192
	then	
193
		echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
194
	else
195
		echo "An error occurs when downloading complementary packages"
196
	fi
532 richard 197
	rpm_error
198
	exit 1
199
fi
200
# update with cached RPM
201
urpmi --auto $PACKAGES 
799 richard 202
if [ "$?" != "0" ]
203
then
204
	echo
1060 richard 205
	if [ $Lang == "fr" ]
206
	then	
207
		echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
208
	else
209
		echo "An error occurs when installing complementary packages"
210
	fi
799 richard 211
	rpm_error
212
	exit 1
213
fi
1348 richard 214
# delete unused RPMs
215
if [ $Lang == "fr" ]
216
then
217
	echo "Cleaning the system : "
218
else
219
	echo "Nettoyage du système : "
220
fi
221
for rm_rpm in shorewall mandi radeontool avahi mageia-gfxboot-theme
1207 richard 222
do
532 richard 223
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
1348 richard 224
	echo -n "."
532 richard 225
done
1207 richard 226
 
972 richard 227
# Save chilli launch script (erase with new rpm one)
1007 richard 228
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
972 richard 229
# Install home made RPMs
532 richard 230
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
972 richard 231
# restore chilli launch script
1007 richard 232
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
532 richard 233
# Clean the RPM cache
234
urpmi --clean
230 franck 235
exit 0