Subversion Repositories ALCASAR

Rev

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

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