Subversion Repositories ALCASAR

Rev

Rev 933 | Rev 958 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 933 Rev 941
Line 1... Line 1...
1
#!/bin/sh
1
#!/bin/bash
2
# $Id: alcasar-urpmi.sh 838 2012-03-14 22:56:41Z richard $
2
# $Id: alcasar-rpm-dowwload.sh 922 2012-07-02 22:37:19Z 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
# script de mise en place des dépots RPM 
8
# récupération des RPM nécessaire dans un fichier tarball
9
# configure the RPM repository
9
# retrieve needed RPM in a yarball file
10
 
10
 
11
VERSION="2010.2"
11
VERSION="2010.2"
12
TO_ARCH="i586 x86_64" 
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 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 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 "
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
{
Line 33... Line 33...
33
echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
33
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."
34
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'"
35
echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
36
}
36
}
37
 
37
 
-
 
38
# extract the current architecture (i586 ou X64)
-
 
39
fic=`cat /etc/product.id`
-
 
40
old="$IFS"
-
 
41
IFS=","
-
 
42
set $fic
-
 
43
for i in $*
-
 
44
do
-
 
45
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
-
 
46
	then 
-
 
47
		ARCH=`echo $i|cut -d"=" -f2`
-
 
48
	fi
-
 
49
done
-
 
50
IFS="$old"
38
# We prefer wget than curl
51
# We prefer wget than curl
39
urpmi --no-verify-rpm --auto wget
52
urpmi --no-verify-rpm --auto ../../conf/rpms/$ARCH/wget*.rpm
40
 
-
 
41
# Clean the RPM cache
53
# Set the RPM repository
42
urpmi --clean
54
MIRROR_NBR=2
43
 
-
 
-
 
55
#                       For french ALCASARistes
-
 
56
MIRRORLIST1="http://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/official/$VERSION/$ARCH"
-
 
57
#                       For International install
-
 
58
MIRRORLIST2="http://api.mandriva.com/mirrors/basic.$VERSION.$ARCH.list"
-
 
59
try_nb="0"; nb_repository="0"
44
for ARCH in $TO_ARCH
60
while [ "$nb_repository" != "4" ]
45
do
61
do
46
    # Set the RPM repository
-
 
47
    MIRROR_NBR=2
-
 
48
    #                       For french ALCASARistes
-
 
49
    MIRRORLIST1="http://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/official/$VERSION/$ARCH"
-
 
50
    #                       For International install
-
 
51
    MIRRORLIST2="http://api.mandriva.com/mirrors/basic.$VERSION.$ARCH.list"
-
 
52
    try_nb="0"; nb_repository="0"
-
 
53
    while [ "$nb_repository" != "4" ]
-
 
54
    do
-
 
55
	    try_nb=`expr $try_nb + 1`
62
	try_nb=`expr $try_nb + 1`
56
	    MIRRORLIST="MIRRORLIST$try_nb"
63
	MIRRORLIST="MIRRORLIST$try_nb"
57
	    rpm_repository_sync 
64
	rpm_repository_sync 
58
	    nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
65
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
59
	    if [ "$nb_repository" != "4" ]
66
	if [ "$nb_repository" != "4" ]
60
	    then
67
	then
61
		    echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
68
		echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
62
		    echo "An error occurs when synchronising the repositories N°$try_nb"
69
		echo "An error occurs when synchronising the repositories N°$try_nb"
63
		    if [ $(expr $try_nb) -eq $MIRROR_NBR ]
70
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
64
		    then
71
		then
65
			    rpm_error
72
			rpm_error
66
			    exit 1
73
			exit 1
67
		    fi
74
		fi
68
		    echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
75
		echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
69
		    echo "Do you wan't to try a synchronisation with an other repository?"
76
		echo "Do you wan't to try a synchronisation with an other repository?"
70
		    response=0
77
		response=0
71
		    PTN='^[oOnNyY]$'
78
		PTN='^[oOnNyY]$'
72
		    until [[ $(expr $response : $PTN) -gt 0 ]]
79
		until [[ $(expr $response : $PTN) -gt 0 ]]
73
		    do
80
		do
74
			    read response
81
			read response
75
		    done
82
		done
76
		    if [ "$response" = "n" ] || [ "$response" = "N" ] 
83
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
77
		    then
84
		then
78
			    exit 1
85
			exit 1
79
		    fi
86
		fi
80
	    fi
87
	fi
81
    done
-
 
82
    
-
 
83
    urpmi --auto --auto-update --quiet --test --retry 2 --download-all /tmp/$ARCH 
-
 
84
  
-
 
85
    if [ "$?" != "0" ]
-
 
86
    then
-
 
87
	    echo
-
 
88
	    echo "Une erreur a été détectée lors de la récupération des paquetages."
-
 
89
	    echo "An error occurs when downloading RPMS"
-
 
90
	    rpm_error
-
 
91
	    exit 1
-
 
92
    fi
-
 
93
  
-
 
94
done
88
done
-
 
89
# delete unused RPMs
-
 
90
echo "Cleaning the system : "
-
 
91
for rm_rpm in shorewall dhcp-server cyrus-sasl distcache-server avahi mandi radeontool mondo mindi
-
 
92
do
-
 
93
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
-
 
94
	echo -n "."
-
 
95
done
-
 
96
urpmi --clean
-
 
97
# download RPM in cache 
-
 
98
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
-
 
99
echo "Updated RPM download. Please wait ..."
-
 
100
echo "Il est temps d'aller prendre un café :-) "
-
 
101
echo "You should now take a Beer ;-) "
-
 
102
urpmi --auto --auto-update --quiet --test --retry 2
-
 
103
if [ "$?" != "0" ]
-
 
104
then
-
 
105
	echo
-
 
106
	echo "Une erreur a été détectée lors de la récupération des paquetages."
-
 
107
	echo "An error occurs when downloading RPMS"
-
 
108
	rpm_error
-
 
109
	exit 1
-
 
110
fi
-
 
111
# update with cached RPM
-
 
112
urpmi --auto --auto-update --noclean
-
 
113
if [ "$?" != "0" ]
-
 
114
then
-
 
115
	echo
-
 
116
	echo "Une erreur a été détectée lors de la mise à jour des paquetages."
-
 
117
	echo "An error occurs when updating packages"
-
 
118
	rpm_error
-
 
119
	exit 1
-
 
120
fi
-
 
121
 
-
 
122
# Download of ALCASAR specifics RPM in cache (and test)
-
 
123
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
-
 
124
echo "Download of complementary packages. Please wait ..."
-
 
125
urpmi --auto $PACKAGES --quiet --test --retry 2
-
 
126
if [ "$?" != "0" ]
-
 
127
then
-
 
128
	echo
-
 
129
	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"
-
 
131
	rpm_error
-
 
132
	exit 1
-
 
133
fi
-
 
134
echo "archive creation. Please wait..."
-
 
135
cd /var/cache/urpmi
-
 
136
tar -czf rpms-$ARCH.tar.gz rpms/
-
 
137
# Clean the RPM cache
-
 
138
urpmi --clean
-
 
139
mv rpms-$ARCH.tar.gz /root/
95
  
140
cd
-
 
141
echo "Your RPM archive : rpms-$ARCH.tar.gz"
96
exit 0
142
exit 0
97
 
143