Subversion Repositories ALCASAR

Rev

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

Rev 958 Rev 1007
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-rpm-download.sh 958 2012-07-19 09:01:30Z franck $
2
# $Id: alcasar-rpm-download.sh 1007 2013-01-05 15:14:32Z richard $
3
 
3
 
4
# alcasar-urpmi.sh
4
# alcasar-urpmi.sh
5
# by Franck BOUIJOUX and Richard REY
5
# by Franck BOUIJOUX and Richard REY
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
# récupération des RPM nécessaire dans un fichier tarball
8
# récupération des RPM nécessaire dans un fichier tarball
9
# retrieve needed RPM in a yarball file
9
# retrieve needed RPM in a tarball file
10
 
10
 
11
VERSION="2010.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="freeradius freeradius-mysql freeradius-ldap freeradius-web apache-mpm-prefork apache-mod_ssl apache-mod_php squid dansguardian postfix MySQL logwatch ntp awstats buffer vim-enhanced bind-utils arpscan ulogd openssh-server php-xml php-ldap pam_ccreds rng-utils lsb-release dnsmasq sudo syslinux rsync cronie-anacron pciutils clamav pm-fallback-policy "
14
PACKAGES="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
urpmi.addmedia --probe-synthesis --mirrorlist ${!MIRRORLIST} main /media/main/release
-
 
24
urpmi.addmedia --update --probe-synthesis --mirrorlist ${!MIRRORLIST} main_updates /media/main/updates
-
 
25
urpmi.addmedia --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib /media/contrib/release
23
urpmi.addmedia --probe-synthesis --mirrorlist ${!MIRRORLIST} core /media/core/release
26
urpmi.addmedia --update --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib_updates /media/contrib/updates
24
urpmi.addmedia --update --probe-synthesis --mirrorlist ${!MIRRORLIST} core_updates /media/core/updates
27
}
25
}
28
 
26
 
29
rpm_error ()
27
rpm_error ()
30
{
28
{
31
echo
29
echo
32
echo "Relancez l'installation ultérieurement."
30
echo "Relancez l'installation ultérieurement."
33
echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
31
echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
34
echo "Try an other install later."
32
echo "Try an other install later."
35
echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
33
echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
36
}
34
}
37
 
35
 
38
# extract the current architecture (i586 ou X64)
36
# extract the current architecture (i586 ou X64)
39
fic=`cat /etc/product.id`
37
fic=`cat /etc/product.id`
40
old="$IFS"
38
old="$IFS"
41
IFS=","
39
IFS=","
42
set $fic
40
set $fic
43
for i in $*
41
for i in $*
44
do
42
do
45
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
43
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
46
	then 
44
	then 
47
		ARCH=`echo $i|cut -d"=" -f2`
45
		ARCH=`echo $i|cut -d"=" -f2`
48
	fi
46
	fi
49
done
47
done
50
IFS="$old"
48
IFS="$old"
51
# We prefer wget than curl
49
# We prefer wget than curl
52
urpmi --no-verify-rpm --auto ../../conf/rpms/$ARCH/wget*.rpm
50
urpmi --no-verify-rpm --auto ../../conf/rpms/$ARCH/wget*.rpm
53
# Set the RPM repository
51
# Set the RPM repository
54
MIRROR_NBR=2
52
MIRROR_NBR=2
55
#                       For french ALCASARistes
53
#                       For french ALCASARistes
56
MIRRORLIST1="http://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/official/$VERSION/$ARCH"
54
MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
57
#                       For International install
55
#                       For International install
58
MIRRORLIST2="http://api.mandriva.com/mirrors/basic.$VERSION.$ARCH.list"
56
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
59
try_nb="0"; nb_repository="0"
57
try_nb="0"; nb_repository="0"
60
while [ "$nb_repository" != "4" ]
58
while [ "$nb_repository" != "4" ]
61
do
59
do
62
	try_nb=`expr $try_nb + 1`
60
	try_nb=`expr $try_nb + 1`
63
	MIRRORLIST="MIRRORLIST$try_nb"
61
	MIRRORLIST="MIRRORLIST$try_nb"
64
	rpm_repository_sync 
62
	rpm_repository_sync 
65
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
63
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
66
	if [ "$nb_repository" != "4" ]
64
	if [ "$nb_repository" != "4" ]
67
	then
65
	then
68
		echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
66
		echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
69
		echo "An error occurs when synchronising the repositories N°$try_nb"
67
		echo "An error occurs when synchronising the repositories N°$try_nb"
70
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
68
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
71
		then
69
		then
72
			rpm_error
70
			rpm_error
73
			exit 1
71
			exit 1
74
		fi
72
		fi
75
		echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
73
		echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
76
		echo "Do you wan't to try a synchronisation with an other repository?"
74
		echo "Do you wan't to try a synchronisation with an other repository?"
77
		response=0
75
		response=0
78
		PTN='^[oOnNyY]$'
76
		PTN='^[oOnNyY]$'
79
		until [[ $(expr $response : $PTN) -gt 0 ]]
77
		until [[ $(expr $response : $PTN) -gt 0 ]]
80
		do
78
		do
81
			read response
79
			read response
82
		done
80
		done
83
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
81
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
84
		then
82
		then
85
			exit 1
83
			exit 1
86
		fi
84
		fi
87
	fi
85
	fi
88
done
86
done
89
# delete unused RPMs
87
# delete unused RPMs
90
echo "Cleaning the system : "
88
echo "Cleaning the system : "
91
for rm_rpm in shorewall dhcp-server cyrus-sasl distcache-server avahi mandi radeontool mondo mindi
89
for rm_rpm in shorewall dhcp-server cyrus-sasl distcache-server avahi mandi radeontool mondo mindi
92
do
90
do
93
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
91
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
94
	echo -n "."
92
	echo -n "."
95
done
93
done
96
urpmi --clean
94
urpmi --clean
97
# download RPM in cache 
95
# download RPM in cache 
98
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
96
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
99
echo "Updated RPM download. Please wait ..."
97
echo "Updated RPM download. Please wait ..."
100
echo "Il est temps d'aller prendre un café :-) "
98
echo "Il est temps d'aller prendre un café :-) "
101
echo "You should now take a Beer ;-) "
99
echo "You should now take a Beer ;-) "
102
urpmi --auto --auto-update --quiet --test --retry 2
100
urpmi --auto --auto-update --quiet --test --retry 2
103
if [ "$?" != "0" ]
101
if [ "$?" != "0" ]
104
then
102
then
105
	echo
103
	echo
106
	echo "Une erreur a été détectée lors de la récupération des paquetages."
104
	echo "Une erreur a été détectée lors de la récupération des paquetages."
107
	echo "An error occurs when downloading RPMS"
105
	echo "An error occurs when downloading RPMS"
108
	rpm_error
106
	rpm_error
109
	exit 1
107
	exit 1
110
fi
108
fi
111
# update with cached RPM
109
# update with cached RPM
112
urpmi --auto --auto-update --noclean
110
urpmi --auto --auto-update --noclean
113
if [ "$?" != "0" ]
111
if [ "$?" != "0" ]
114
then
112
then
115
	echo
113
	echo
116
	echo "Une erreur a été détectée lors de la mise à jour des paquetages."
114
	echo "Une erreur a été détectée lors de la mise à jour des paquetages."
117
	echo "An error occurs when updating packages"
115
	echo "An error occurs when updating packages"
118
	rpm_error
116
	rpm_error
119
	exit 1
117
	exit 1
120
fi
118
fi
121
 
119
 
122
# Download of ALCASAR specifics RPM in cache (and test)
120
# Download of ALCASAR specifics RPM in cache (and test)
123
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
121
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
124
echo "Download of complementary packages. Please wait ..."
122
echo "Download of complementary packages. Please wait ..."
125
urpmi --auto $PACKAGES --quiet --test --retry 2
123
urpmi --auto $PACKAGES --quiet --test --retry 2
126
if [ "$?" != "0" ]
124
if [ "$?" != "0" ]
127
then
125
then
128
	echo
126
	echo
129
	echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
127
	echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
130
	echo "An error occurs when downloading complementary packages"
128
	echo "An error occurs when downloading complementary packages"
131
	rpm_error
129
	rpm_error
132
	exit 1
130
	exit 1
133
fi
131
fi
134
echo "archive creation. Please wait..."
132
echo "archive creation. Please wait..."
135
cd /var/cache/urpmi
133
cd /var/cache/urpmi
136
tar -czf rpms-$ARCH.tar.gz rpms/
134
tar -czf rpms-$ARCH.tar.gz rpms/
137
# Clean the RPM cache
135
# Clean the RPM cache
138
urpmi --clean
136
urpmi --clean
139
mv rpms-$ARCH.tar.gz /root/
137
mv rpms-$ARCH.tar.gz /root/
140
cd
138
cd
141
echo "Your RPM archive : rpms-$ARCH.tar.gz"
139
echo "Your RPM archive : rpms-$ARCH.tar.gz"
142
exit 0
140
exit 0
143
 
141
 
144
 
142