Subversion Repositories ALCASAR

Rev

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

Rev 3103 Rev 3114
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-rpm-download.sh 3103 2022-12-30 23:45:23Z rexy $
2
# $Id: alcasar-rpm-download.sh 3114 2023-02-09 21:52:16Z 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="8"
11
VERSION="8"
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.15.82-1.mga8-1-1.mga8"
14
KERNEL="kernel-server-5.15.82-1.mga8-1-1.mga8"
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
16
# (old) perl-Socket6 : needed by nfsen
17
# "fonts-dejavu-common" & "fonts-ttf-dejavu" : fonts needed by wkhtmltopdf
17
# "fonts-dejavu-common" & "fonts-ttf-dejavu" : fonts needed by wkhtmltopdf
18
# "lsscsi" & nvme-cli" : needed by phpsysinfo
18
# "lsscsi" & nvme-cli" : needed by phpsysinfo
19
# "socat" : avoid a warning when run the install script of letsencrypt ("acme.sh")
19
# "socat" : avoid a warning when run the install script of letsencrypt ("acme.sh")
20
# "sudo" : needed after a reinstallation (to be investigated)
20
# "sudo" : needed after a reinstallation (to be investigated)
21
# "clamav" + "clamav-db" : needed because of a lack of mutual dependance
21
# "clamav" + "clamav-db" : needed because of a lack of mutual dependance
22
# "postfix" + "cyrus-sasl" + "lib64sasl2-plug-plain" : email registration method
22
# "postfix" + "cyrus-sasl" + "lib64sasl2-plug-plain" : email registration method
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"
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 php-filter 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"
24
 
24
 
25
rpm_repository_sync ()
25
rpm_repository_sync ()
26
{
26
{
27
cat <<EOF > /etc/urpmi/urpmi.cfg
27
cat <<EOF > /etc/urpmi/urpmi.cfg
28
{
28
{
29
downloader: wget
29
downloader: wget
30
}
30
}
31
EOF
31
EOF
32
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
32
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
33
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
34
urpmi.addmedia nonfree --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/nonfree/release
34
urpmi.addmedia nonfree --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/nonfree/release
35
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
36
}
36
}
37
 
37
 
38
rpm_error ()
38
rpm_error ()
39
{
39
{
40
echo
40
echo
41
echo "Relancez l'installation ultérieurement."
41
echo "Relancez l'installation ultérieurement."
42
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'"
43
echo "Try an other install later."
43
echo "Try an other install later."
44
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'"
45
}
45
}
46
 
46
 
47
# extract the current architecture (i586 ou X64)
47
# extract the current architecture (i586 ou X64)
48
fic=`cat /etc/product.id`
48
fic=`cat /etc/product.id`
49
old="$IFS"
49
old="$IFS"
50
IFS=","
50
IFS=","
51
set $fic
51
set $fic
52
for i in $*
52
for i in $*
53
do
53
do
54
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
54
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
55
	then
55
	then
56
		ARCH=`echo $i|cut -d"=" -f2`
56
		ARCH=`echo $i|cut -d"=" -f2`
57
	fi
57
	fi
58
done
58
done
59
IFS="$old"
59
IFS="$old"
60
# We prefer wget than curl
60
# We prefer wget than curl
61
wget_exist=`rpm -qa|grep wget|wc -l`
61
wget_exist=`rpm -qa|grep wget|wc -l`
62
if [ "$wget_exist" -eq "0" ]
62
if [ "$wget_exist" -eq "0" ]
63
then
63
then
64
	urpmi --no-verify-rpm --auto ../rpms/$ARCH/wget*.rpm
64
	urpmi --no-verify-rpm --auto ../rpms/$ARCH/wget*.rpm
65
fi
65
fi
66
# Set the RPM repository
66
# Set the RPM repository
67
MIRROR_NBR=2
67
MIRROR_NBR=2
68
#                       For french ALCASARistes
68
#                       For french ALCASARistes
69
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"
70
#                       For International install
70
#                       For International install
71
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
71
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
72
try_nb="0"; nb_repository="0"
72
try_nb="0"; nb_repository="0"
73
while [ "$nb_repository" != "4" ]
73
while [ "$nb_repository" != "4" ]
74
do
74
do
75
	try_nb=`expr $try_nb + 1`
75
	try_nb=`expr $try_nb + 1`
76
	MIRRORLIST="MIRRORLIST$try_nb"
76
	MIRRORLIST="MIRRORLIST$try_nb"
77
	rpm_repository_sync
77
	rpm_repository_sync
78
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
78
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
79
	if [ "$nb_repository" != "4" ]
79
	if [ "$nb_repository" != "4" ]
80
	then
80
	then
81
		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."
82
		echo "An error occurs when synchronising the repositories N°$try_nb"
82
		echo "An error occurs when synchronising the repositories N°$try_nb"
83
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
83
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
84
		then
84
		then
85
			rpm_error
85
			rpm_error
86
			exit 1
86
			exit 1
87
		fi
87
		fi
88
		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)?"
89
		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)?"
90
		response=0
90
		response=0
91
		PTN='^[oOnNyY]?$'
91
		PTN='^[oOnNyY]?$'
92
		until [[ "$response" =~ $PTN ]]
92
		until [[ "$response" =~ $PTN ]]
93
		do
93
		do
94
			read response
94
			read response
95
		done
95
		done
96
		if [ "$response" = "n" ] || [ "$response" = "N" ]
96
		if [ "$response" = "n" ] || [ "$response" = "N" ]
97
		then
97
		then
98
			exit 1
98
			exit 1
99
		fi
99
		fi
100
	fi
100
	fi
101
done
101
done
102
# delete unused RPMs
102
# delete unused RPMs
103
echo "Cleaning the system : "
103
echo "Cleaning the system : "
104
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
105
do
105
do
106
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
106
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
107
	echo -n "."
107
	echo -n "."
108
done
108
done
109
urpmi --clean
109
urpmi --clean
110
# download RPM in cache
110
# download RPM in cache
111
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
111
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
112
echo "Updated RPM download. Please wait ..."
112
echo "Updated RPM download. Please wait ..."
113
echo "Il est temps d'aller prendre un café :-) "
113
echo "Il est temps d'aller prendre un café :-) "
114
echo "You should now take a Beer ;-) "
114
echo "You should now take a Beer ;-) "
115
urpmi --auto --auto-update --quiet --test --retry 2
115
urpmi --auto --auto-update --quiet --test --retry 2
116
if [ "$?" != "0" ]
116
if [ "$?" != "0" ]
117
then
117
then
118
	echo
118
	echo
119
	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."
120
	echo "An error occurs when downloading RPMS"
120
	echo "An error occurs when downloading RPMS"
121
	rpm_error
121
	rpm_error
122
	exit 1
122
	exit 1
123
fi
123
fi
124
# update with cached RPM
124
# update with cached RPM
125
urpmi --auto --auto-update --noclean
125
urpmi --auto --auto-update --noclean
126
if [ "$?" != "0" ]
126
if [ "$?" != "0" ]
127
then
127
then
128
	echo
128
	echo
129
	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."
130
	echo "An error occurs when updating packages"
130
	echo "An error occurs when updating packages"
131
	rpm_error
131
	rpm_error
132
	exit 1
132
	exit 1
133
fi
133
fi
134
 
134
 
135
# Download of ALCASAR specifics RPM in cache (and test)
135
# Download of ALCASAR specifics RPM in cache (and test)
136
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
136
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
137
echo "Download of complementary packages. Please wait ..."
137
echo "Download of complementary packages. Please wait ..."
138
urpmi --auto $KERNEL --quiet --test --retry 2
138
urpmi --auto $KERNEL --quiet --test --retry 2
139
urpmi --auto $PACKAGES --quiet --test --retry 2
139
urpmi --auto $PACKAGES --quiet --test --retry 2
140
if [ "$?" != "0" ]
140
if [ "$?" != "0" ]
141
then
141
then
142
	echo
142
	echo
143
	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."
144
	echo "An error occurs when downloading complementary packages"
144
	echo "An error occurs when downloading complementary packages"
145
	rpm_error
145
	rpm_error
146
	exit 1
146
	exit 1
147
fi
147
fi
148
echo "archive creation. Please wait..."
148
echo "archive creation. Please wait..."
149
cd /var/cache/urpmi
149
cd /var/cache/urpmi
150
tar -czf rpms-$ARCH.tar.gz rpms/
150
tar -czf rpms-$ARCH.tar.gz rpms/
151
# Clean the RPM cache
151
# Clean the RPM cache
152
urpmi --clean
152
urpmi --clean
153
mv rpms-$ARCH.tar.gz /root/
153
mv rpms-$ARCH.tar.gz /root/
154
cd
154
cd
155
echo "Your RPM archive file is /root/rpms-$ARCH.tar.gz"
155
echo "Your RPM archive file is /root/rpms-$ARCH.tar.gz"
156
exit 0
156
exit 0
157
 
157