Subversion Repositories ALCASAR

Rev

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

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