Line 1... |
Line 1... |
1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
2 |
# $Id: alcasar-watchdog.sh 1377 2014-06-10 22:16:50Z richard $
|
2 |
# $Id: alcasar-watchdog.sh 1469 2014-10-30 21:58:47Z 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 11... |
Line 11... |
11 |
# This script tells users that Internet access is down
|
11 |
# This script tells users that Internet access is down
|
12 |
# it logs out users whose
|
12 |
# it logs out users whose
|
13 |
# - PCs are quiet
|
13 |
# - PCs are quiet
|
14 |
# - MAC address is used by other systems (usurped)
|
14 |
# - MAC address is used by other systems (usurped)
|
15 |
|
15 |
|
16 |
EXTIF="enp1s0"
|
- |
|
17 |
INTIF="enp2s0"
|
- |
|
18 |
conf_file="/usr/local/etc/alcasar.conf"
|
16 |
CONF_FILE="/usr/local/etc/alcasar.conf"
|
- |
|
17 |
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2` # EXTernal InterFace
|
- |
|
18 |
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace
|
19 |
private_ip_mask=`grep PRIVATE_IP= $conf_file|cut -d"=" -f2`
|
19 |
private_ip_mask=`grep PRIVATE_IP= $CONF_FILE|cut -d"=" -f2`
|
20 |
private_ip_mask=${private_ip_mask:=192.168.182.1/24}
|
20 |
private_ip_mask=${private_ip_mask:=192.168.182.1/24}
|
21 |
PRIVATE_IP=`echo "$private_ip_mask" |cut -d"/" -f1` # @ip du portail (côté LAN)
|
21 |
PRIVATE_IP=`echo "$private_ip_mask" |cut -d"/" -f1` # @ip du portail (côté LAN)
|
22 |
PRIVATE_IP=${PRIVATE_IP:=192.168.182.1}
|
22 |
PRIVATE_IP=${PRIVATE_IP:=192.168.182.1}
|
23 |
tmp_file="/tmp/watchdog.txt"
|
23 |
tmp_file="/tmp/watchdog.txt"
|
24 |
DIR_WEB="/var/www/html"
|
24 |
DIR_WEB="/var/www/html"
|
Line 29... |
Line 29... |
29 |
function lan_down_alert ()
|
29 |
function lan_down_alert ()
|
30 |
# users are redirected on ALCASAR IP address if a LAN problem is detected
|
30 |
# users are redirected on ALCASAR IP address if a LAN problem is detected
|
31 |
{
|
31 |
{
|
32 |
case $LAN_DOWN in
|
32 |
case $LAN_DOWN in
|
33 |
"1")
|
33 |
"1")
|
34 |
logger "eth0 link down"
|
34 |
logger "$EXTIF (WAN card) link down"
|
35 |
echo "eth0 is down"
|
35 |
echo "$EXTIF (WAN card) is down"
|
36 |
/bin/sed -i "s?diagnostic =.*?diagnostic = \"eth0 link down\";?g" $Index_Page
|
36 |
/bin/sed -i "s?diagnostic =.*?diagnostic = \"$EXTIF (WAN card) link down\";?g" $Index_Page
|
37 |
;;
|
37 |
;;
|
38 |
"2")
|
38 |
"2")
|
39 |
logger "can't contact the default router"
|
39 |
logger "can't contact the default router"
|
40 |
echo "can't contact the default router"
|
40 |
echo "can't contact the default router"
|
41 |
/bin/sed -i "s?diagnostic =.*?diagnostic = \"can't contact the default router\";?g" $Index_Page
|
41 |
/bin/sed -i "s?diagnostic =.*?diagnostic = \"can't contact the default router\";?g" $Index_Page
|