User Tools

Site Tools


ppp.sh
#!/bin/bash

#SERVERS="62.4.16.36 feth1-0-thevenin.nerim.net www.nerim.net hsrp1-telehouse.nerim.net feth0-0-julo.nerim.net"
SERVERS2=irc.geeknode.org
STATUS_LINK=0

USER=`id -u`

if [ ! "$USER" = "0" ];
then
  echo "you're not root, you can't check adsl."
  exit
fi

if [ -f /var/run/checkadsl ]
then
  echo already running
  exit
fi

if ! /sbin/ifconfig ppp0 > /dev/null
then
  echo "No pppd running. Restarting NOW."
  killall pppd
  /etc/init.d/net.ppp0 restart  
  exit                          
fi                              
                                
touch /var/run/checkadsl        
                                
## recupere l'ip du peer        
ip=$(/sbin/ifconfig  ppp0 | /bin/grep "P-t-P" | /usr/bin/cut -d":" -f3 | /usr/bin/cut -d" " -f1)
SERVERS=$ip                     
                                
for i in $SERVERS;              
do                              
  ping -c 3 $i                  
#1>/dev/null 2>/dev/null        
  if [ "$?" = "0" ];            
  then                          
    STATUS_LINK=1               
    rm -f /var/run/checkadsl    
    echo "exit c est ok on passe au deuxieme test"
  exit 0                        
  fi                            
done                            
if [ "$STATUS_LINK" = "0" ];
then
  echo "ADSL Link DOWN. Restarting NOW."

  /etc/init.d/net.ppp0 restart
  rm -f /var/run/checkadsl
fi

rm -f /var/run/checkadsl
ppp.sh.txt · Last modified: 2018/06/18 11:07 (external edit)