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