[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: adsl keep alive script



Hi,
Here is my script seems to work for month...
Change the YOUR_ISV to the name of your ISV'S DNS or mail server
and yourname@IYOUR_ISV to

And Yes there is an "l" between the @ and YOUR_ISV when invoking pptp

Also do not forget to make sure the cleaning person is not hooking up the
vacum instead of your moedm once in a while. :)
Ghiora


#*******************************************************************************************
#!/bin/bash

while [ 1 ]
do
    # This returns 1 if not connected !!
    ping -c 3 YOURISV.co.il  >>/dev/null 2>&1
    if [ $? != 0 ]
    then
        date >>/tmp/dial_log 2>&1   
        echo "Attempting to connect " >>/tmp/dial_log
        #eliminate the pptp process
        ELIM=`ps -eaf |grep pptp |grep -v grep |tail -n1 |awk '{ print 
$2 }'`
        kill -9 $ELIM
        #lower and raise th0 to clear the connections to the modem
        /sbin/ifconfig eth0 down
        /sbin/ifconfig eth0 up
        #remove a bsocket left by pptp (a bug)
        rm -f /var/run/pptp/10.0.0.138
        # run pptp
        /usr/sbin/pptp 10.0.0.138  user yourname@IYOURUSV remotename 
"10.0.0.138 RELAY_PPP1"  defaultroute netmask 255.0.0.0 mtu 1500 mru 
1500 noauth >/dev/null 2>&1 &
        /etc/firewall
        if [ -f /var/run/named.pid ]
                then
             ps -eaf |grep -v grep |grep `cat /var/run/named.pid` 
 >/dev/null 2>&1
             if [ $? != 0 ]
             then
            /usr/local/sbin/named  &
             fi
        else
            /usr/local/sbin/named  &
        fi
    else
        date >>/tmp/dial_log 2>&1
        echo "Connected " >>/tmp/dial_log
    fi
   
    sleep 500  # Every 15 minutes we check we are connected
done
exit 0


#***********************************************************





Ohad.Levy@infineon.com wrote:

> Hello all,
>
>  
>
> I'm trying to write a script which will keep my adsl connection up all 
> the time.
>
>  
>
> I tried something like running :
>
> while 1
>
> rm -rf /var/run/pp*
>
>  pptp parameters nodetach &
>
> end
>
>  
>
> but from some reason, whenever i ran it, it worked for about 10 
> minutes, and after ten minutes, the pptp was detached and alot of pptp 
> process started ( even that the connection was still alive ).
>
>  
>
> I also wish to enter in the script, that if the modem fails, i could 
> telnet it a reboot it under the system menu ( something like telnet 
> with chat, maybe netcat).
>
>  
>
> Anyone wrote something like that?
>
>  
>
> Thanks,
>
> Ohad.
>
>  
>




=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il