Line 1... |
Line 1... |
1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
2 |
# $Id: alcasar-watchdog.sh 2871 2020-10-28 18:17:44Z rexy $
|
2 |
# $Id: alcasar-watchdog.sh 2883 2020-11-15 21:14:52Z 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 140... |
Line 140... |
140 |
if [ -e $current_users_file ]; then
|
140 |
if [ -e $current_users_file ]; then
|
141 |
# We check if user @IP is in 'current_users.txt'
|
141 |
# 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}")
|
142 |
cmp_user_ok=$(cat $current_users_file | awk -F':' "\$1 == \"$active_ip\" {print \$2}")
|
143 |
# If not we disconnect this user.
|
143 |
# If not we disconnect this user.
|
144 |
if [ -z "$cmp_user_ok" ]; then
|
144 |
if [ -z "$cmp_user_ok" ]; then
|
145 |
logger -t alcasar-watchdog "$active_ip ($active_mac) can't be contact. We disconnects the user ($active_user)."
|
145 |
logger -t alcasar-watchdog "$active_ip ($active_mac) doesn't contact ALCASAR any more. We disconnects the user ($active_user)."
|
146 |
/usr/sbin/chilli_query logout $active_mac
|
146 |
/usr/sbin/chilli_query logout $active_mac
|
147 |
elif [ "$cmp_user_ok" == "TEMP" ]; then
|
147 |
elif [ "$cmp_user_ok" == "TEMP" ]; then
|
148 |
# Remove the user's IP from 'current_users.txt'. Every user need to insert their @IP everytime to prove their connectivity.
|
148 |
# Remove the user's IP from 'current_users.txt'. Every user status page need to insert their @IP everytime to prove their connectivity.
|
- |
|
149 |
# We don't disconnect when $cmp_user_ok == "PERM" (status page not needed)
|
149 |
sed -i "/^$active_ip:$cmp_user_ok\$/d" $current_users_file
|
150 |
sed -i "/^$active_ip:$cmp_user_ok\$/d" $current_users_file
|
150 |
fi
|
151 |
fi
|
151 |
else # "current_user.txt" does not exists. We disconnect every users.
|
152 |
else # "current_user.txt" does not exists. We disconnect every users.
|
152 |
logger -t alcasar-watchdog "The file /tmp/current_users.txt doesn't' exist. We disconnects the user $active_user"
|
153 |
logger -t alcasar-watchdog "The file /tmp/current_users.txt doesn't' exist. We disconnects the user $active_user"
|
153 |
/usr/sbin/chilli_query logout $active_mac
|
154 |
/usr/sbin/chilli_query logout $active_mac
|