#!/bin/sh

#network_status="$(ping 8.8.8.8)"

#var=23

#case $var in
#  *12*) echo "match";;
#     *) echo "no match";;
#esac

#if echo $var | grep -q "12"
#then
#  echo "match"
#else
#   echo "no match"
#fi

if ! ping -q -c 3 -W 1 8.8.8.8>/dev/null 
then
#  offline; check if redirect is already there 

   if ! grep -q address=/#/10.7.0.10 /etc/dnsmasq.d/lime-proto-anygw-10-ipv4.conf
   then
      echo "address=/#/10.7.0.10">> /etc/dnsmasq.d/lime-proto-anygw-10-ipv4.conf 
      echo "added line"
      /etc/init.d/dnsmasq restart
   fi
else
#if online, delete that line in case it is there 
   if sed -i '\|address=/#/10.7.0.10|d' /etc/dnsmasq.d/lime-proto-anygw-10-ipv4.conf 
   then 
      /etc/init.d/dnsmasq restart
   fi
   echo "tried to delete line"
fi




#echo $dns_status
