941 |
richard |
1 |
#!/bin/bash
|
958 |
franck |
2 |
# $Id: alcasar-rpm-download.sh 2486 2018-02-14 18:50:37Z 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 |
|
2478 |
richard |
11 |
VERSION="6"
|
2454 |
tom.houday |
12 |
ARCH="x86_64"
|
2478 |
richard |
13 |
# The kernel version we compile netflow for
|
2486 |
tom.houday |
14 |
KERNEL="kernel-server-4.14.18-1.mga6-1-1.mga6"
|
933 |
franck |
15 |
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
|
2478 |
richard |
16 |
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 dos2unix p7zip bc msec kernel-userspace-headers dnsmasq netcat-traditional"
|
933 |
franck |
17 |
|
|
|
18 |
rpm_repository_sync ()
|
|
|
19 |
{
|
|
|
20 |
cat <<EOF > /etc/urpmi/urpmi.cfg
|
|
|
21 |
{
|
|
|
22 |
downloader: wget
|
|
|
23 |
}
|
|
|
24 |
EOF
|
1985 |
richard |
25 |
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
|
|
|
26 |
urpmi.addmedia core-updates --update --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/updates
|
|
|
27 |
urpmi.addmedia nonfree --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/nonfree/release
|
|
|
28 |
urpmi.addmedia nonfree-updates --update --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/nonfree/updates
|
933 |
franck |
29 |
}
|
|
|
30 |
|
|
|
31 |
rpm_error ()
|
|
|
32 |
{
|
|
|
33 |
echo
|
|
|
34 |
echo "Relancez l'installation ultérieurement."
|
|
|
35 |
echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
|
|
|
36 |
echo "Try an other install later."
|
|
|
37 |
echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
|
|
|
38 |
}
|
|
|
39 |
|
941 |
richard |
40 |
# extract the current architecture (i586 ou X64)
|
|
|
41 |
fic=`cat /etc/product.id`
|
|
|
42 |
old="$IFS"
|
|
|
43 |
IFS=","
|
|
|
44 |
set $fic
|
|
|
45 |
for i in $*
|
|
|
46 |
do
|
|
|
47 |
if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
|
2454 |
tom.houday |
48 |
then
|
941 |
richard |
49 |
ARCH=`echo $i|cut -d"=" -f2`
|
|
|
50 |
fi
|
|
|
51 |
done
|
|
|
52 |
IFS="$old"
|
933 |
franck |
53 |
# We prefer wget than curl
|
1767 |
richard |
54 |
wget_exist=`rpm -qa|grep wget|wc -l`
|
|
|
55 |
if [ "$wget_exist" -eq "0" ]
|
|
|
56 |
then
|
|
|
57 |
urpmi --no-verify-rpm --auto ../../conf/rpms/$ARCH/wget*.rpm
|
|
|
58 |
fi
|
941 |
richard |
59 |
# Set the RPM repository
|
|
|
60 |
MIRROR_NBR=2
|
|
|
61 |
# For french ALCASARistes
|
1007 |
richard |
62 |
MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
|
941 |
richard |
63 |
# For International install
|
1007 |
richard |
64 |
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
|
941 |
richard |
65 |
try_nb="0"; nb_repository="0"
|
1985 |
richard |
66 |
while [ "$nb_repository" != "4" ]
|
941 |
richard |
67 |
do
|
|
|
68 |
try_nb=`expr $try_nb + 1`
|
|
|
69 |
MIRRORLIST="MIRRORLIST$try_nb"
|
2454 |
tom.houday |
70 |
rpm_repository_sync
|
941 |
richard |
71 |
nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
|
1985 |
richard |
72 |
if [ "$nb_repository" != "4" ]
|
941 |
richard |
73 |
then
|
|
|
74 |
echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
|
|
|
75 |
echo "An error occurs when synchronising the repositories N°$try_nb"
|
|
|
76 |
if [ $(expr $try_nb) -eq $MIRROR_NBR ]
|
|
|
77 |
then
|
|
|
78 |
rpm_error
|
|
|
79 |
exit 1
|
|
|
80 |
fi
|
|
|
81 |
echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
|
|
|
82 |
echo "Do you wan't to try a synchronisation with an other repository?"
|
|
|
83 |
response=0
|
|
|
84 |
PTN='^[oOnNyY]$'
|
|
|
85 |
until [[ $(expr $response : $PTN) -gt 0 ]]
|
|
|
86 |
do
|
|
|
87 |
read response
|
|
|
88 |
done
|
2454 |
tom.houday |
89 |
if [ "$response" = "n" ] || [ "$response" = "N" ]
|
941 |
richard |
90 |
then
|
|
|
91 |
exit 1
|
|
|
92 |
fi
|
|
|
93 |
fi
|
|
|
94 |
done
|
|
|
95 |
# delete unused RPMs
|
|
|
96 |
echo "Cleaning the system : "
|
|
|
97 |
for rm_rpm in shorewall dhcp-server cyrus-sasl distcache-server avahi mandi radeontool mondo mindi
|
|
|
98 |
do
|
|
|
99 |
/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
|
|
|
100 |
echo -n "."
|
|
|
101 |
done
|
|
|
102 |
urpmi --clean
|
2454 |
tom.houday |
103 |
# download RPM in cache
|
941 |
richard |
104 |
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
|
|
|
105 |
echo "Updated RPM download. Please wait ..."
|
|
|
106 |
echo "Il est temps d'aller prendre un café :-) "
|
|
|
107 |
echo "You should now take a Beer ;-) "
|
|
|
108 |
urpmi --auto --auto-update --quiet --test --retry 2
|
|
|
109 |
if [ "$?" != "0" ]
|
|
|
110 |
then
|
|
|
111 |
echo
|
|
|
112 |
echo "Une erreur a été détectée lors de la récupération des paquetages."
|
|
|
113 |
echo "An error occurs when downloading RPMS"
|
|
|
114 |
rpm_error
|
|
|
115 |
exit 1
|
|
|
116 |
fi
|
|
|
117 |
# update with cached RPM
|
|
|
118 |
urpmi --auto --auto-update --noclean
|
|
|
119 |
if [ "$?" != "0" ]
|
|
|
120 |
then
|
|
|
121 |
echo
|
|
|
122 |
echo "Une erreur a été détectée lors de la mise à jour des paquetages."
|
|
|
123 |
echo "An error occurs when updating packages"
|
|
|
124 |
rpm_error
|
|
|
125 |
exit 1
|
|
|
126 |
fi
|
933 |
franck |
127 |
|
941 |
richard |
128 |
# Download of ALCASAR specifics RPM in cache (and test)
|
|
|
129 |
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
|
|
|
130 |
echo "Download of complementary packages. Please wait ..."
|
2478 |
richard |
131 |
urpmi --auto $KERNEL --quiet --test --retry 2
|
941 |
richard |
132 |
urpmi --auto $PACKAGES --quiet --test --retry 2
|
|
|
133 |
if [ "$?" != "0" ]
|
|
|
134 |
then
|
|
|
135 |
echo
|
|
|
136 |
echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
|
|
|
137 |
echo "An error occurs when downloading complementary packages"
|
|
|
138 |
rpm_error
|
|
|
139 |
exit 1
|
|
|
140 |
fi
|
|
|
141 |
echo "archive creation. Please wait..."
|
|
|
142 |
cd /var/cache/urpmi
|
|
|
143 |
tar -czf rpms-$ARCH.tar.gz rpms/
|
933 |
franck |
144 |
# Clean the RPM cache
|
|
|
145 |
urpmi --clean
|
941 |
richard |
146 |
mv rpms-$ARCH.tar.gz /root/
|
|
|
147 |
cd
|
1012 |
richard |
148 |
echo "Your RPM archive file is /root/rpms-$ARCH.tar.gz"
|
933 |
franck |
149 |
exit 0
|
|
|
150 |
|