Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 1471 → Rev 1472

/scripts/alcasar-watchdog.sh
23,6 → 23,8
tmp_file="/tmp/watchdog.txt"
DIR_WEB="/var/www/html"
Index_Page="$DIR_WEB/index.php"
IPTABLES="/sbin/iptables"
TUNIF="tun0" # listen device for chilli daemon
OLDIFS=$IFS
IFS=$'\n'
 
41,13 → 43,11
/bin/sed -i "s?diagnostic =.*?diagnostic = \"can't contact the default router\";?g" $Index_Page
;;
esac
net_pb=`cat /etc/dnsmasq.conf|grep "address=/#/"|wc -l`
if [ $net_pb = "0" ] # user alert
net_pb=`grep "network_pb = True;" $Index_Page|wc -l`
if [ $net_pb = "0" ] # user alert (only the first time)
then
/bin/sed -i "s?^\$network_pb.*?\$network_pb = True;?g" $Index_Page
/bin/sed -i "s?^conf-dir=.*?address=\/#\/$PRIVATE_IP?g" /etc/dnsmasq-blacklist.conf
/bin/sed -i "1i\address=\/#\/$PRIVATE_IP" /etc/dnsmasq.conf
/etc/init.d/dnsmasq restart
$IPTABLES -I PREROUTING -t nat -i $TUNIF -p udp --dport domain -j REDIRECT --to-port 56
fi
}
 
62,7 → 62,7
fi
# EXTIF testing
LAN_DOWN="0"
if [ "`/usr/sbin/ethtool $EXTIF|grep Link|cut -d' ' -f3`" != "yes" ] && [ "`/sbin/mii-tool $EXTIF | grep -i link | awk '{print $NF}'`" != "ok" ]
if [ `/sbin/ip link | grep $EXTIF|grep "NO-CARRIER" | wc -l` -eq "1" ]
then
LAN_DOWN="1"
fi
83,13 → 83,11
# else switch in normal mode
else
echo "Internet access is OK for now"
net_pb=`cat /etc/dnsmasq.conf|grep "address=/#/"|wc -l`
net_pb=`grep "network_pb = True;" $Index_Page|wc -l`
if [ $net_pb != "0" ]
then
/bin/sed -i "s?^\$network_pb.*?\$network_pb = False;?g" $Index_Page
/bin/sed -i "s?^address=\/#\/.*?conf-dir=/usr/local/share/dnsmasq-bl-enabled?g" /etc/dnsmasq-blacklist.conf
/bin/sed -i "/^address=/d" /etc/dnsmasq.conf
/etc/init.d/dnsmasq restart
$IPTABLES -D PREROUTING -t nat -i $TUNIF -p udp --dport domain -j REDIRECT --to-port 56
fi
fi
}