Subversion Repositories ALCASAR

Rev

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

Rev 784 Rev 786
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-watchdog.sh 784 2011-12-18 14:33:56Z richard $
2
# $Id: alcasar-watchdog.sh 786 2012-01-02 22:50:31Z richard $
3
 
3
 
4
# alcasar-watchdog.sh
4
# alcasar-watchdog.sh
5
# by Richard REY
5
# by 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 14... Line 14...
14
# - PCs are quiet
14
# - PCs are quiet
15
# - MAC address are in used by other systems (usurped)
15
# - MAC address are in used by other systems (usurped)
16
 
16
 
17
EXTIF="eth0"
17
EXTIF="eth0"
18
INTIF="eth1"
18
INTIF="eth1"
-
 
19
macallowed_file="/usr/local/etc/alcasar-macallowed"
-
 
20
conf_file="/usr/local/etc/alcasar.conf"
-
 
21
private_ip_mask=`grep PRIVATE_IP= $conf_file|cut -d"=" -f2`
19
PRIVATE_IP="192.168.182.1"
22
private_ip_mask=${private_ip_mask:=192.168.182.1/24}
-
 
23
PRIVATE_IP=`echo $private_ip_mask | cut -d"/" -f1`			# ALCASAR LAN IP address
20
tmp_file="/tmp/watchdog.txt"
24
tmp_file="/tmp/watchdog.txt"
21
DIR_WEB="/var/www/html"
25
DIR_WEB="/var/www/html"
22
Index_Page="$DIR_WEB/index.php"
26
Index_Page="$DIR_WEB/index.php"
23
OLDIFS=$IFS
27
OLDIFS=$IFS
24
IFS=$'\n'
28
IFS=$'\n'
Line 107... Line 111...
107
				noresponse_ip=`echo $noresponse | cut -d" " -f1`
111
				noresponse_ip=`echo $noresponse | cut -d" " -f1`
108
				noresponse_mac=`echo $noresponse | cut -d" " -f2`
112
				noresponse_mac=`echo $noresponse | cut -d" " -f2`
109
				arp_reply=`/usr/sbin/arping -b -I$INTIF -s$PRIVATE_IP -c1 -w4 $noresponse_ip|grep response|cut -d" " -f2`
113
				arp_reply=`/usr/sbin/arping -b -I$INTIF -s$PRIVATE_IP -c1 -w4 $noresponse_ip|grep response|cut -d" " -f2`
110
				if [[ $(expr $arp_reply) -eq 0 ]]
114
				if [[ $(expr $arp_reply) -eq 0 ]]
111
	       				then
115
	       				then
-
 
116
					mac_allowed=`cat $macallowed_file |grep $noresponse_mac | wc -l`
-
 
117
					if [ $mac_allowed -eq 0 ]
-
 
118
						then
112
					logger "alcasar-watchdog $noresponse_ip ($noresponse_mac) can't be contact. Alcasar disconnects the user."
119
						logger "alcasar-watchdog $noresponse_ip ($noresponse_mac) can't be contact. Alcasar disconnects the user."
113
					/usr/sbin/chilli_query logout $noresponse_mac
120
						/usr/sbin/chilli_query logout $noresponse_mac
-
 
121
					else
-
 
122
						logger "alcasar-watchdog $noresponse_ip ($noresponse_mac - macallowed) can't be contact. Alcasar release the IP address"
-
 
123
						/usr/sbin/chilli_query dhcp-release $noresponse_mac
-
 
124
					fi
114
				fi
125
				fi
115
			done
126
			done
116
			rm $tmp_file
127
			rm $tmp_file
117
		fi
128
		fi
118
# on traite chaque équipements connus de chilli
129
# on traite chaque équipements connus de chilli