Subversion Repositories ALCASAR

Rev

Rev 2821 | 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 2824 2020-05-30 17:39:20Z rexy $
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
 
2454 tom.houday 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`
2757 rexy 12
VERSION="7"
2454 tom.houday 13
ARCH="x86_64"
1799 richard 14
# The kernel version we compile netflow for
2824 rexy 15
KERNEL="kernel-server-5.6.14-2.mga7-1-1.mga7"
532 richard 16
# ****** Alcasar needed RPMS - paquetages nécessaires au fonctionnement d'Alcasar ******
2794 rexy 17
# (old) perl-Socket6 : needed by nfsen
2807 rexy 18
# "fonts-dejavu-common" & "fonts-ttf-dejavu" : fonts needed by wkhtmltopdf
19
# "lsscsi" & nvme-cli" : needed by phpsysinfo
20
PACKAGES="vim-enhanced freeradius freeradius-mysql freeradius-ldap lighttpd lighttpd-mod_auth php-fpm php-gd php-ldap php-mysqli php-mbstring php-sockets php-curl php-pdo_sqlite php-cli php-rrd unbound e2guardian postfix mariadb ntp bind-utils openssh-server rng-utils rsync clamav fail2ban gnupg2 ulogd pm-fallback-policy ipset usb_modeswitch tinyproxy vnstat dos2unix p7zip msec kernel-userspace-headers kernel-firmware-nonfree dnsmasq dhcp-server tcpdump fonts-dejavu-common fonts-ttf-dejavu lsscsi nvme-cli"
1207 richard 21
 
497 richard 22
rpm_repository_sync ()
23
{
835 richard 24
cat <<EOF > /etc/urpmi/urpmi.cfg
25
{
26
downloader: wget
497 richard 27
}
835 richard 28
EOF
1003 richard 29
echo ${!MIRRORLIST}
30
urpmi.addmedia core --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/release
31
urpmi.addmedia core-updates --update --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/core/updates
1985 richard 32
urpmi.addmedia nonfree --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/nonfree/release
33
urpmi.addmedia nonfree-updates --update --probe-synthesis --mirrorlist ${!MIRRORLIST} /media/nonfree/updates
835 richard 34
}
497 richard 35
 
532 richard 36
rpm_error ()
37
{
38
echo
1060 richard 39
if [ $Lang == "fr" ]
2454 tom.houday 40
then
1060 richard 41
	echo "Relancez l'installation ultérieurement."
42
	echo "Si vous rencontrez à nouveau ce problème, modifier les variables MIRRORLIST[1&2] du fichier 'scripts/alcasar-urpmi.sh'"
43
else
44
	echo "Try an other install later."
45
	echo "If this problem occurs again, change the MIRRORLIST[1&2] variables in the file 'scripts/alcasar-urpmi.sh'"
46
fi
532 richard 47
}
1799 richard 48
 
1336 richard 49
# extract the current Mageia version and hardware architecture (i586 ou X64)
230 franck 50
fic=`cat /etc/product.id`
457 richard 51
old="$IFS"
52
IFS=","
230 franck 53
set $fic
54
for i in $*
55
do
1003 richard 56
	if [ "`echo $i|grep distribution|cut -d'=' -f1`" == "distribution" ]
2454 tom.houday 57
	then
1003 richard 58
		DISTRIBUTION=`echo $i|cut -d"=" -f2`
59
	fi
230 franck 60
	if [ "`echo $i|grep version|cut -d'=' -f1`" == "version" ]
2454 tom.houday 61
	then
457 richard 62
		CURRENT_VERSION=`echo $i|cut -d"=" -f2`
230 franck 63
	fi
456 franck 64
	if [ "`echo $i|grep arch|cut -d'=' -f1`" == "arch" ]
2454 tom.houday 65
	then
456 franck 66
		ARCH=`echo $i|cut -d"=" -f2`
67
	fi
230 franck 68
done
457 richard 69
IFS="$old"
1799 richard 70
 
532 richard 71
# We prefer wget than curl
1943 richard 72
urpmi --no-verify-rpm --auto rpms/$ARCH/wget*.rpm
1799 richard 73
 
1350 richard 74
# Set the RPM repository (if not already set)
1352 richard 75
ACTIVE_REPO=`cat /etc/urpmi/urpmi.cfg|grep "mageia.org"|wc -l`
2056 richard 76
MIRROR_NBR=2
2454 tom.houday 77
#                       For Europeans
2824 rexy 78
MIRRORLIST1="https://www.mirrorservice.org/pub/mageia/distrib/$VERSION/$ARCH"
2056 richard 79
#                       For International install
2587 tom.houday 80
MIRRORLIST2="https://mirrors.mageia.org/api/mageia.$VERSION.$ARCH.list"
2056 richard 81
try_nb="0"; nb_repository="0"
82
while [ "$nb_repository" != "4" ]
83
do
84
	try_nb=`expr $try_nb + 1`
85
	MIRRORLIST="MIRRORLIST$try_nb"
2454 tom.houday 86
	rpm_repository_sync
2056 richard 87
	nb_repository=`cat /etc/urpmi/urpmi.cfg|grep mirrorlist|wc -l`
88
	if [ "$nb_repository" != "4" ]
89
	then
90
		if [ $Lang == "fr" ]
2454 tom.houday 91
		then
2056 richard 92
			echo "Une erreur a été détectée lors de la synchronisation avec le dépot N°$try_nb."
93
		else
94
			echo "An error occurs when synchronising the repositories N°$try_nb"
95
		fi
96
		if [ $(expr $try_nb) -eq $MIRROR_NBR ]
497 richard 97
		then
2056 richard 98
			rpm_error
497 richard 99
			exit 1
100
		fi
2056 richard 101
		if [ $Lang == "fr" ]
2454 tom.houday 102
		then
2431 tom.houday 103
			echo "Voulez-vous tenter une synchronisation avec un autre dépôt ? (O/n)"
2056 richard 104
		else
2760 lucas.echa 105
			echo "Do you want to try a synchronisation with an other repository? (Y/n)"
2056 richard 106
		fi
107
		response=0
2760 lucas.echa 108
		PTN='^[oOnNyY]?$'
109
		until [[ "$response" =~ $PTN ]]
2056 richard 110
		do
111
			read response
112
		done
2454 tom.houday 113
		if [ "$response" = "n" ] || [ "$response" = "N" ]
2056 richard 114
		then
115
			exit 1
116
		fi
117
	fi
118
done
2761 rexy 119
# fix some RPM versions
120
echo "/^kernel/" > /etc/urpmi/skip.list
121
echo "/^freeradius/" >> /etc/urpmi/skip.list
2802 rexy 122
echo "/^wkhtmltopdf/" >> /etc/urpmi/skip.list
2730 rexy 123
# download the kernel used by ALCASAR
1799 richard 124
if [ $Lang == "fr" ]
2454 tom.houday 125
then
1799 richard 126
	echo "Récupération du noyau Linux exploité par ALCASAR. Veuillez patienter ..."
127
else
128
	echo "Download the Linux kernel used by ALCASAR. Please wait ..."
129
fi
130
urpmi --auto --quiet $KERNEL
2454 tom.houday 131
# download updated RPM in cache
1207 richard 132
if [ $Lang == "fr" ]
2454 tom.houday 133
then
1060 richard 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) ;-)"
136
else
137
	echo "Updated RPM download. Please wait ..."
138
	echo "You should now take a coffe (or a good beer) ;-)"
139
fi
835 richard 140
urpmi --auto --auto-update --quiet --test --retry 2
460 richard 141
if [ "$?" != "0" ]
142
then
143
	echo
1060 richard 144
	if [ $Lang == "fr" ]
2454 tom.houday 145
	then
1060 richard 146
		echo "Une erreur a été détectée lors de la récupération des paquetages."
147
	else
148
		echo "An error occurs when downloading RPMS"
149
	fi
532 richard 150
	rpm_error
470 richard 151
	exit 1
460 richard 152
fi
1799 richard 153
 
460 richard 154
# update with cached RPM
155
urpmi --auto --auto-update
799 richard 156
if [ "$?" != "0" ]
157
then
158
	echo
1060 richard 159
	if [ $Lang == "fr" ]
2454 tom.houday 160
	then
1060 richard 161
		echo "Une erreur a été détectée lors de la mise à jour des paquetages."
162
	else
163
		echo "An error occurs when updating packages"
164
	fi
799 richard 165
	rpm_error
166
	exit 1
167
fi
772 richard 168
# Clean the RPM cache
169
urpmi --clean
1799 richard 170
 
532 richard 171
# Download of ALCASAR specifics RPM in cache (and test)
1060 richard 172
if [ $Lang == "fr" ]
2454 tom.houday 173
then
1060 richard 174
	echo "Récupération des paquetages complémentaires. Veuillez patienter ..."
175
else
176
	echo "Download of complementary packages. Please wait ..."
177
fi
2761 rexy 178
urpmi --auto --no-recommends $PACKAGES --quiet --test --retry 2
532 richard 179
if [ "$?" != "0" ]
180
then
181
	echo
1060 richard 182
	if [ $Lang == "fr" ]
2454 tom.houday 183
	then
1060 richard 184
		echo "Une erreur a été détectée lors de la récupération des paquetages complémentaires."
185
	else
186
		echo "An error occurs when downloading complementary packages"
187
	fi
532 richard 188
	rpm_error
189
	exit 1
190
fi
1799 richard 191
 
532 richard 192
# update with cached RPM
2761 rexy 193
urpmi --auto --no-recommends $PACKAGES
799 richard 194
if [ "$?" != "0" ]
195
then
196
	echo
1060 richard 197
	if [ $Lang == "fr" ]
2454 tom.houday 198
	then
1060 richard 199
		echo "Une erreur a été détectée lors de l'installation des paquetages complémentaires."
200
	else
201
		echo "An error occurs when installing complementary packages"
202
	fi
799 richard 203
	rpm_error
204
	exit 1
205
fi
1799 richard 206
 
207
# Keep only the kernel version we compil netflow with, and remove all others
1801 richard 208
kernelVersion=$(rpm -qa | grep -e ^kernel-server -e ^kernel-desktop)
1799 richard 209
for i in $kernelVersion
210
do
1801 richard 211
	if [ $i != $KERNEL ];then
1799 richard 212
		urpme --auto $i
213
	fi
214
done
1348 richard 215
# delete unused RPMs
216
if [ $Lang == "fr" ]
217
then
218
	echo "Cleaning the system : "
219
else
220
	echo "Nettoyage du système : "
221
fi
2563 rexy 222
rm_rpm="shorewall mandi plymouth cpupower squid"
2227 richard 223
/usr/sbin/urpme --auto -a $rm_rpm
2291 richard 224
/usr/sbin/urpme --auto --auto-orphans
1207 richard 225
 
972 richard 226
# Save chilli launch script (erase with new rpm one)
1007 richard 227
[ -e /etc/chilli.conf ] && cp /etc/chilli.conf /tmp/
972 richard 228
# Install home made RPMs
2768 rexy 229
for pkg in `ls rpms/$ARCH/*.rpm`
230
do
231
    urpmi --no-verify --auto $pkg
232
done
972 richard 233
# restore chilli launch script
1007 richard 234
[ -e /tmp/chilli.conf ] && mv /tmp/chilli.conf /etc/
532 richard 235
# Clean the RPM cache
236
urpmi --clean
2768 rexy 237
# the ipt-netflow RPM add the kernel module ipt_NETFLOW (the modules dependance tree need to be updated). "2>/dev/null" in order not to display a error (the running kernel is not the ALCASAR one during the installation process)
238
/sbin/depmod -a 2>/dev/null
2758 rexy 239
# test if all needed rpms are correctly installed
240
count_pkg=0; nb_pkg=0;
241
for pkg in $PACKAGES
242
do
2760 lucas.echa 243
	nb_pkg=`expr $nb_pkg + 1`
2758 rexy 244
	if rpm -q --quiet $pkg ; then
245
		count_pkg=`expr $count_pkg + 1`
246
	else
247
		echo "error installing $pkg"
2760 lucas.echa 248
	fi
2758 rexy 249
done
250
if [ $count_pkg -ne $nb_pkg ]
251
then
252
	exit 1
253
fi
254
# test if all custom rpms are correctly installed
2768 rexy 255
count_pkg=0; nb_pkg=0;
256
for pkg in `ls rpms/$ARCH/|sed 's/.x86_64.rpm//'`
257
do
258
	nb_pkg=`expr $nb_pkg + 1`
259
	if rpm -q --quiet $pkg ; then
260
		count_pkg=`expr $count_pkg + 1`
261
	else
262
		echo "error installing $pkg"
263
	fi
264
done
265
if [ $count_pkg -ne $nb_pkg ]
266
then
267
	exit 1
268
fi
2417 richard 269
exit 0