Subversion Repositories ALCASAR

Rev

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