Subversion Repositories ALCASAR

Rev

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

Rev 1033 Rev 1056
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-urpmi.sh 1033 2013-02-17 23:08:26Z richard $
2
# $Id: alcasar-urpmi.sh 1056 2013-03-26 21:46:36Z stephane $
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
VERSION="2"
11
VERSION="2"
12
ARCH="i586" 
12
ARCH="i586" 
13
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
13
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
14
PACKAGES="sudo freeradius freeradius-mysql freeradius-ldap freeradius-web apache-mpm-prefork apache-mod_ssl apache-mod_php iptables squid dansguardian postfix mariadb logwatch ntp awstats bind-utils openssh-server php-xml php-ldap php-mysql pam_ccreds rng-utils dnsmasq syslinux rsync cronie-anacron clamav pm-fallback-policy"
14
PACKAGES="sudo freeradius freeradius-mysql freeradius-ldap freeradius-web apache-mpm-prefork apache-mod_ssl apache-mod_php iptables squid dansguardian postfix mariadb logwatch ntp awstats bind-utils openssh-server php-xml php-ldap php-mysql pam_ccreds rng-utils dnsmasq syslinux rsync cronie-anacron clamav pm-fallback-policy"
15
 
15
 
16
rpm_repository_sync ()
16
rpm_repository_sync ()
17
{
17
{
18
cat <<EOF > /etc/urpmi/urpmi.cfg
18
cat <<EOF > /etc/urpmi/urpmi.cfg
19
{
19
{
20
downloader: wget
20
downloader: wget
21
}
21
}
22
EOF
22
EOF
23
echo ${!MIRRORLIST}
23
echo ${!MIRRORLIST}
24
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
24
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
25
urpmi.addmedia core-updates --update --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/updates
25
urpmi.addmedia core-updates --update --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/updates
26
}
26
}
27
 
27
 
28
rpm_error ()
28
rpm_error ()
29
{
29
{
30
echo
30
echo
31
echo "Relancez l'installation ultérieurement."
31
echo "Relancez l'installation ultérieurement."
32
echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
32
echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
33
echo "Try an other install later."
33
echo "Try an other install later."
34
echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
34
echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
35
}
35
}
36
# extract the current Mandriva/Mageia version and hardware architecture (i586 ou X64)
36
# extract the current Mandriva/Mageia version and hardware architecture (i586 ou X64)
37
fic=`cat /etc/product.id`
37
fic=`cat /etc/product.id`
38
unknown_os=0
38
unknown_os=0
39
old="$IFS"
39
old="$IFS"
40
IFS=","
40
IFS=","
41
set $fic
41
set $fic
42
for i in $*
42
for i in $*
43
do
43
do
44
	if [ "`echo $i|grep distribution|cut -d'=' -f1`" == "distribution" ]
44
	if [ "`echo $i|grep distribution|cut -d'=' -f1`" == "distribution" ]
45
	then 
45
	then 
46
		DISTRIBUTION=`echo $i|cut -d"=" -f2`
46
		DISTRIBUTION=`echo $i|cut -d"=" -f2`
47
		unknown_os=`expr $unknown_os + 1`
47
		unknown_os=`expr $unknown_os + 1`
48
	fi
48
	fi
49
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
49
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
50
	then 
50
	then 
51
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
51
		CURRENT_VERSION=`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 arch|cut -d'=' -f1`" == "arch" ]
54
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
55
	then 
55
	then 
56
		ARCH=`echo $i|cut -d"=" -f2`
56
		ARCH=`echo $i|cut -d"=" -f2`
57
		unknown_os=`expr $unknown_os + 1`
57
		unknown_os=`expr $unknown_os + 1`
58
	fi
58
	fi
59
done
59
done
60
IFS="$old"
60
IFS="$old"
61
if [[ ( $unknown_os != 3 || "$DISTRIBUTION" != "Mageia" ) && ( "$CURRENT_VERSION" != "2" ) ]]
61
if [[ ( $unknown_os != 3 || "$DISTRIBUTION" != "Mageia" ) && ( "$CURRENT_VERSION" != "2" ) ]]
62
	then
62
	then
63
	echo "le système Linux installé n'est pas conforme. Installez Mageia2 (cf documentation d'installation)"
63
	echo "le système Linux installé n'est pas conforme. Installez Mageia2 (cf documentation d'installation)"
64
	echo "the installed Linux operating system isn't conform. Install Mageia2 (see installation documentation)"
64
	echo "the installed Linux operating system isn't conform. Install Mageia2 (see installation documentation)"
65
	if [ -e /tmp/alcasar-conf.tar.gz ]
65
	if [ -e /tmp/alcasar-conf.tar.gz ]
66
		then
66
		then
67
		echo
67
		echo
68
		echo "La migration automatique du système ne peut pas être réalisée."
68
		echo "La migration automatique du système ne peut pas être réalisée."
69
		echo "Récupérez le fichier /tmp/alcasar-conf.tar.gz et faites une mise à jour manuelle (cf. readme.txt)."
69
		echo "Récupérez le fichier /tmp/alcasar-conf.tar.gz et faites une mise à jour manuelle (cf. readme.txt)."
70
		echo "The automatic system update can't perform."
70
		echo "The automatic system update can't perform."
71
		echo "Retrieve the file /tmp/alcasar-conf.tar.gz and do a manual update (see readme.txt)."
71
		echo "Retrieve the file /tmp/alcasar-conf.tar.gz and do a manual update (see readme.txt)."
72
	fi
72
	fi
73
	exit 1
73
	exit 1
74
fi
74
fi
75
# We prefer wget than curl
75
# We prefer wget than curl
76
urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
76
urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
77
# Set the RPM repository
77
# Set the RPM repository
78
MIRROR_NBR=2
78
MIRROR_NBR=2
79
#                       For Europeans 
79
#                       For Europeans 
80
MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
80
MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
81
#                       For International install
81
#                       For International install
82
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
82
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
83
try_nb="0"; nb_repository="0"
83
try_nb="0"; nb_repository="0"
84
while [ "$nb_repository" != "2" ]
84
while [ "$nb_repository" != "2" ]
85
do
85
do
86
	try_nb=`expr $try_nb + 1`
86
	try_nb=`expr $try_nb + 1`
87
	MIRRORLIST="MIRRORLIST$try_nb"
87
	MIRRORLIST="MIRRORLIST$try_nb"
88
	rpm_repository_sync 
88
	rpm_repository_sync 
89
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
89
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
90
	if [ "$nb_repository" != "2" ]
90
	if [ "$nb_repository" != "2" ]
91
	then
91
	then
92
		echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
92
		echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
93
		echo "An error occurs when synchronising the repositories N°$try_nb"
93
		echo "An error occurs when synchronising the repositories N°$try_nb"
94
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
94
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
95
		then
95
		then
96
			rpm_error
96
			rpm_error
97
			exit 1
97
			exit 1
98
		fi
98
		fi
99
		echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
99
		echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
100
		echo "Do you wan't to try a synchronisation with an other repository?"
100
		echo "Do you wan't to try a synchronisation with an other repository?"
101
		response=0
101
		response=0
102
		PTN='^[oOnNyY]$'
102
		PTN='^[oOnNyY]$'
103
		until [[ $(expr $response : $PTN) -gt 0 ]]
103
		until [[ $(expr $response : $PTN) -gt 0 ]]
104
		do
104
		do
105
			read response
105
			read response
106
		done
106
		done
107
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
107
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
108
		then
108
		then
109
			exit 1
109
			exit 1
110
		fi
110
		fi
111
	fi
111
	fi
112
done
112
done
113
# delete unused RPMs
113
# delete unused RPMs
114
echo "Cleaning the system : "
114
echo "Cleaning the system : "
115
for rm_rpm in shorewall mandi radeontool
115
for rm_rpm in shorewall mandi radeontool
116
do
116
do
117
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
117
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
118
	echo -n "."
118
	echo -n "."
119
done
119
done
120
echo
120
echo
121
# download RPM in cache 
121
# download RPM in cache 
122
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
122
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
123
echo "Updated RPM download. Please wait ..."
123
echo "Updated RPM download. Please wait ..."
124
echo "Il est temps d'aller prendre un café :-) "
124
echo "Il est temps d'aller prendre un café :-) "
125
echo "You should now take a Beer ;-) "
125
echo "You should now take a Beer ;-) "
126
urpmi --auto --auto-update --quiet --test --retry 2
126
urpmi --auto --auto-update --quiet --test --retry 2
127
if [ "$?" != "0" ]
127
if [ "$?" != "0" ]
128
then
128
then
129
	echo
129
	echo
130
	echo "Une erreur a été détectée lors de la récupération des paquetages."
130
	echo "Une erreur a été détectée lors de la récupération des paquetages."
131
	echo "An error occurs when downloading RPMS"
131
	echo "An error occurs when downloading RPMS"
132
	rpm_error
132
	rpm_error
133
	exit 1
133
	exit 1
134
fi
134
fi
135
# update with cached RPM
135
# update with cached RPM
136
urpmi --auto --auto-update
136
urpmi --auto --auto-update
137
if [ "$?" != "0" ]
137
if [ "$?" != "0" ]
138
then
138
then
139
	echo
139
	echo
140
	echo "Une erreur a été détectée lors de la mise à jour des paquetages."
140
	echo "Une erreur a été détectée lors de la mise à jour des paquetages."
141
	echo "An error occurs when updating packages"
141
	echo "An error occurs when updating packages"
142
	rpm_error
142
	rpm_error
143
	exit 1
143
	exit 1
144
fi
144
fi
145
# Clean the RPM cache
145
# Clean the RPM cache
146
urpmi --clean
146
urpmi --clean
147
# Download of ALCASAR specifics RPM in cache (and test)
147
# Download of ALCASAR specifics RPM in cache (and test)
148
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
148
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
149
echo "Download of complementary packages. Please wait ..."
149
echo "Download of complementary packages. Please wait ..."
150
urpmi --auto $PACKAGES --quiet --test --retry 2
150
urpmi --auto $PACKAGES --quiet --test --retry 2
151
if [ "$?" != "0" ]
151
if [ "$?" != "0" ]
152
then
152
then
153
	echo
153
	echo
154
	echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
154
	echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
155
	echo "An error occurs when downloading complementary packages"
155
	echo "An error occurs when downloading complementary packages"
156
	rpm_error
156
	rpm_error
157
	exit 1
157
	exit 1
158
fi
158
fi
159
# update with cached RPM
159
# update with cached RPM
160
urpmi --auto $PACKAGES 
160
urpmi --auto $PACKAGES 
161
if [ "$?" != "0" ]
161
if [ "$?" != "0" ]
162
then
162
then
163
	echo
163
	echo
164
	echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
164
	echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
165
	echo "An error occurs when installing complementary packages"
165
	echo "An error occurs when installing complementary packages"
166
	rpm_error
166
	rpm_error
167
	exit 1
167
	exit 1
168
fi
168
fi
169
# delete old alcasar RPMs and unused services
169
# delete old alcasar RPMs and unused services
170
for rm_rpm in c-icap-server lib64chilli0 libchilli0 python-coova-chilli cyrus-sasl mageia-gfxboot-theme
170
for rm_rpm in c-icap-server lib64chilli0 libchilli0 python-coova-chilli cyrus-sasl mageia-gfxboot-theme
171
do
171
do
172
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
172
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
173
done
173
done
174
# Save chilli launch script (erase with new rpm one)
174
# Save chilli launch script (erase with new rpm one)
175
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
175
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
176
# Install home made RPMs
176
# Install home made RPMs
177
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
177
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
178
# restore chilli launch script
178
# restore chilli launch script
179
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
179
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
180
# Clean the RPM cache
180
# Clean the RPM cache
181
urpmi --clean
181
urpmi --clean
182
exit 0
182
exit 0
183
 
183
 
184
 
184