Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

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