Subversion Repositories ALCASAR

Rev

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

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