Subversion Repositories ALCASAR

Rev

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

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