Subversion Repositories ALCASAR

Rev

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

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