Line 1... |
Line 1... |
1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
2 |
# $Id: alcasar-watchdog.sh 2108 2017-01-06 08:50:25Z richard $
|
2 |
# $Id: alcasar-watchdog.sh 2113 2017-01-08 22:43:26Z 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 112... |
Line 112... |
112 |
active_mac=`echo $system | cut -d" " -f1`
|
112 |
active_mac=`echo $system | cut -d" " -f1`
|
113 |
active_user=`echo $system |cut -d" " -f6`
|
113 |
active_user=`echo $system |cut -d" " -f6`
|
114 |
#We disconnect inactive user here :
|
114 |
#We disconnect inactive user here :
|
115 |
#We check if this is not an auth @MAC and if he is still connected
|
115 |
#We check if this is not an auth @MAC and if he is still connected
|
116 |
if [ "$active_user" != "$active_mac" ] && [ $(expr $active_session) -eq 1 ]; then
|
116 |
if [ "$active_user" != "$active_mac" ] && [ $(expr $active_session) -eq 1 ]; then
|
117 |
# If /tmp/current_user.txt exists ...
|
- |
|
118 |
if [ -e $current_users_file ]; then
|
117 |
if [ -e $current_users_file ]; then
|
119 |
# We check if user @IP is in 'current_users.txt'
|
118 |
# We check if user @IP is in 'current_users.txt'
|
120 |
cmp_user_ok=$(cat $current_users_file | grep $active_ip | wc -w)
|
119 |
cmp_user_ok=$(cat $current_users_file | grep $active_ip | wc -w)
|
121 |
# If not we disconnect this user.
|
120 |
# If not we disconnect this user.
|
122 |
if [ $cmp_user_ok -eq 0 ]; then
|
121 |
if [ $cmp_user_ok -eq 0 ]; then
|
123 |
logger "alcasar-watchdog $active_ip ($active_mac) can't be contact. Alcasar disconnects the user ($active_user)."
|
122 |
logger "alcasar-watchdog : $active_ip ($active_mac) can't be contact. We disconnects the user ($active_user)."
|
124 |
/usr/sbin/chilli_query logout $active_mac
|
123 |
/usr/sbin/chilli_query logout $active_mac
|
125 |
fi
|
124 |
fi
|
126 |
# Remove the user's IP from 'current_users.txt'. Every user need to insert their @IP everytime to prove their connectivity.
|
125 |
# Remove the user's IP from 'current_users.txt'. Every user need to insert their @IP everytime to prove their connectivity.
|
127 |
sed -i "/^$active_ip/d" $current_users_file
|
126 |
sed -i "/^$active_ip/d" $current_users_file
|
128 |
else # "/tmp/current_user.txt" does not exists. We disconnect every users.
|
127 |
else # "/tmp/current_user.txt" does not exists. We disconnect every users.
|
129 |
logger "Le fichier /tmp/current_users.txt n'existe pas."
|
- |
|
130 |
logger "alcasar-watchdog $active_ip ($active_mac) can't be contact. Alcasar disconnects the user ($active_user)."
|
128 |
logger "alcasar-watchdog : The file /var/tmp/havp/current_users.txt doen't' exist. We disconnects the user $active_user"
|
131 |
/usr/sbin/chilli_query logout $active_mac
|
129 |
/usr/sbin/chilli_query logout $active_mac
|
132 |
fi
|
130 |
fi
|
133 |
fi
|
131 |
fi
|
134 |
# IP usurpation test : process only equipment with an authenticated user
|
132 |
# IP usurpation test : process only equipment with an authenticated user
|
135 |
if [[ $(expr $active_session) -eq 1 ]]
|
133 |
if [[ $(expr $active_session) -eq 1 ]]
|