Subversion Repositories ALCASAR

Rev

Rev 3055 | Rev 3088 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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