941 |
richard |
1 |
#!/bin/bash
|
958 |
franck |
2 |
# $Id: alcasar-rpm-download.sh 2968 2021-07-08 22:10:57Z rexy $
|
933 |
franck |
3 |
|
2941 |
rexy |
4 |
# alcasar-rpm-download.sh
|
933 |
franck |
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 |
|
2757 |
rexy |
11 |
VERSION="7"
|
2454 |
tom.houday |
12 |
ARCH="x86_64"
|
2478 |
richard |
13 |
# The kernel version we compile netflow for
|
2968 |
rexy |
14 |
KERNEL="kernel-server-5.10.46-1.mga7-1-1.mga7"
|
933 |
franck |
15 |
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
|
2956 |
rexy |
16 |
PACKAGES="vim-enhanced freeradius freeradius-mysql freeradius-ldap lighttpd lighttpd-mod_auth php-fpm php-gd php-ldap php-mysqli php-mbstring php-sockets php-curl php-pdo_sqlite php-cli unbound e2guardian postfix mariadb ntp bind-utils openssh-server rng-utils rsync clamd clamav clamav-db fail2ban gnupg2 ulogd pm-fallback-policy ipset usb_modeswitch vnstat dos2unix p7zip msec kernel-userspace-headers kernel-firmware-nonfree dnsmasq dhcp-server tcpdump fonts-dejavu-common fonts-ttf-dejavu lsscsi nvme-cli sudo socat"
|
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."
|
2941 |
rexy |
35 |
echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-rpm.sh'"
|
933 |
franck |
36 |
echo "Try an other install later."
|
2941 |
rexy |
37 |
echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-rpm.sh'"
|
933 |
franck |
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
|
2507 |
rexy |
57 |
urpmi --no-verify-rpm --auto ../rpms/$ARCH/wget*.rpm
|
1767 |
richard |
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
|
2760 |
lucas.echa |
81 |
echo "Voulez-vous tenter une synchronisation avec un autre dépôt (O/n)?"
|
|
|
82 |
echo "Do you want to try a synchronisation with an other repository (Y/n)?"
|
941 |
richard |
83 |
response=0
|
2760 |
lucas.echa |
84 |
PTN='^[oOnNyY]?$'
|
|
|
85 |
until [[ "$response" =~ $PTN ]]
|
941 |
richard |
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
|