Subversion Repositories ALCASAR

Rev

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

Rev 1539 Rev 1548
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-urpmi.sh 1539 2014-12-22 14:44:49Z richard $
2
# $Id: alcasar-urpmi.sh 1548 2014-12-28 15:39:18Z richard $
3
 
3
 
4
# alcasar-urpmi.sh
4
# alcasar-urpmi.sh
5
# by 3abtux and Rexy
5
# by 3abtux and Rexy
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
# script de mise en place des dépots RPM 
8
# script de mise en place des dépots RPM 
9
# configure the RPM repository
9
# configure the RPM repository
10
 
10
 
11
Lang=`echo $LANG|cut -c 1-2`
11
Lang=`echo $LANG|cut -c 1-2`
12
VERSION="4"
12
VERSION="4"
13
ARCH="i586" 
13
ARCH="i586" 
14
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
14
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
15
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"
15
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"
16
 
16
 
17
rpm_repository_sync ()
17
rpm_repository_sync ()
18
{
18
{
19
cat <<EOF > /etc/urpmi/urpmi.cfg
19
cat <<EOF > /etc/urpmi/urpmi.cfg
20
{
20
{
21
downloader: wget
21
downloader: wget
22
}
22
}
23
EOF
23
EOF
24
echo ${!MIRRORLIST}
24
echo ${!MIRRORLIST}
25
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
25
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
26
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
27
}
27
}
28
 
28
 
29
rpm_error ()
29
rpm_error ()
30
{
30
{
31
echo
31
echo
32
if [ $Lang == "fr" ]
32
if [ $Lang == "fr" ]
33
then	
33
then	
34
	echo "Relancez l'installation ultérieurement."
34
	echo "Relancez l'installation ultérieurement."
35
	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'"
36
else
36
else
37
	echo "Try an other install later."
37
	echo "Try an other install later."
38
	echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
38
	echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
39
fi
39
fi
40
}
40
}
41
# extract the current Mageia version and hardware architecture (i586 ou X64)
41
# extract the current Mageia version and hardware architecture (i586 ou X64)
42
fic=`cat /etc/product.id`
42
fic=`cat /etc/product.id`
43
old="$IFS"
43
old="$IFS"
44
IFS=","
44
IFS=","
45
set $fic
45
set $fic
46
for i in $*
46
for i in $*
47
do
47
do
48
	if [ "`echo $i|grep distribution|cut -d'=' -f1`" == "distribution" ]
48
	if [ "`echo $i|grep distribution|cut -d'=' -f1`" == "distribution" ]
49
	then 
49
	then 
50
		DISTRIBUTION=`echo $i|cut -d"=" -f2`
50
		DISTRIBUTION=`echo $i|cut -d"=" -f2`
51
	fi
51
	fi
52
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
52
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
53
	then 
53
	then 
54
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
54
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
55
	fi
55
	fi
56
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
56
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
57
	then 
57
	then 
58
		ARCH=`echo $i|cut -d"=" -f2`
58
		ARCH=`echo $i|cut -d"=" -f2`
59
	fi
59
	fi
60
done
60
done
61
IFS="$old"
61
IFS="$old"
62
# We prefer wget than curl
62
# We prefer wget than curl
63
urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
63
urpmi --no-verify-rpm --auto conf/rpms/$ARCH/wget*.rpm
64
# Set the RPM repository (if not already set)
64
# Set the RPM repository (if not already set)
65
ACTIVE_REPO=`cat /etc/urpmi/urpmi.cfg|grep "mageia.org"|wc -l`
65
ACTIVE_REPO=`cat /etc/urpmi/urpmi.cfg|grep "mageia.org"|wc -l`
66
if [ "$ACTIVE_REPO" != "2" ]
66
if [ "$ACTIVE_REPO" != "2" ]
67
	then
67
	then
68
	MIRROR_NBR=2
68
	MIRROR_NBR=2
69
	#                       For Europeans 
69
	#                       For Europeans 
70
	MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
70
	MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
71
	#                       For International install
71
	#                       For International install
72
	MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
72
	MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
73
	try_nb="0"; nb_repository="0"
73
	try_nb="0"; nb_repository="0"
74
	while [ "$nb_repository" != "2" ]
74
	while [ "$nb_repository" != "2" ]
75
	do
75
	do
76
		try_nb=`expr $try_nb + 1`
76
		try_nb=`expr $try_nb + 1`
77
		MIRRORLIST="MIRRORLIST$try_nb"
77
		MIRRORLIST="MIRRORLIST$try_nb"
78
		rpm_repository_sync 
78
		rpm_repository_sync 
79
		nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
79
		nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
80
		if [ "$nb_repository" != "2" ]
80
		if [ "$nb_repository" != "2" ]
81
		then
81
		then
82
			if [ $Lang == "fr" ]
82
			if [ $Lang == "fr" ]
83
			then	
83
			then	
84
				echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
84
				echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
85
			else
85
			else
86
				echo "An error occurs when synchronising the repositories N°$try_nb"
86
				echo "An error occurs when synchronising the repositories N°$try_nb"
87
			fi
87
			fi
88
			if [ $(expr $try_nb) -eq $MIRROR_NBR ]
88
			if [ $(expr $try_nb) -eq $MIRROR_NBR ]
89
			then
89
			then
90
				rpm_error
90
				rpm_error
91
				exit 1
91
				exit 1
92
			fi
92
			fi
93
			if [ $Lang == "fr" ]
93
			if [ $Lang == "fr" ]
94
			then	
94
			then	
95
				echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
95
				echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
96
			else
96
			else
97
				echo "Do you wan't to try a synchronisation with an other repository?"
97
				echo "Do you wan't to try a synchronisation with an other repository?"
98
			fi
98
			fi
99
			response=0
99
			response=0
100
			PTN='^[oOnNyY]$'
100
			PTN='^[oOnNyY]$'
101
			until [[ $(expr $response : $PTN) -gt 0 ]]
101
			until [[ $(expr $response : $PTN) -gt 0 ]]
102
			do
102
			do
103
				read response
103
				read response
104
			done
104
			done
105
			if [ "$response" = "n" ] || [ "$response" = "N" ] 
105
			if [ "$response" = "n" ] || [ "$response" = "N" ] 
106
			then
106
			then
107
			exit 1
107
			exit 1
108
			fi
108
			fi
109
		fi
109
		fi
110
	done
110
	done
111
fi
111
fi
112
# download updated RPM in cache 
112
# download updated RPM in cache 
113
if [ $Lang == "fr" ]
113
if [ $Lang == "fr" ]
114
then	
114
then	
115
	echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
115
	echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
116
	echo "Il est temps d'aller prendre un café (ou une bonne bière) ;-)"
116
	echo "Il est temps d'aller prendre un café (ou une bonne bière) ;-)"
117
else
117
else
118
	echo "Updated RPM download. Please wait ..."
118
	echo "Updated RPM download. Please wait ..."
119
	echo "You should now take a coffe (or a good beer) ;-)"
119
	echo "You should now take a coffe (or a good beer) ;-)"
120
fi
120
fi
121
urpmi --auto --auto-update --quiet --test --retry 2
121
urpmi --auto --auto-update --quiet --test --retry 2
122
if [ "$?" != "0" ]
122
if [ "$?" != "0" ]
123
then
123
then
124
	echo
124
	echo
125
	if [ $Lang == "fr" ]
125
	if [ $Lang == "fr" ]
126
	then	
126
	then	
127
		echo "Une erreur a été détectée lors de la récupération des paquetages."
127
		echo "Une erreur a été détectée lors de la récupération des paquetages."
128
	else
128
	else
129
		echo "An error occurs when downloading RPMS"
129
		echo "An error occurs when downloading RPMS"
130
	fi
130
	fi
131
	rpm_error
131
	rpm_error
132
	exit 1
132
	exit 1
133
fi
133
fi
134
# update with cached RPM
134
# update with cached RPM
135
urpmi --auto --auto-update
135
urpmi --auto --auto-update
136
if [ "$?" != "0" ]
136
if [ "$?" != "0" ]
137
then
137
then
138
	echo
138
	echo
139
	if [ $Lang == "fr" ]
139
	if [ $Lang == "fr" ]
140
	then	
140
	then	
141
		echo "Une erreur a été détectée lors de la mise à jour des paquetages."
141
		echo "Une erreur a été détectée lors de la mise à jour des paquetages."
142
	else
142
	else
143
		echo "An error occurs when updating packages"
143
		echo "An error occurs when updating packages"
144
	fi
144
	fi
145
	rpm_error
145
	rpm_error
146
	exit 1
146
	exit 1
147
fi
147
fi
148
# Clean the RPM cache
148
# Clean the RPM cache
149
urpmi --clean
149
urpmi --clean
150
# Download of ALCASAR specifics RPM in cache (and test)
150
# Download of ALCASAR specifics RPM in cache (and test)
151
if [ $Lang == "fr" ]
151
if [ $Lang == "fr" ]
152
then	
152
then	
153
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
153
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
154
else
154
else
155
	echo "Download of complementary packages. Please wait ..."
155
	echo "Download of complementary packages. Please wait ..."
156
fi
156
fi
157
urpmi --auto $PACKAGES --quiet --test --retry 2
157
urpmi --auto $PACKAGES --quiet --test --retry 2
158
if [ "$?" != "0" ]
158
if [ "$?" != "0" ]
159
then
159
then
160
	echo
160
	echo
161
	if [ $Lang == "fr" ]
161
	if [ $Lang == "fr" ]
162
	then	
162
	then	
163
		echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
163
		echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
164
	else
164
	else
165
		echo "An error occurs when downloading complementary packages"
165
		echo "An error occurs when downloading complementary packages"
166
	fi
166
	fi
167
	rpm_error
167
	rpm_error
168
	exit 1
168
	exit 1
169
fi
169
fi
170
# update with cached RPM
170
# update with cached RPM
171
urpmi --auto $PACKAGES 
171
urpmi --auto $PACKAGES 
172
if [ "$?" != "0" ]
172
if [ "$?" != "0" ]
173
then
173
then
174
	echo
174
	echo
175
	if [ $Lang == "fr" ]
175
	if [ $Lang == "fr" ]
176
	then	
176
	then	
177
		echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
177
		echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
178
	else
178
	else
179
		echo "An error occurs when installing complementary packages"
179
		echo "An error occurs when installing complementary packages"
180
	fi
180
	fi
181
	rpm_error
181
	rpm_error
182
	exit 1
182
	exit 1
183
fi
183
fi
184
# delete unused RPMs
184
# delete unused RPMs
185
if [ $Lang == "fr" ]
185
if [ $Lang == "fr" ]
186
then
186
then
187
	echo "Cleaning the system : "
187
	echo "Cleaning the system : "
188
else
188
else
189
	echo "Nettoyage du système : "
189
	echo "Nettoyage du système : "
190
fi
190
fi
191
for rm_rpm in shorewall mandi radeontool avahi mageia-gfxboot-theme privoxy cpupower squid
191
for rm_rpm in shorewall mandi radeontool avahi mageia-gfxboot-theme privoxy cpupower squid
192
do
192
do
193
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
193
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
194
	echo -n "."
194
	echo -n "."
195
done
195
done
196
 
196
 
197
# Save chilli launch script (erase with new rpm one)
197
# Save chilli launch script (erase with new rpm one)
198
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
198
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
199
# Install home made RPMs
199
# Install home made RPMs
200
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
200
urpmi --no-verify --auto conf/rpms/$ARCH/*.rpm
201
# restore chilli launch script
201
# restore chilli launch script
202
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
202
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
203
# Clean the RPM cache
203
# Clean the RPM cache
204
urpmi --clean
204
urpmi --clean
205
exit 0
205
exit 0
206
 
206