Subversion Repositories ALCASAR

Rev

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

Rev 2202 Rev 2221
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-urpmi.sh 2202 2017-05-06 13:35:14Z richard $
2
# $Id: alcasar-urpmi.sh 2221 2017-05-13 13:47:30Z 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="5"
12
VERSION="5"
13
ARCH="i586" 
13
ARCH="x86_64" 
14
# The kernel version we compile netflow for
14
# The kernel version we compile netflow for
15
KERNEL="kernel-server-4.4.59-1.mga5-1-1.mga5"
15
KERNEL="kernel-server-4.4.59-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="arp-scan 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-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 bc msec"
17
PACKAGES="arp-scan 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-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 bc msec"
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
MIRROR_NBR=2
73
MIRROR_NBR=2
74
#                       For Europeans 
74
#                       For Europeans 
75
MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
75
MIRRORLIST1="http://www.mirrorservice.org/sites/mageia.org/pub/mageia/distrib/$VERSION/$ARCH"
76
#                       For International install
76
#                       For International install
77
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
77
MIRRORLIST2="http://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
78
try_nb="0"; nb_repository="0"
78
try_nb="0"; nb_repository="0"
79
while [ "$nb_repository" != "4" ]
79
while [ "$nb_repository" != "4" ]
80
do
80
do
81
	try_nb=`expr $try_nb + 1`
81
	try_nb=`expr $try_nb + 1`
82
	MIRRORLIST="MIRRORLIST$try_nb"
82
	MIRRORLIST="MIRRORLIST$try_nb"
83
	rpm_repository_sync 
83
	rpm_repository_sync 
84
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
84
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
85
	if [ "$nb_repository" != "4" ]
85
	if [ "$nb_repository" != "4" ]
86
	then
86
	then
87
		if [ $Lang == "fr" ]
87
		if [ $Lang == "fr" ]
88
		then	
88
		then	
89
			echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
89
			echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
90
		else
90
		else
91
			echo "An error occurs when synchronising the repositories N°$try_nb"
91
			echo "An error occurs when synchronising the repositories N°$try_nb"
92
		fi
92
		fi
93
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
93
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
94
		then
94
		then
95
			rpm_error
95
			rpm_error
96
			exit 1
96
			exit 1
97
		fi
97
		fi
98
		if [ $Lang == "fr" ]
98
		if [ $Lang == "fr" ]
99
		then	
99
		then	
100
			echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
100
			echo "Voulez-vous tenter une synchronisation avec un autre dépôt?"
101
		else
101
		else
102
			echo "Do you wan't to try a synchronisation with an other repository?"
102
			echo "Do you wan't to try a synchronisation with an other repository?"
103
		fi
103
		fi
104
		response=0
104
		response=0
105
		PTN='^[oOnNyY]$'
105
		PTN='^[oOnNyY]$'
106
		until [[ $(expr $response : $PTN) -gt 0 ]]
106
		until [[ $(expr $response : $PTN) -gt 0 ]]
107
		do
107
		do
108
			read response
108
			read response
109
		done
109
		done
110
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
110
		if [ "$response" = "n" ] || [ "$response" = "N" ] 
111
		then
111
		then
112
			exit 1
112
			exit 1
113
		fi
113
		fi
114
	fi
114
	fi
115
done
115
done
116
 
116
 
117
# download the kernel used by ALCASAR and fix its version
117
# download the kernel used by ALCASAR and fix its version
118
if [ $Lang == "fr" ]
118
if [ $Lang == "fr" ]
119
then	
119
then	
120
	echo "Récupération du noyau Linux exploité par ALCASAR. Veuillez patienter ..."
120
	echo "Récupération du noyau Linux exploité par ALCASAR. Veuillez patienter ..."
121
else
121
else
122
	echo "Download the Linux kernel used by ALCASAR. Please wait ..."
122
	echo "Download the Linux kernel used by ALCASAR. Please wait ..."
123
fi
123
fi
124
rm -f /etc/urpmi/skip.list
-
 
125
urpmi --auto --quiet $KERNEL
-
 
126
echo "/^kernel/" > /etc/urpmi/skip.list
124
echo "/^kernel/" > /etc/urpmi/skip.list
127
 
-
 
-
 
125
urpmi --auto --quiet $KERNEL
128
# download updated RPM in cache 
126
# download updated RPM in cache 
129
if [ $Lang == "fr" ]
127
if [ $Lang == "fr" ]
130
then	
128
then	
131
	echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
129
	echo "Récupération des paquetages de mise à jour. Veuillez patienter ..."
132
	echo "Il est temps d'aller prendre un café (ou une bonne bière) ;-)"
130
	echo "Il est temps d'aller prendre un café (ou une bonne bière) ;-)"
133
else
131
else
134
	echo "Updated RPM download. Please wait ..."
132
	echo "Updated RPM download. Please wait ..."
135
	echo "You should now take a coffe (or a good beer) ;-)"
133
	echo "You should now take a coffe (or a good beer) ;-)"
136
fi
134
fi
137
urpmi --auto --auto-update --quiet --test --retry 2
135
urpmi --auto --auto-update --quiet --test --retry 2
138
if [ "$?" != "0" ]
136
if [ "$?" != "0" ]
139
then
137
then
140
	echo
138
	echo
141
	if [ $Lang == "fr" ]
139
	if [ $Lang == "fr" ]
142
	then	
140
	then	
143
		echo "Une erreur a été détectée lors de la récupération des paquetages."
141
		echo "Une erreur a été détectée lors de la récupération des paquetages."
144
	else
142
	else
145
		echo "An error occurs when downloading RPMS"
143
		echo "An error occurs when downloading RPMS"
146
	fi
144
	fi
147
	rpm_error
145
	rpm_error
148
	exit 1
146
	exit 1
149
fi
147
fi
150
 
148
 
151
# update with cached RPM
149
# update with cached RPM
152
urpmi --auto --auto-update
150
urpmi --auto --auto-update
153
if [ "$?" != "0" ]
151
if [ "$?" != "0" ]
154
then
152
then
155
	echo
153
	echo
156
	if [ $Lang == "fr" ]
154
	if [ $Lang == "fr" ]
157
	then	
155
	then	
158
		echo "Une erreur a été détectée lors de la mise à jour des paquetages."
156
		echo "Une erreur a été détectée lors de la mise à jour des paquetages."
159
	else
157
	else
160
		echo "An error occurs when updating packages"
158
		echo "An error occurs when updating packages"
161
	fi
159
	fi
162
	rpm_error
160
	rpm_error
163
	exit 1
161
	exit 1
164
fi
162
fi
165
# Clean the RPM cache
163
# Clean the RPM cache
166
urpmi --clean
164
urpmi --clean
167
 
165
 
168
# Download of ALCASAR specifics RPM in cache (and test)
166
# Download of ALCASAR specifics RPM in cache (and test)
169
if [ $Lang == "fr" ]
167
if [ $Lang == "fr" ]
170
then	
168
then	
171
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
169
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
172
else
170
else
173
	echo "Download of complementary packages. Please wait ..."
171
	echo "Download of complementary packages. Please wait ..."
174
fi
172
fi
175
urpmi --auto $PACKAGES --quiet --test --retry 2
173
urpmi --auto $PACKAGES --quiet --test --retry 2
176
if [ "$?" != "0" ]
174
if [ "$?" != "0" ]
177
then
175
then
178
	echo
176
	echo
179
	if [ $Lang == "fr" ]
177
	if [ $Lang == "fr" ]
180
	then	
178
	then	
181
		echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
179
		echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
182
	else
180
	else
183
		echo "An error occurs when downloading complementary packages"
181
		echo "An error occurs when downloading complementary packages"
184
	fi
182
	fi
185
	rpm_error
183
	rpm_error
186
	exit 1
184
	exit 1
187
fi
185
fi
188
 
186
 
189
# update with cached RPM
187
# update with cached RPM
190
urpmi --auto $PACKAGES 
188
urpmi --auto $PACKAGES 
191
if [ "$?" != "0" ]
189
if [ "$?" != "0" ]
192
then
190
then
193
	echo
191
	echo
194
	if [ $Lang == "fr" ]
192
	if [ $Lang == "fr" ]
195
	then	
193
	then	
196
		echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
194
		echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
197
	else
195
	else
198
		echo "An error occurs when installing complementary packages"
196
		echo "An error occurs when installing complementary packages"
199
	fi
197
	fi
200
	rpm_error
198
	rpm_error
201
	exit 1
199
	exit 1
202
fi
200
fi
203
 
201
 
204
# Keep only the kernel version we compil netflow with, and remove all others
202
# Keep only the kernel version we compil netflow with, and remove all others
205
kernelVersion=$(rpm -qa | grep -e ^kernel-server -e ^kernel-desktop)
203
kernelVersion=$(rpm -qa | grep -e ^kernel-server -e ^kernel-desktop)
206
for i in $kernelVersion
204
for i in $kernelVersion
207
do
205
do
208
	if [ $i != $KERNEL ];then
206
	if [ $i != $KERNEL ];then
209
		urpme --auto $i
207
		urpme --auto $i
210
	fi
208
	fi
211
done
209
done
212
# delete unused RPMs
210
# delete unused RPMs
213
if [ $Lang == "fr" ]
211
if [ $Lang == "fr" ]
214
then
212
then
215
	echo "Cleaning the system : "
213
	echo "Cleaning the system : "
216
else
214
else
217
	echo "Nettoyage du système : "
215
	echo "Nettoyage du système : "
218
fi
216
fi
219
for rm_rpm in shorewall mandi avahi mageia-gfxboot-theme privoxy cpupower squid gamin
217
for rm_rpm in shorewall mandi avahi mageia-gfxboot-theme privoxy cpupower squid gamin
220
do
218
do
221
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
219
	/usr/sbin/urpme --auto $rm_rpm --auto-orphans 2>/dev/null
222
	echo -n "."
220
	echo -n "."
223
done
221
done
224
 
222
 
225
# Save chilli launch script (erase with new rpm one)
223
# Save chilli launch script (erase with new rpm one)
226
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
224
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
227
# Install home made RPMs
225
# Install home made RPMs
228
urpmi --no-verify --auto rpms/$ARCH/*.rpm
226
urpmi --no-verify --auto rpms/$ARCH/*.rpm
229
# restore chilli launch script
227
# restore chilli launch script
230
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
228
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
231
# Clean the RPM cache
229
# Clean the RPM cache
232
urpmi --clean
230
urpmi --clean
233
# the ipt-netflow RPM add the kernel module ipt_NETFLOW (the modules dependance tree need to be updated)
231
# the ipt-netflow RPM add the kernel module ipt_NETFLOW (the modules dependance tree need to be updated)
234
/sbin/depmod -a
232
/sbin/depmod -a
235
exit 0
233
exit 0
236
 
234