Subversion Repositories ALCASAR

Rev

Rev 634 | Rev 637 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 634 Rev 636
Line 1... Line 1...
1
#!/bin/sh
1
#!/bin/sh
2
#  $Id: alcasar.sh 634 2011-06-13 17:23:46Z richard $ 
2
#  $Id: alcasar.sh 636 2011-06-15 22:29:07Z richard $ 
3
 
3
 
4
# alcasar.sh
4
# alcasar.sh
5
# by Franck BOUIJOUX, Pascal LEVANT and Richard REY
5
# by Franck BOUIJOUX, Pascal LEVANT and Richard REY
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
 
Line 265... Line 265...
265
## - Renseignement des fichiers hosts.allow et hosts.deny	##
265
## - Renseignement des fichiers hosts.allow et hosts.deny	##
266
##################################################################
266
##################################################################
267
network ()
267
network ()
268
{
268
{
269
	header_install
269
	header_install
-
 
270
	if [ "$mode" != "update" ]
-
 
271
		then
270
	if [ $Lang == "fr" ]
272
		if [ $Lang == "fr" ]
271
		then echo "Par défaut, l'adresse IP d'ALCASAR sur le réseau de consultation est : $DEFAULT_PRIVATE_IP_MASK"
273
			then echo "Par défaut, l'adresse IP d'ALCASAR sur le réseau de consultation est : $DEFAULT_PRIVATE_IP_MASK"
272
		else echo "The default ALCASAR IP address on consultation network is : $DEFAULT_PRIVATE_IP_MASK"
274
			else echo "The default ALCASAR IP address on consultation network is : $DEFAULT_PRIVATE_IP_MASK"
273
	fi
275
		fi
274
	response=0
276
		response=0
275
	PTN='^[oOyYnN]$'
277
		PTN='^[oOyYnN]$'
276
	until [[ $(expr $response : $PTN) -gt 0 ]]
278
		until [[ $(expr $response : $PTN) -gt 0 ]]
277
		do
279
		do
278
			if [ $Lang == "fr" ]
280
			if [ $Lang == "fr" ]
279
				then echo -n "Voulez-vous utiliser cette addresse et ce plan d'adressage (recommandé) (O/n)? : "
281
				then echo -n "Voulez-vous utiliser cette addresse et ce plan d'adressage (recommandé) (O/n)? : "
280
				else echo -n "Do you want to use this IP address and this IP addressing plan (recommanded) (Y/n)? : "
282
				else echo -n "Do you want to use this IP address and this IP addressing plan (recommanded) (Y/n)? : "
281
			fi
283
			fi
282
			read response
284
			read response
283
		done
285
		done
284
	if [ "$response" = "n" ] || [ "$response" = "N" ]
286
		if [ "$response" = "n" ] || [ "$response" = "N" ]
285
	then
287
		then
286
		PRIVATE_IP_MASK="0"
288
			PRIVATE_IP_MASK="0"
287
		PTN='^\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\).\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\).\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\).\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\)/[012]\?[[:digit:]]$'
289
			PTN='^\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\).\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\).\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\).\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\)/[012]\?[[:digit:]]$'
288
		until [[ $(expr $PRIVATE_IP_MASK : $PTN) -gt 0 ]]
290
			until [[ $(expr $PRIVATE_IP_MASK : $PTN) -gt 0 ]]
289
			do
291
			do
290
				if [ $Lang == "fr" ]
292
				if [ $Lang == "fr" ]
291
					then echo -n "Entrez l'adresse IP d'ALCASAR au format CIDR (a.b.c.d/xx) : "
293
					then echo -n "Entrez l'adresse IP d'ALCASAR au format CIDR (a.b.c.d/xx) : "
292
					else echo -n "Enter ALCASAR IP address in CIDR format (a.b.c.d/xx) : "
294
					else echo -n "Enter ALCASAR IP address in CIDR format (a.b.c.d/xx) : "
293
				fi
295
				fi
294
				read PRIVATE_IP_MASK
296
				read PRIVATE_IP_MASK
295
 
-
 
296
			done
297
			done
-
 
298
		else
-
 
299
       			PRIVATE_IP_MASK=$DEFAULT_PRIVATE_IP_MASK
-
 
300
		fi
297
	else
301
	else
298
       		PRIVATE_IP_MASK=$DEFAULT_PRIVATE_IP_MASK
302
		PRIVATE_IP_MASK=`grep PRIVATE_IP |cut -d"=" -f2` /tmp/conf/etc/alcasar.conf
299
	fi
303
	fi
300
# Définition de la config réseau côté "LAN de consultation"
304
# Définition de la config réseau côté "LAN de consultation"
301
	hostname $HOSTNAME
305
	hostname $HOSTNAME
302
	PRIVATE_NETWORK=`/bin/ipcalc -n $PRIVATE_IP_MASK | cut -d"=" -f2`			# @ réseau de consultation (ex.: 192.168.182.0)
306
	PRIVATE_NETWORK=`/bin/ipcalc -n $PRIVATE_IP_MASK | cut -d"=" -f2`			# @ réseau de consultation (ex.: 192.168.182.0)
303
	PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`			# masque réseau de consultation (ex.: 255.255.255.0)
307
	PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`			# masque réseau de consultation (ex.: 255.255.255.0)
Line 1381... Line 1385...
1381
if [ "$mode" = "update" ]
1385
if [ "$mode" = "update" ]
1382
then
1386
then
1383
	$DIR_DEST_BIN/alcasar-conf.sh --load
1387
	$DIR_DEST_BIN/alcasar-conf.sh --load
1384
	$SED "s?^INSTALL_DATE=.*?INSTALL_DATE=$DATE?g" $CONF_FILE
1388
	$SED "s?^INSTALL_DATE=.*?INSTALL_DATE=$DATE?g" $CONF_FILE
1385
	$SED "s?^VERSION=.*?VERSION=$VERSION?g" $CONF_FILE
1389
	$SED "s?^VERSION=.*?VERSION=$VERSION?g" $CONF_FILE
1386
	$SED "s?^ORGANISM=.*?ORGANISM=$ORGANISM?g" $CONF_FILE
-
 
1387
fi
1390
fi
1388
rm -f /tmp/alcasar-conf*
1391
rm -f /tmp/alcasar-conf*
1389
chown -R root:apache $DIR_DEST_ETC/*
1392
chown -R root:apache $DIR_DEST_ETC/*
1390
chmod -R 660 $DIR_DEST_ETC/*
1393
chmod -R 660 $DIR_DEST_ETC/*
1391
chmod ug+x $DIR_DEST_ETC/digest $DIR_DEST_ETC/alcasar-dnsfilter*
1394
chmod ug+x $DIR_DEST_ETC/digest $DIR_DEST_ETC/alcasar-dnsfilter*
Line 1458... Line 1461...
1458
			else
1461
			else
1459
				RUNNING_VERSION=`cat $DIR_WEB/VERSION|cut -d" " -f1`
1462
				RUNNING_VERSION=`cat $DIR_WEB/VERSION|cut -d" " -f1`
1460
				MAJ_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f1`
1463
				MAJ_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f1`
1461
				MIN_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f2|cut -c1`
1464
				MIN_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f2|cut -c1`
1462
				UPD_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f3`
1465
				UPD_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f3`
1463
# Create the conf file of the running version
1466
# Create a backup of running version importants files
1464
				chmod u+x $DIR_SCRIPTS/alcasar-conf.sh
1467
				chmod u+x $DIR_SCRIPTS/alcasar-conf.sh
1465
				$DIR_SCRIPTS/alcasar-conf.sh --create
1468
				$DIR_SCRIPTS/alcasar-conf.sh --create
1466
				mode="update"
1469
				mode="update"
1467
			fi
1470
			fi
1468
		fi
1471
		fi
Line 1475... Line 1478...
1475
		if [ -e $DIR_WEB/VERSION ]
1478
		if [ -e $DIR_WEB/VERSION ]
1476
		then
1479
		then
1477
# Uninstall the running version
1480
# Uninstall the running version
1478
			$DIR_SCRIPTS/sbin/alcasar-uninstall.sh
1481
			$DIR_SCRIPTS/sbin/alcasar-uninstall.sh
1479
		fi
1482
		fi
-
 
1483
# Test if manual update	
1480
		if [ -e /tmp/alcasar-conf.tar.gz ] && [ "$mode" != "update" ]
1484
		if [ -e /tmp/alcasar-conf.tar.gz ] && [ "$mode" != "update" ]
1481
		then
1485
		then
-
 
1486
			header_install
1482
			if [ $Lang == "fr" ]
1487
			if [ $Lang == "fr" ]
1483
				then echo -n "Le fichier de configuration d'une ancienne version a été trouvé";
1488
				then echo "Le fichier de configuration d'une ancienne version a été trouvé";
1484
				else echo -n "The configuration file of an old version has been found";
1489
				else echo "The configuration file of an old version has been found";
1485
			fi
1490
			fi
1486
			response=0
1491
			response=0
1487
			PTN='^[oOnNyY]$'
1492
			PTN='^[oOnNyY]$'
1488
			until [[ $(expr $response : $PTN) -gt 0 ]]
1493
			until [[ $(expr $response : $PTN) -gt 0 ]]
1489
			do
1494
			do
Line 1495... Line 1500...
1495
				if [ "$response" = "n" ] || [ "$response" = "N" ] 
1500
				if [ "$response" = "n" ] || [ "$response" = "N" ] 
1496
				then rm -f /tmp/alcasar-conf*
1501
				then rm -f /tmp/alcasar-conf*
1497
				fi
1502
				fi
1498
			done
1503
			done
1499
		fi
1504
		fi
-
 
1505
# Test if update
1500
		if [ -e /tmp/alcasar-conf.tar.gz ] 
1506
		if [ -e /tmp/alcasar-conf.tar.gz ] 
1501
		then
1507
		then
1502
			if [ $Lang == "fr" ]
1508
			if [ $Lang == "fr" ]
1503
				then echo "#### Installation avec mise à jour ####";
1509
				then echo "#### Installation avec mise à jour ####";
1504
				else echo "#### Installation with update     ####";
1510
				else echo "#### Installation with update     ####";
1505
			fi
1511
			fi
1506
# Read the organism name from the conf file
1512
# Extract the central configuration file
1507
			tar -xvf /tmp/alcasar-conf.tar.gz conf/organisme 
1513
			tar -xvf /tmp/alcasar-conf.tar.gz conf/etc/alcasar.conf -C /tmp
1508
			ORGANISME=`cat $DIR_CONF/organisme`
1514
			ORGANISME=`cat /tmp/conf/etc/alcasar.conf|grep ORGANISM|cut -d"=" -f2`
1509
			mode="update"
1515
			mode="update"
1510
		else
1516
		else
1511
			mode="install"
1517
			mode="install"
1512
		fi
1518
		fi
1513
		for func in init network gestion AC init_db param_radius param_web_radius param_chilli param_squid param_dansguardian antivirus param_ulogd param_awstats param_dnsmasq BL cron post_install
1519
		for func in init network gestion AC init_db param_radius param_web_radius param_chilli param_squid param_dansguardian antivirus param_ulogd param_awstats param_dnsmasq BL cron post_install