872 |
richard |
1 |
#!/bin/bash
|
230 |
franck |
2 |
# $Id: alcasar-urpmi.sh 958 2012-07-19 09:01:30Z franck $
|
672 |
richard |
3 |
|
|
|
4 |
# alcasar-urpmi.sh
|
|
|
5 |
# by Franck BOUIJOUX and Richard REY
|
|
|
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 |
|
476 |
richard |
11 |
VERSION="2010.2"
|
525 |
richard |
12 |
ARCH="i586"
|
532 |
richard |
13 |
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
|
922 |
richard |
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 "
|
497 |
richard |
15 |
|
|
|
16 |
rpm_repository_sync ()
|
|
|
17 |
{
|
835 |
richard |
18 |
cat <<EOF > /etc/urpmi/urpmi.cfg
|
|
|
19 |
{
|
|
|
20 |
downloader: wget
|
497 |
richard |
21 |
}
|
835 |
richard |
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
|
|
|
26 |
urpmi.addmedia --update --probe-synthesis --mirrorlist ${!MIRRORLIST} contrib_updates /media/contrib/updates
|
|
|
27 |
}
|
497 |
richard |
28 |
|
532 |
richard |
29 |
rpm_error ()
|
|
|
30 |
{
|
|
|
31 |
echo
|
|
|
32 |
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'"
|
|
|
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'"
|
|
|
36 |
}
|
460 |
richard |
37 |
# extract the current Mandriva version and hardware architecture (i586 ou X64)
|
230 |
franck |
38 |
fic=`cat /etc/product.id`
|
457 |
richard |
39 |
old="$IFS"
|
|
|
40 |
IFS=","
|
230 |
franck |
41 |
set $fic
|
|
|
42 |
for i in $*
|
|
|
43 |
do
|
|
|
44 |
if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
|
|
|
45 |
then
|
457 |
richard |
46 |
CURRENT_VERSION=`echo $i|cut -d"=" -f2`
|
|
|
47 |
if [ $CURRENT_VERSION != "2009.0" ] && [ $CURRENT_VERSION != "2009.1" ] && [ $CURRENT_VERSION != "2010.0" ] && [ $CURRENT_VERSION != "2010.1" ] && [ $CURRENT_VERSION != "2010.2" ]
|
230 |
franck |
48 |
then
|
457 |
richard |
49 |
echo "La migration automatique du système ne peut être réalisée."
|
|
|
50 |
echo "Réalisez une mise à jour manuelle (cf. doc)."
|
460 |
richard |
51 |
echo "The automatic system update can't perform."
|
|
|
52 |
echo "Do a manual update (see doc)."
|
456 |
franck |
53 |
exit 1
|
230 |
franck |
54 |
fi
|
|
|
55 |
fi
|
456 |
franck |
56 |
if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
|
|
|
57 |
then
|
|
|
58 |
ARCH=`echo $i|cut -d"=" -f2`
|
|
|
59 |
fi
|
230 |
franck |
60 |
done
|
457 |
richard |
61 |
IFS="$old"
|
532 |
richard |
62 |
# We prefer wget than curl
|
582 |
richard |
63 |
urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
|
497 |
richard |
64 |
# Set the RPM repository
|
525 |
richard |
65 |
MIRROR_NBR=2
|
|
|
66 |
# For french ALCASARistes
|
806 |
richard |
67 |
MIRRORLIST1="http://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/official/$VERSION/$ARCH"
|
525 |
richard |
68 |
# For International install
|
806 |
richard |
69 |
MIRRORLIST2="http://api.mandriva.com/mirrors/basic.$VERSION.$ARCH.list"
|
497 |
richard |
70 |
try_nb="0"; nb_repository="0"
|
|
|
71 |
while [ "$nb_repository" != "4" ]
|
|
|
72 |
do
|
|
|
73 |
try_nb=`expr $try_nb + 1`
|
|
|
74 |
MIRRORLIST="MIRRORLIST$try_nb"
|
|
|
75 |
rpm_repository_sync
|
|
|
76 |
nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
|
|
|
77 |
if [ "$nb_repository" != "4" ]
|
|
|
78 |
then
|
|
|
79 |
echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
|
|
|
80 |
echo "An error occurs when synchronising the repositories N°$try_nb"
|
|
|
81 |
if [ $(expr $try_nb) -eq $MIRROR_NBR ]
|
|
|
82 |
then
|
532 |
richard |
83 |
rpm_error
|
497 |
richard |
84 |
exit 1
|
|
|
85 |
fi
|
|
|
86 |
echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
|
|
|
87 |
echo "Do you wan't to try a synchronisation with an other repository?"
|
|
|
88 |
response=0
|
|
|
89 |
PTN='^[oOnNyY]$'
|
|
|
90 |
until [[ $(expr $response : $PTN) -gt 0 ]]
|
|
|
91 |
do
|
|
|
92 |
read response
|
|
|
93 |
done
|
|
|
94 |
if [ "$response" = "n" ] || [ "$response" = "N" ]
|
|
|
95 |
then
|
|
|
96 |
exit 1
|
|
|
97 |
fi
|
|
|
98 |
fi
|
|
|
99 |
done
|
772 |
richard |
100 |
# delete unused RPMs
|
|
|
101 |
echo "Cleaning the system : "
|
806 |
richard |
102 |
for rm_rpm in shorewall dhcp-server cyrus-sasl distcache-server avahi mandi radeontool mondo mindi
|
772 |
richard |
103 |
do
|
|
|
104 |
/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
|
|
|
105 |
echo -n "."
|
|
|
106 |
done
|
|
|
107 |
echo
|
497 |
richard |
108 |
# download RPM in cache
|
460 |
richard |
109 |
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
|
|
|
110 |
echo "Updated RPM download. Please wait ..."
|
461 |
richard |
111 |
echo "Il est temps d'aller prendre un café :-) "
|
|
|
112 |
echo "You should now take a Beer ;-) "
|
835 |
richard |
113 |
urpmi --auto --auto-update --quiet --test --retry 2
|
460 |
richard |
114 |
if [ "$?" != "0" ]
|
|
|
115 |
then
|
|
|
116 |
echo
|
470 |
richard |
117 |
echo "Une erreur a été détectée lors de la récupération des paquetages."
|
799 |
richard |
118 |
echo "An error occurs when downloading RPMS"
|
532 |
richard |
119 |
rpm_error
|
470 |
richard |
120 |
exit 1
|
460 |
richard |
121 |
fi
|
|
|
122 |
# update with cached RPM
|
|
|
123 |
urpmi --auto --auto-update
|
799 |
richard |
124 |
if [ "$?" != "0" ]
|
|
|
125 |
then
|
|
|
126 |
echo
|
|
|
127 |
echo "Une erreur a été détectée lors de la mise à jour des paquetages."
|
|
|
128 |
echo "An error occurs when updating packages"
|
|
|
129 |
rpm_error
|
|
|
130 |
exit 1
|
|
|
131 |
fi
|
772 |
richard |
132 |
# Clean the RPM cache
|
|
|
133 |
urpmi --clean
|
532 |
richard |
134 |
# Download of ALCASAR specifics RPM in cache (and test)
|
|
|
135 |
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
|
|
|
136 |
echo "Download of complementary packages. Please wait ..."
|
835 |
richard |
137 |
urpmi --auto $PACKAGES --quiet --test --retry 2
|
532 |
richard |
138 |
if [ "$?" != "0" ]
|
|
|
139 |
then
|
|
|
140 |
echo
|
|
|
141 |
echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
|
|
|
142 |
echo "An error occurs when downloading complementary packages"
|
|
|
143 |
rpm_error
|
|
|
144 |
exit 1
|
|
|
145 |
fi
|
|
|
146 |
# update with cached RPM
|
|
|
147 |
urpmi --auto $PACKAGES
|
799 |
richard |
148 |
if [ "$?" != "0" ]
|
|
|
149 |
then
|
|
|
150 |
echo
|
|
|
151 |
echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
|
|
|
152 |
echo "An error occurs when installing complementary packages"
|
|
|
153 |
rpm_error
|
|
|
154 |
exit 1
|
|
|
155 |
fi
|
772 |
richard |
156 |
# delete old alcasar RPMs
|
|
|
157 |
for rm_rpm in c-icap-server lib64chilli0 libchilli0 python-coova-chilli
|
532 |
richard |
158 |
do
|
|
|
159 |
/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
|
|
|
160 |
done
|
|
|
161 |
# On installe les RPMs spécifiques à la version
|
|
|
162 |
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
|
|
|
163 |
# On empêche les mises à jour de coova-chilli et freeradius par le biais des dépôts
|
638 |
richard |
164 |
for rpmskip in coova-chilli freeradius
|
532 |
richard |
165 |
do
|
|
|
166 |
echo -n "/^$rpmskip/" >> /etc/urpmi/skip.list
|
|
|
167 |
done
|
|
|
168 |
# Clean the RPM cache
|
|
|
169 |
urpmi --clean
|
230 |
franck |
170 |
exit 0
|
|
|
171 |
|