Subversion Repositories ALCASAR

Rev

Rev 1943 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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