Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2376 → Rev 2394

/scripts/alcasar-watchdog.sh
105,25 → 105,25
lan_test
# We disconnect inactive users (its means that their 'status.php' tab has been closed --> their ip address isn't in $current_users_file)
# process each equipment known by chilli to check if IP address is usurped (with arping)
for system in `/usr/sbin/chilli_query list |grep -v "\.0\.0\.0"`
for system in `/usr/sbin/chilli_query list | grep -v "0\.0\.0\.0"`
do
active_ip=`echo $system |cut -d" " -f2`
active_session=`echo $system |cut -d" " -f5`
active_mac=`echo $system | cut -d" " -f1`
active_user=`echo $system |cut -d" " -f6`
#We disconnect inactive user here :
#We check if this is not an auth @MAC and if he is still connected
# We disconnect inactive user here :
# We check if this is not an auth @MAC and if he is still connected
if [ "$active_user" != "$active_mac" ] && [ $(expr $active_session) -eq 1 ]; then
if [ -e $current_users_file ]; then
# We check if user @IP is in 'current_users.txt'
cmp_user_ok=$(cat $current_users_file | grep "^$active_ip\$" -c)
cmp_user_ok=$(cat $current_users_file | awk -F':' "\$1 == \"$active_ip\" {print \$2}")
# If not we disconnect this user.
if [ $cmp_user_ok -eq 0 ]; then
if [ -z "$cmp_user_ok" ]; then
logger "alcasar-watchdog : $active_ip ($active_mac) can't be contact. We disconnects the user ($active_user)."
/usr/sbin/chilli_query logout $active_mac
else
elif [ "$cmp_user_ok" == "TEMP" ]; then
# Remove the user's IP from 'current_users.txt'. Every user need to insert their @IP everytime to prove their connectivity.
sed -i "/^$active_ip\$/d" $current_users_file
sed -i "/^$active_ip:$cmp_user_ok\$/d" $current_users_file
fi
else # "current_user.txt" does not exists. We disconnect every users.
logger "alcasar-watchdog : The file /var/tmp/havp/current_users.txt doen't' exist. We disconnects the user $active_user"