Rev 2236 | Rev 2478 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log
Rev | Author | Line No. | Line |
---|---|---|---|
941 | richard | 1 | #!/bin/bash |
958 | franck | 2 | # $Id: alcasar-rpm-download.sh 2454 2017-12-09 18:59:31Z tom.houdayer $ |
933 | franck | 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 | |||
2109 | richard | 8 | # récupération des RPM nécessaires dans un fichier tarball |
1007 | richard | 9 | # retrieve needed RPM in a tarball file |
933 | franck | 10 | |
1953 | richard | 11 | VERSION="5" |
2454 | tom.houday | 12 | ARCH="x86_64" |
933 | franck | 13 | # ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ****** |
2236 | tom.houday | 14 | PACKAGES="arp-scan vim-enhanced freeradius freeradius-mysql freeradius-ldap apache apache-mod_ssl apache-mod_php dansguardian postfix mariadb ntp bind-utils openssh-server php-xml php-ldap php-mysqli php-mbstring php-sockets php-cli php-curl php-pdo_sqlite php-json rng-utils rsync clamav perl-rrdtool perl-MailTools perl-Socket6 fail2ban gnupg ulogd pm-fallback-policy ipset cronie-anacron gammu usbutils locales-en usb_modeswitch tinyproxy vnstat php-gd sudo iftop man kernel-firmware-nonfree dos2unix p7zip bc msec kernel-userspace-headers" |
933 | franck | 15 | |
16 | rpm_repository_sync () |
||
17 | { |
||
18 | cat <<EOF > /etc/urpmi/urpmi.cfg |
||
19 | { |
||
20 | downloader: wget |
||
21 | } |
||
22 | EOF |
||
1985 | richard | 23 | urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release |
24 | urpmi.addmedia core-updates --update --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/updates |
||
25 | urpmi.addmedia nonfree --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/nonfree/release |
||
26 | urpmi.addmedia nonfree-updates --update --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/nonfree/updates |
||
933 | franck | 27 | } |
28 | |||
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 | } |
||
37 | |||
941 | richard | 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" ] |
||
2454 | tom.houday | 46 | then |
941 | richard | 47 | ARCH=`echo $i|cut -d"=" -f2` |
48 | fi |
||
49 | done |
||
50 | IFS="$old" |
||
933 | franck | 51 | # We prefer wget than curl |
1767 | richard | 52 | wget_exist=`rpm -qa|grep wget|wc -l` |
53 | if [ "$wget_exist" -eq "0" ] |
||
54 | then |
||
55 | urpmi --no-verify-rpm --auto ../../conf/rpms/$ARCH/wget*.rpm |
||
56 | fi |
||
941 | richard | 57 | # Set the RPM repository |
58 | MIRROR_NBR=2 |
||
59 | # For french ALCASARistes |
||
1007 | richard | 60 | MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH" |
941 | richard | 61 | # For International install |
1007 | richard | 62 | MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list" |
941 | richard | 63 | try_nb="0"; nb_repository="0" |
1985 | richard | 64 | while [ "$nb_repository" != "4" ] |
941 | richard | 65 | do |
66 | try_nb=`expr $try_nb + 1` |
||
67 | MIRRORLIST="MIRRORLIST$try_nb" |
||
2454 | tom.houday | 68 | rpm_repository_sync |
941 | richard | 69 | nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l` |
1985 | richard | 70 | if [ "$nb_repository" != "4" ] |
941 | richard | 71 | then |
72 | echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb." |
||
73 | echo "An error occurs when synchronising the repositories N°$try_nb" |
||
74 | if [ $(expr $try_nb) -eq $MIRROR_NBR ] |
||
75 | then |
||
76 | rpm_error |
||
77 | exit 1 |
||
78 | fi |
||
79 | echo "Voulez-vous tenter une synchronisation avec un autre dépôt?" |
||
80 | echo "Do you wan't to try a synchronisation with an other repository?" |
||
81 | response=0 |
||
82 | PTN='^[oOnNyY]$' |
||
83 | until [[ $(expr $response : $PTN) -gt 0 ]] |
||
84 | do |
||
85 | read response |
||
86 | done |
||
2454 | tom.houday | 87 | if [ "$response" = "n" ] || [ "$response" = "N" ] |
941 | richard | 88 | then |
89 | exit 1 |
||
90 | fi |
||
91 | fi |
||
92 | done |
||
93 | # delete unused RPMs |
||
94 | echo "Cleaning the system : " |
||
95 | for rm_rpm in shorewall dhcp-server cyrus-sasl distcache-server avahi mandi radeontool mondo mindi |
||
96 | do |
||
97 | /usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null |
||
98 | echo -n "." |
||
99 | done |
||
100 | urpmi --clean |
||
2454 | tom.houday | 101 | # download RPM in cache |
941 | richard | 102 | echo "Récupération des paquetages de mise à jour. Veuillez patienter ..." |
103 | echo "Updated RPM download. Please wait ..." |
||
104 | echo "Il est temps d'aller prendre un café :-) " |
||
105 | echo "You should now take a Beer ;-) " |
||
106 | urpmi --auto --auto-update --quiet --test --retry 2 |
||
107 | if [ "$?" != "0" ] |
||
108 | then |
||
109 | echo |
||
110 | echo "Une erreur a été détectée lors de la récupération des paquetages." |
||
111 | echo "An error occurs when downloading RPMS" |
||
112 | rpm_error |
||
113 | exit 1 |
||
114 | fi |
||
115 | # update with cached RPM |
||
116 | urpmi --auto --auto-update --noclean |
||
117 | if [ "$?" != "0" ] |
||
118 | then |
||
119 | echo |
||
120 | echo "Une erreur a été détectée lors de la mise à jour des paquetages." |
||
121 | echo "An error occurs when updating packages" |
||
122 | rpm_error |
||
123 | exit 1 |
||
124 | fi |
||
933 | franck | 125 | |
941 | richard | 126 | # Download of ALCASAR specifics RPM in cache (and test) |
127 | echo "Récupération des paquetages complémentaires. Veuillez patienter ..." |
||
128 | echo "Download of complementary packages. Please wait ..." |
||
129 | urpmi --auto $PACKAGES --quiet --test --retry 2 |
||
130 | if [ "$?" != "0" ] |
||
131 | then |
||
132 | echo |
||
133 | echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires." |
||
134 | echo "An error occurs when downloading complementary packages" |
||
135 | rpm_error |
||
136 | exit 1 |
||
137 | fi |
||
138 | echo "archive creation. Please wait..." |
||
139 | cd /var/cache/urpmi |
||
140 | tar -czf rpms-$ARCH.tar.gz rpms/ |
||
933 | franck | 141 | # Clean the RPM cache |
142 | urpmi --clean |
||
941 | richard | 143 | mv rpms-$ARCH.tar.gz /root/ |
144 | cd |
||
1012 | richard | 145 | echo "Your RPM archive file is /root/rpms-$ARCH.tar.gz" |
933 | franck | 146 | exit 0 |
147 |