Subversion Repositories ALCASAR

Rev

Rev 1056 | Rev 1827 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log

Rev 1056 Rev 1767
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-rpm-download.sh 1056 2013-03-26 21:46:36Z stephane $
2
# $Id: alcasar-rpm-download.sh 1767 2016-01-16 18:35:35Z 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écessaire dans un fichier tarball
8
# récupération des RPM nécessaire dans un fichier tarball
9
# retrieve needed RPM in a tarball file
9
# retrieve needed RPM in a tarball file
10
 
10
 
11
VERSION="2"
11
VERSION="4"
12
ARCH="i586" 
12
ARCH="i586" 
13
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
13
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
14
PACKAGES="freeradius freeradius-mysql freeradius-ldap freeradius-web apache-mpm-prefork apache-mod_ssl apache-mod_php iptables squid dansguardian postfix mariadb logwatch ntp awstats bind-utils openssh-server php-xml php-ldap php-mysql pam_ccreds rng-utils dnsmasq syslinux rsync cronie-anacron clamav pm-fallback-policy"
14
PACKAGES="vim-enhanced freeradius freeradius-mysql freeradius-ldap freeradius-web apache apache-mod_ssl apache-mod_php dansguardian postfix mariadb ntp bind-utils openssh-server php-xml php-ldap php-mysql php-mysqli php-mbstring php-sockets php-cli php-curl php-pdo_sqlite php-json rng-utils dnsmasq rsync clamav perl-rrdtool perl-MailTools perl-Socket6 fail2ban gnupg ulogd dkms-ipt_NETFLOW iptables-NETFLOW pm-fallback-policy ipset cronie-anacron gammu usbutils locales-en usb_modeswitch tinyproxy vnstat php-gd sudo iftop"
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 --probe-synthesis --mirrorlist ${!MIRRORLIST} core /media/core/release
23
urpmi.addmedia --probe-synthesis --mirrorlist ${!MIRRORLIST} core /media/core/release
24
urpmi.addmedia --update --probe-synthesis --mirrorlist ${!MIRRORLIST} core_updates /media/core/updates
24
urpmi.addmedia --update --probe-synthesis --mirrorlist ${!MIRRORLIST} core_updates /media/core/updates
25
}
25
}
26
 
26
 
27
rpm_error ()
27
rpm_error ()
28
{
28
{
29
echo
29
echo
30
echo "Relancez l'installation ultérieurement."
30
echo "Relancez l'installation ultérieurement."
31
echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
31
echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
32
echo "Try an other install later."
32
echo "Try an other install later."
33
echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
33
echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
34
}
34
}
35
 
35
 
36
# extract the current architecture (i586 ou X64)
36
# extract the current architecture (i586 ou X64)
37
fic=`cat /etc/product.id`
37
fic=`cat /etc/product.id`
38
old="$IFS"
38
old="$IFS"
39
IFS=","
39
IFS=","
40
set $fic
40
set $fic
41
for i in $*
41
for i in $*
42
do
42
do
43
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
43
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
44
	then 
44
	then 
45
		ARCH=`echo $i|cut -d"=" -f2`
45
		ARCH=`echo $i|cut -d"=" -f2`
46
	fi
46
	fi
47
done
47
done
48
IFS="$old"
48
IFS="$old"
49
# We prefer wget than curl
49
# We prefer wget than curl
-
 
50
wget_exist=`rpm -qa|grep wget|wc -l`
-
 
51
if [ "$wget_exist" -eq "0" ]
-
 
52
then
50
urpmi --no-verify-rpm --auto ../../conf/rpms/$ARCH/wget*.rpm
53
	urpmi --no-verify-rpm --auto ../../conf/rpms/$ARCH/wget*.rpm
-
 
54
fi
51
# Set the RPM repository
55
# Set the RPM repository
52
MIRROR_NBR=2
56
MIRROR_NBR=2
53
#                       For french ALCASARistes
57
#                       For french ALCASARistes
54
MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
58
MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
55
#                       For International install
59
#                       For International install
56
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
60
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
57
try_nb="0"; nb_repository="0"
61
try_nb="0"; nb_repository="0"
58
while [ "$nb_repository" != "2" ]
62
while [ "$nb_repository" != "2" ]
59
do
63
do
60
	try_nb=`expr $try_nb + 1`
64
	try_nb=`expr $try_nb + 1`
61
	MIRRORLIST="MIRRORLIST$try_nb"
65
	MIRRORLIST="MIRRORLIST$try_nb"
62
	rpm_repository_sync 
66
	rpm_repository_sync 
63
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
67
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
64
	if [ "$nb_repository" != "2" ]
68
	if [ "$nb_repository" != "2" ]
65
	then
69
	then
66
		echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
70
		echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
67
		echo "An error occurs when synchronising the repositories N°$try_nb"
71
		echo "An error occurs when synchronising the repositories N°$try_nb"
68
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
72
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
69
		then
73
		then
70
			rpm_error
74
			rpm_error
71
			exit 1
75
			exit 1
72
		fi
76
		fi
73
		echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
77
		echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
74
		echo "Do you wan't to try a synchronisation with an other repository?"
78
		echo "Do you wan't to try a synchronisation with an other repository?"
75
		response=0
79
		response=0
76
		PTN='^[oOnNyY]$'
80
		PTN='^[oOnNyY]$'
77
		until [[ $(expr $response : $PTN) -gt 0 ]]
81
		until [[ $(expr $response : $PTN) -gt 0 ]]
78
		do
82
		do
79
			read response
83
			read response
80
		done
84
		done
81
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
85
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
82
		then
86
		then
83
			exit 1
87
			exit 1
84
		fi
88
		fi
85
	fi
89
	fi
86
done
90
done
87
# delete unused RPMs
91
# delete unused RPMs
88
echo "Cleaning the system : "
92
echo "Cleaning the system : "
89
for rm_rpm in shorewall dhcp-server cyrus-sasl distcache-server avahi mandi radeontool mondo mindi
93
for rm_rpm in shorewall dhcp-server cyrus-sasl distcache-server avahi mandi radeontool mondo mindi
90
do
94
do
91
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
95
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
92
	echo -n "."
96
	echo -n "."
93
done
97
done
94
urpmi --clean
98
urpmi --clean
95
# download RPM in cache 
99
# download RPM in cache 
96
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
100
echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
97
echo "Updated RPM download. Please wait ..."
101
echo "Updated RPM download. Please wait ..."
98
echo "Il est temps d'aller prendre un café :-) "
102
echo "Il est temps d'aller prendre un café :-) "
99
echo "You should now take a Beer ;-) "
103
echo "You should now take a Beer ;-) "
100
urpmi --auto --auto-update --quiet --test --retry 2
104
urpmi --auto --auto-update --quiet --test --retry 2
101
if [ "$?" != "0" ]
105
if [ "$?" != "0" ]
102
then
106
then
103
	echo
107
	echo
104
	echo "Une erreur a été détectée lors de la récupération des paquetages."
108
	echo "Une erreur a été détectée lors de la récupération des paquetages."
105
	echo "An error occurs when downloading RPMS"
109
	echo "An error occurs when downloading RPMS"
106
	rpm_error
110
	rpm_error
107
	exit 1
111
	exit 1
108
fi
112
fi
109
# update with cached RPM
113
# update with cached RPM
110
urpmi --auto --auto-update --noclean
114
urpmi --auto --auto-update --noclean
111
if [ "$?" != "0" ]
115
if [ "$?" != "0" ]
112
then
116
then
113
	echo
117
	echo
114
	echo "Une erreur a été détectée lors de la mise à jour des paquetages."
118
	echo "Une erreur a été détectée lors de la mise à jour des paquetages."
115
	echo "An error occurs when updating packages"
119
	echo "An error occurs when updating packages"
116
	rpm_error
120
	rpm_error
117
	exit 1
121
	exit 1
118
fi
122
fi
119
 
123
 
120
# Download of ALCASAR specifics RPM in cache (and test)
124
# Download of ALCASAR specifics RPM in cache (and test)
121
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
125
echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
122
echo "Download of complementary packages. Please wait ..."
126
echo "Download of complementary packages. Please wait ..."
123
urpmi --auto $PACKAGES --quiet --test --retry 2
127
urpmi --auto $PACKAGES --quiet --test --retry 2
124
if [ "$?" != "0" ]
128
if [ "$?" != "0" ]
125
then
129
then
126
	echo
130
	echo
127
	echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
131
	echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
128
	echo "An error occurs when downloading complementary packages"
132
	echo "An error occurs when downloading complementary packages"
129
	rpm_error
133
	rpm_error
130
	exit 1
134
	exit 1
131
fi
135
fi
132
echo "archive creation. Please wait..."
136
echo "archive creation. Please wait..."
133
cd /var/cache/urpmi
137
cd /var/cache/urpmi
134
tar -czf rpms-$ARCH.tar.gz rpms/
138
tar -czf rpms-$ARCH.tar.gz rpms/
135
# Clean the RPM cache
139
# Clean the RPM cache
136
urpmi --clean
140
urpmi --clean
137
mv rpms-$ARCH.tar.gz /root/
141
mv rpms-$ARCH.tar.gz /root/
138
cd
142
cd
139
echo "Your RPM archive file is /root/rpms-$ARCH.tar.gz"
143
echo "Your RPM archive file is /root/rpms-$ARCH.tar.gz"
140
exit 0
144
exit 0
141
 
145
 
142
 
146