Subversion Repositories ALCASAR

Rev

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

Rev 2830 Rev 2841
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-watchdog.sh 2830 2020-06-04 20:02:48Z rexy $
2
# $Id: alcasar-watchdog.sh 2841 2020-06-28 21:49:00Z rexy $
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 17... Line 17...
17
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2`			# INTernal InterFace
17
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2`			# INTernal InterFace
18
private_ip_mask=`grep ^PRIVATE_IP= $CONF_FILE|cut -d"=" -f2`
18
private_ip_mask=`grep ^PRIVATE_IP= $CONF_FILE|cut -d"=" -f2`
19
private_ip_mask=${private_ip_mask:=192.168.182.1/24}
19
private_ip_mask=${private_ip_mask:=192.168.182.1/24}
20
PRIVATE_IP=`echo "$private_ip_mask" |cut -d"/" -f1`		# @ip du portail (côté LAN)
20
PRIVATE_IP=`echo "$private_ip_mask" |cut -d"/" -f1`		# @ip du portail (côté LAN)
21
PRIVATE_IP=${PRIVATE_IP:=192.168.182.1}
21
PRIVATE_IP=${PRIVATE_IP:=192.168.182.1}
22
current_users_file="/var/tmp/havp/current_users.txt"		# file containing active users with their "status.php" tab open
22
current_users_file="/tmp/current_users.txt"		# file containing active users with their "status.php" tab open
23
DIR_WEB="/var/www/html"
23
DIR_WEB="/var/www/html"
24
Index_Page="$DIR_WEB/index.php"
24
Index_Page="$DIR_WEB/index.php"
25
IPTABLES="/sbin/iptables"
25
IPTABLES="/sbin/iptables"
26
TUNIF="tun0"							# listen device for chilli daemon
26
TUNIF="tun0"							# listen device for chilli daemon
27
OLDIFS=$IFS
27
OLDIFS=$IFS
Line 130... Line 130...
130
					elif [ "$cmp_user_ok" == "TEMP" ]; then
130
					elif [ "$cmp_user_ok" == "TEMP" ]; then
131
						# Remove the user's IP from 'current_users.txt'. Every user need to insert their @IP everytime to prove their connectivity.
131
						# Remove the user's IP from 'current_users.txt'. Every user need to insert their @IP everytime to prove their connectivity.
132
						sed -i "/^$active_ip:$cmp_user_ok\$/d" $current_users_file
132
						sed -i "/^$active_ip:$cmp_user_ok\$/d" $current_users_file
133
					fi
133
					fi
134
				else # "current_user.txt" does not exists. We disconnect every users.
134
				else # "current_user.txt" does not exists. We disconnect every users.
135
					logger -t alcasar-watchdog "The file /var/tmp/havp/current_users.txt doen't' exist. We disconnects the user $active_user"
135
					logger -t alcasar-watchdog "The file /tmp/current_users.txt doesn't' exist. We disconnects the user $active_user"
136
					/usr/sbin/chilli_query logout $active_mac
136
					/usr/sbin/chilli_query logout $active_mac
137
				fi
137
				fi
138
			fi
138
			fi
139
			# IP usurpation test : process only equipment with an authenticated user
139
			# IP usurpation test : process only equipment with an authenticated user
140
			if [[ $(expr $active_session) -eq 1 ]]
140
			if [[ $(expr $active_session) -eq 1 ]]