Subversion Repositories ALCASAR

Rev

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

Rev 1202 Rev 1377
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-watchdog.sh 1202 2013-09-02 16:05:07Z crox53 $
2
# $Id: alcasar-watchdog.sh 1377 2014-06-10 22:16:50Z richard $
3
 
3
 
4
# alcasar-watchdog.sh
4
# alcasar-watchdog.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
# Ce script prévient les usagers de l'indisponibilité de l'accès Internet
7
# Ce script prévient les usagers de l'indisponibilité de l'accès Internet
Line 11... Line 11...
11
# This script tells users that Internet access is down
11
# This script tells users that Internet access is down
12
# it logs out users whose 
12
# it logs out users whose 
13
# - PCs are quiet
13
# - PCs are quiet
14
# - MAC address is used by other systems (usurped)
14
# - MAC address is used by other systems (usurped)
15
 
15
 
16
EXTIF="eth0"
16
EXTIF="enp1s0"
17
INTIF="eth1"
17
INTIF="enp2s0"
18
conf_file="/usr/local/etc/alcasar.conf"
18
conf_file="/usr/local/etc/alcasar.conf"
19
private_ip_mask=`grep PRIVATE_IP= $conf_file|cut -d"=" -f2`
19
private_ip_mask=`grep PRIVATE_IP= $conf_file|cut -d"=" -f2`
20
private_ip_mask=${private_ip_mask:=192.168.182.1/24}
20
private_ip_mask=${private_ip_mask:=192.168.182.1/24}
21
PRIVATE_IP=`echo "$private_ip_mask" |cut -d"/" -f1`      # @ip du portail (côté LAN)
21
PRIVATE_IP=`echo "$private_ip_mask" |cut -d"/" -f1`      # @ip du portail (côté LAN)
22
PRIVATE_IP=${PRIVATE_IP:=192.168.182.1}
22
PRIVATE_IP=${PRIVATE_IP:=192.168.182.1}
Line 43... Line 43...
43
	esac
43
	esac
44
	net_pb=`cat /etc/dnsmasq.conf|grep "address=/#/"|wc -l`
44
	net_pb=`cat /etc/dnsmasq.conf|grep "address=/#/"|wc -l`
45
	if [ $net_pb = "0" ] # user alert
45
	if [ $net_pb = "0" ] # user alert
46
		then
46
		then
47
		/bin/sed -i "s?^\$network_pb.*?\$network_pb = True;?g" $Index_Page
47
		/bin/sed -i "s?^\$network_pb.*?\$network_pb = True;?g" $Index_Page
48
		/bin/sed -i "s?^conf-dir=.*?address=\/#\/$PRIVATE_IP?g" /etc/dnsmasq-blackhole.conf
48
		/bin/sed -i "s?^conf-dir=.*?address=\/#\/$PRIVATE_IP?g" /etc/dnsmasq-blacklist.conf
49
		/bin/sed -i "1i\address=\/#\/$PRIVATE_IP" /etc/dnsmasq.conf
49
		/bin/sed -i "1i\address=\/#\/$PRIVATE_IP" /etc/dnsmasq.conf
50
		/etc/init.d/dnsmasq restart
50
		/etc/init.d/dnsmasq restart
51
	fi
51
	fi
52
}
52
}
53
 
53
 
Line 85... Line 85...
85
		echo "Internet access is OK for now"
85
		echo "Internet access is OK for now"
86
		net_pb=`cat /etc/dnsmasq.conf|grep "address=/#/"|wc -l`
86
		net_pb=`cat /etc/dnsmasq.conf|grep "address=/#/"|wc -l`
87
		if [ $net_pb != "0" ]
87
		if [ $net_pb != "0" ]
88
			then
88
			then
89
			/bin/sed -i "s?^\$network_pb.*?\$network_pb = False;?g" $Index_Page
89
			/bin/sed -i "s?^\$network_pb.*?\$network_pb = False;?g" $Index_Page
90
			/bin/sed -i "s?^address=\/#\/.*?conf-dir=/usr/local/share/dnsmasq-bl-enabled?g" /etc/dnsmasq-blackhole.conf
90
			/bin/sed -i "s?^address=\/#\/.*?conf-dir=/usr/local/share/dnsmasq-bl-enabled?g" /etc/dnsmasq-blacklist.conf
91
			/bin/sed -i "/^address=/d" /etc/dnsmasq.conf
91
			/bin/sed -i "/^address=/d" /etc/dnsmasq.conf
92
			/etc/init.d/dnsmasq restart
92
			/etc/init.d/dnsmasq restart
93
		fi
93
		fi
94
	fi
94
	fi
95
}
95
}