Subversion Repositories ALCASAR

Rev

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

Rev 2454 Rev 2478
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-rpm-download.sh 2454 2017-12-09 18:59:31Z tom.houdayer $
2
# $Id: alcasar-rpm-download.sh 2478 2017-12-30 16:27:44Z richard $
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="5"
11
VERSION="6"
12
ARCH="x86_64"
12
ARCH="x86_64"
-
 
13
# The kernel version we compile netflow for
-
 
14
KERNEL="kernel-server-4.9.56-1.mga6-1-1.mga6"
13
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
15
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
14
PACKAGES="arp-scan vim-enhanced freeradius freeradius-mysql freeradius-ldap apache apache-mod_ssl apache-mod_php dansguardian postfix mariadb ntp bind-utils openssh-server php-xml php-ldap php-mysqli php-mbstring php-sockets php-cli php-curl php-pdo_sqlite php-json rng-utils rsync clamav perl-rrdtool perl-MailTools perl-Socket6 fail2ban gnupg ulogd pm-fallback-policy ipset cronie-anacron gammu usbutils locales-en usb_modeswitch tinyproxy vnstat php-gd sudo iftop man kernel-firmware-nonfree dos2unix p7zip bc msec kernel-userspace-headers"
16
PACKAGES="arp-scan vim-enhanced freeradius freeradius-mysql freeradius-ldap apache apache-mod_ssl apache-mod_php dansguardian postfix mariadb ntp bind-utils openssh-server php-xml php-ldap php-mysqli php-mbstring php-sockets php-cli php-curl php-pdo_sqlite php-json rng-utils rsync clamav perl-rrdtool perl-MailTools perl-Socket6 fail2ban gnupg ulogd pm-fallback-policy ipset cronie-anacron gammu usbutils locales-en usb_modeswitch tinyproxy vnstat php-gd sudo iftop man dos2unix p7zip bc msec kernel-userspace-headers dnsmasq netcat-traditional"
15
 
17
 
16
rpm_repository_sync ()
18
rpm_repository_sync ()
17
{
19
{
18
cat <<EOF > /etc/urpmi/urpmi.cfg
20
cat <<EOF > /etc/urpmi/urpmi.cfg
19
{
21
{
20
downloader: wget
22
downloader: wget
21
}
23
}
22
EOF
24
EOF
23
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
25
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
24
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
25
urpmi.addmedia nonfree --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/nonfree/release
27
urpmi.addmedia nonfree --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/nonfree/release
26
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
27
}
29
}
28
 
30
 
29
rpm_error ()
31
rpm_error ()
30
{
32
{
31
echo
33
echo
32
echo "Relancez l'installation ultérieurement."
34
echo "Relancez l'installation ultérieurement."
33
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'"
34
echo "Try an other install later."
36
echo "Try an other install later."
35
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'"
36
}
38
}
37
 
39
 
38
# extract the current architecture (i586 ou X64)
40
# extract the current architecture (i586 ou X64)
39
fic=`cat /etc/product.id`
41
fic=`cat /etc/product.id`
40
old="$IFS"
42
old="$IFS"
41
IFS=","
43
IFS=","
42
set $fic
44
set $fic
43
for i in $*
45
for i in $*
44
do
46
do
45
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
47
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
46
	then
48
	then
47
		ARCH=`echo $i|cut -d"=" -f2`
49
		ARCH=`echo $i|cut -d"=" -f2`
48
	fi
50
	fi
49
done
51
done
50
IFS="$old"
52
IFS="$old"
51
# We prefer wget than curl
53
# We prefer wget than curl
52
wget_exist=`rpm -qa|grep wget|wc -l`
54
wget_exist=`rpm -qa|grep wget|wc -l`
53
if [ "$wget_exist" -eq "0" ]
55
if [ "$wget_exist" -eq "0" ]
54
then
56
then
55
	urpmi --no-verify-rpm --auto ../../conf/rpms/$ARCH/wget*.rpm
57
	urpmi --no-verify-rpm --auto ../../conf/rpms/$ARCH/wget*.rpm
56
fi
58
fi
57
# Set the RPM repository
59
# Set the RPM repository
58
MIRROR_NBR=2
60
MIRROR_NBR=2
59
#                       For french ALCASARistes
61
#                       For french ALCASARistes
60
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"
61
#                       For International install
63
#                       For International install
62
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
64
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
63
try_nb="0"; nb_repository="0"
65
try_nb="0"; nb_repository="0"
64
while [ "$nb_repository" != "4" ]
66
while [ "$nb_repository" != "4" ]
65
do
67
do
66
	try_nb=`expr $try_nb + 1`
68
	try_nb=`expr $try_nb + 1`
67
	MIRRORLIST="MIRRORLIST$try_nb"
69
	MIRRORLIST="MIRRORLIST$try_nb"
68
	rpm_repository_sync
70
	rpm_repository_sync
69
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
71
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
70
	if [ "$nb_repository" != "4" ]
72
	if [ "$nb_repository" != "4" ]
71
	then
73
	then
72
		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."
73
		echo "An error occurs when synchronising the repositories N°$try_nb"
75
		echo "An error occurs when synchronising the repositories N°$try_nb"
74
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
76
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
75
		then
77
		then
76
			rpm_error
78
			rpm_error
77
			exit 1
79
			exit 1
78
		fi
80
		fi
79
		echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
81
		echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
80
		echo "Do you wan't to try a synchronisation with an other repository?"
82
		echo "Do you wan't to try a synchronisation with an other repository?"
81
		response=0
83
		response=0
82
		PTN='^[oOnNyY]$'
84
		PTN='^[oOnNyY]$'
83
		until [[ $(expr $response : $PTN) -gt 0 ]]
85
		until [[ $(expr $response : $PTN) -gt 0 ]]
84
		do
86
		do
85
			read response
87
			read response
86
		done
88
		done
87
		if [ "$response" = "n" ] || [ "$response" = "N" ]
89
		if [ "$response" = "n" ] || [ "$response" = "N" ]
88
		then
90
		then
89
			exit 1
91
			exit 1
90
		fi
92
		fi
91
	fi
93
	fi
92
done
94
done
93
# delete unused RPMs
95
# delete unused RPMs
94
echo "Cleaning the system : "
96
echo "Cleaning the system : "
95
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
96
do
98
do
97
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
99
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
98
	echo -n "."
100
	echo -n "."
99
done
101
done
100
urpmi --clean
102
urpmi --clean
101
# download RPM in cache
103
# download RPM in cache
102
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
104
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
103
echo "Updated RPM download. Please wait ..."
105
echo "Updated RPM download. Please wait ..."
104
echo "Il est temps d'aller prendre un café :-) "
106
echo "Il est temps d'aller prendre un café :-) "
105
echo "You should now take a Beer ;-) "
107
echo "You should now take a Beer ;-) "
106
urpmi --auto --auto-update --quiet --test --retry 2
108
urpmi --auto --auto-update --quiet --test --retry 2
107
if [ "$?" != "0" ]
109
if [ "$?" != "0" ]
108
then
110
then
109
	echo
111
	echo
110
	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."
111
	echo "An error occurs when downloading RPMS"
113
	echo "An error occurs when downloading RPMS"
112
	rpm_error
114
	rpm_error
113
	exit 1
115
	exit 1
114
fi
116
fi
115
# update with cached RPM
117
# update with cached RPM
116
urpmi --auto --auto-update --noclean
118
urpmi --auto --auto-update --noclean
117
if [ "$?" != "0" ]
119
if [ "$?" != "0" ]
118
then
120
then
119
	echo
121
	echo
120
	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."
121
	echo "An error occurs when updating packages"
123
	echo "An error occurs when updating packages"
122
	rpm_error
124
	rpm_error
123
	exit 1
125
	exit 1
124
fi
126
fi
125
 
127
 
126
# Download of ALCASAR specifics RPM in cache (and test)
128
# Download of ALCASAR specifics RPM in cache (and test)
127
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
129
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
128
echo "Download of complementary packages. Please wait ..."
130
echo "Download of complementary packages. Please wait ..."
-
 
131
urpmi --auto $KERNEL --quiet --test --retry 2
129
urpmi --auto $PACKAGES --quiet --test --retry 2
132
urpmi --auto $PACKAGES --quiet --test --retry 2
130
if [ "$?" != "0" ]
133
if [ "$?" != "0" ]
131
then
134
then
132
	echo
135
	echo
133
	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."
134
	echo "An error occurs when downloading complementary packages"
137
	echo "An error occurs when downloading complementary packages"
135
	rpm_error
138
	rpm_error
136
	exit 1
139
	exit 1
137
fi
140
fi
138
echo "archive creation. Please wait..."
141
echo "archive creation. Please wait..."
139
cd /var/cache/urpmi
142
cd /var/cache/urpmi
140
tar -czf rpms-$ARCH.tar.gz rpms/
143
tar -czf rpms-$ARCH.tar.gz rpms/
141
# Clean the RPM cache
144
# Clean the RPM cache
142
urpmi --clean
145
urpmi --clean
143
mv rpms-$ARCH.tar.gz /root/
146
mv rpms-$ARCH.tar.gz /root/
144
cd
147
cd
145
echo "Your RPM archive file is /root/rpms-$ARCH.tar.gz"
148
echo "Your RPM archive file is /root/rpms-$ARCH.tar.gz"
146
exit 0
149
exit 0
147
 
150
 
148
 
151