Line 1... |
Line 1... |
1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
2 |
# $Id: alcasar-watchdog.sh 2884 2020-11-16 22:12:53Z rexy $
|
2 |
# $Id: alcasar-watchdog.sh 2886 2020-11-23 22:50:01Z 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 122... |
Line 122... |
122 |
;;
|
122 |
;;
|
123 |
-lt | --lan_test)
|
123 |
-lt | --lan_test)
|
124 |
lan_test
|
124 |
lan_test
|
125 |
exit 0
|
125 |
exit 0
|
126 |
;;
|
126 |
;;
|
- |
|
127 |
--disconnect-permanent-users)
|
- |
|
128 |
/bin/sed -i '/PERM/d' $current_users_file
|
- |
|
129 |
exit 0
|
- |
|
130 |
;;
|
127 |
*)
|
131 |
*)
|
128 |
lan_test
|
132 |
lan_test
|
129 |
# We disconnect inactive users (its means that their 'status.php' tab has been closed --> their ip address isn't in $current_users_file)
|
133 |
# We disconnect inactive users (its means that their 'status.php' tab has been closed --> their ip address isn't in $current_users_file)
|
130 |
# process each equipment known by chilli to check if IP address is usurped (with arping)
|
134 |
# process each equipment known by chilli
|
131 |
for system in `/usr/sbin/chilli_query list | grep -v "0\.0\.0\.0"`
|
135 |
for system in `/usr/sbin/chilli_query list | grep -v "0\.0\.0\.0"`
|
132 |
do
|
136 |
do
|
133 |
active_ip=`echo $system |cut -d" " -f2`
|
137 |
active_ip=`echo $system |cut -d" " -f2`
|
134 |
active_session=`echo $system |cut -d" " -f5`
|
138 |
active_session=`echo $system |cut -d" " -f5`
|
135 |
active_mac=`echo $system | cut -d" " -f1`
|
139 |
active_mac=`echo $system | cut -d" " -f1`
|
136 |
active_user=`echo $system |cut -d" " -f6`
|
140 |
active_user=`echo $system |cut -d" " -f6`
|
137 |
# We disconnect inactive user here :
|
- |
|
138 |
# We check if the user isn't an auth @MAC and if he is still connected
|
141 |
# We check if the user isn't an auth @MAC and if he is still connected
|
139 |
if [ "$active_user" != "$active_mac" ] && [ $(expr $active_session) -eq 1 ]; then
|
142 |
if [ "$active_user" != "$active_mac" ] && [ $(expr $active_session) -eq 1 ]; then
|
140 |
if [ -e $current_users_file ]; then
|
143 |
if [ -e $current_users_file ]; then
|
141 |
# We check if user @IP is in 'current_users.txt'
|
144 |
# We check if user @IP is in 'current_users.txt'
|
142 |
cmp_user_ok=$(cat $current_users_file | awk -F':' "\$1 == \"$active_ip\" {print \$2}")
|
145 |
cmp_user_ok=$(cat $current_users_file | awk -F':' "\$1 == \"$active_ip\" {print \$2}")
|