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