Subversion Repositories ALCASAR

Rev

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

Rev 1053 Rev 1054
Line 1... Line 1...
1
#/bin/bash
1
#/bin/bash
2
# $Id: alcasar-conf.sh 1053 2013-03-24 22:52:52Z richard $
2
# $Id: alcasar-conf.sh 1054 2013-03-25 20:00:53Z franck $
3
 
3
 
4
# alcasar-conf.sh
4
# alcasar-conf.sh
5
# by REXY
5
# by 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
 
Line 282... Line 282...
282
# Effacement du répertoire d'update
282
# Effacement du répertoire d'update
283
		rm -rf $DIR_UPDATE
283
		rm -rf $DIR_UPDATE
284
		;;
284
		;;
285
	--apply|-apply)
285
	--apply|-apply)
286
		PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/([012]?[0-9]|3[0-2])\b"
286
		PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/([012]?[0-9]|3[0-2])\b"
287
		PRIVATE_IP_MASK=`grep PRIVATE_IP $CONF_FILE|cut -d"=" -f2`
287
		PRIVATE_IP_MASK=`grep ^PRIVATE_IP $CONF_FILE|cut -d"=" -f2`
288
		check=$(echo $PRIVATE_IP_MASK | egrep $PTN)
288
		check=$(echo $PRIVATE_IP_MASK | egrep $PTN)
289
		if [[ "$?" -ne 0 ]]
289
		if [[ "$?" -ne 0 ]]
290
		then 
290
		then 
291
			echo "Syntax error for PRIVATE_IP_MASK ($PRIVATE_IP_MASK)"
291
			echo "Syntax error for PRIVATE_IP_MASK ($PRIVATE_IP_MASK)"
292
			exit 0
292
			exit 0
293
		fi
293
		fi
294
		PUBLIC_IP_MASK=`grep PUBLIC_IP $CONF_FILE|cut -d"=" -f2`
294
		PUBLIC_IP_MASK=`grep ^PUBLIC_IP $CONF_FILE|cut -d"=" -f2`
295
		check=$(echo $PUBLIC_IP_MASK | egrep $PTN)
295
		check=$(echo $PUBLIC_IP_MASK | egrep $PTN)
296
		if [[ "$?" -ne 0 ]]
296
		if [[ "$?" -ne 0 ]]
297
		then 
297
		then 
298
			echo "Syntax error for PUBLIC_IP_MASK ($PUBLIC_IP_MASK)"
298
			echo "Syntax error for PUBLIC_IP_MASK ($PUBLIC_IP_MASK)"
299
			exit 0
299
			exit 0
300
		fi
300
		fi
301
		PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
301
		PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
302
		PUBLIC_GATEWAY=`grep GW $CONF_FILE|cut -d"=" -f2`
302
		PUBLIC_GATEWAY=`grep ^GW $CONF_FILE|cut -d"=" -f2`
303
		check=$(echo $PUBLIC_GATEWAY | egrep $PTN)
303
		check=$(echo $PUBLIC_GATEWAY | egrep $PTN)
304
		if [[ "$?" -ne 0 ]]
304
		if [[ "$?" -ne 0 ]]
305
			then 
305
			then 
306
			echo "Syntax error for the Gateway IP ($PUBLIC_GATEWAY)"
306
			echo "Syntax error for the Gateway IP ($PUBLIC_GATEWAY)"
307
			exit 0
307
			exit 0
308
		fi
308
		fi
309
		DNS1=`grep DNS1 $CONF_FILE|cut -d"=" -f2`
309
		DNS1=`grep ^DNS1 $CONF_FILE|cut -d"=" -f2`
310
		check=$(echo $DNS1 | egrep $PTN)
310
		check=$(echo $DNS1 | egrep $PTN)
311
		if [[ "$?" -ne 0 ]]
311
		if [[ "$?" -ne 0 ]]
312
		then 
312
		then 
313
			echo "Syntax error for the IP address of the first DNS server ($DNS1)"
313
			echo "Syntax error for the IP address of the first DNS server ($DNS1)"
314
			exit 0
314
			exit 0
315
		fi
315
		fi
316
		DNS2=`grep DNS2 $CONF_FILE|cut -d"=" -f2`
316
		DNS2=`grep ^DNS2 $CONF_FILE|cut -d"=" -f2`
317
		check=$(echo $DNS2 | egrep $PTN)
317
		check=$(echo $DNS2 | egrep $PTN)
318
		if [[ "$?" -ne 0 ]]
318
		if [[ "$?" -ne 0 ]]
319
		then 
319
		then 
320
			echo "Syntax error for the IP address of the second DNS server ($DNS2)"
320
			echo "Syntax error for the IP address of the second DNS server ($DNS2)"
321
			exit 0
321
			exit 0
Line 386... Line 386...
386
		do
386
		do
387
			$SED "/^server=/d" $i
387
			$SED "/^server=/d" $i
388
			echo "server=$DNS1" >> $i
388
			echo "server=$DNS1" >> $i
389
			echo "server=$DNS2" >> $i
389
			echo "server=$DNS2" >> $i
390
		done
390
		done
391
		$SED "s?^dhcp-range=.*?dhcp-range=$PRIVATE_IP,192.168.180.254,$PRIVATE_NETMASK,12h?g" /etc/dnsmasq.conf
391
		$SED "s?^dhcp-range=.*?dhcp-range=$PRIVATE_IP,192.168.182.254,$PRIVATE_NETMASK,12h?g" /etc/dnsmasq.conf
392
		$SED "s?^dhcp-option=option:router.*?dhcp-option=option:router,$PRIVATE_IP?g" /etc/dnsmasq.conf
392
		$SED "s?^dhcp-option=option:router.*?dhcp-option=option:router,$PRIVATE_IP?g" /etc/dnsmasq.conf
393
# DG + BL
393
# DG + BL
394
		$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" /etc/dansguardian/dansguardian.conf
394
		$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" /etc/dansguardian/dansguardian.conf
395
# Watchdog
395
# Watchdog
396
		$SED "s?^PRIVATE_IP=.*?PRIVATE_IP=\"$PRIVATE_IP\"?g" $DIR_BIN/alcasar-watchdog.sh
396
		$SED "s?^PRIVATE_IP=.*?PRIVATE_IP=\"$PRIVATE_IP\"?g" $DIR_BIN/alcasar-watchdog.sh