zephyrer / autoddvpn

Automatically exported from code.google.com/p/autoddvpn
0 stars 0 forks source link

graceMode PPTP UpdateScript #94

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
按照 wget 修改的一个脚本,与大家分享。

root@doh:~# cat /jffs/pptp/run.sh
#!/bin/sh

VPNUP='vpnup.sh'
VPNDOWN='vpndown.sh'
VPNLOG='/tmp/autoddvpn.log'
TMPDIR='/tmp/autoddvpn/'
WKDIR='/jffs/pptp/'
DLDIR='http://autoddvpn.googlecode.com/svn/trunk/grace.d/'
PID=$$
INFO="[INFO#${PID}]"
DEBUG="[DEBUG#${PID}]"
IPUP="/tmp/pptpd_client/ip-up"
IPDOWN="/tmp/pptpd_client/ip-down"

echo "$INFO $(date "+%d/%b/%Y:%H:%M:%S") log starts" >> $VPNLOG
echo "$INFO $(date "+%d/%b/%Y:%H:%M:%S") pptp+jffs mode" >> $VPNLOG

mkdir -p $TMPDIR
cd $TMPDIR
for file in $VPNUP $VPNDOWN
do
        for i in 1 2 3 4 5
        do
                echo "$INFO $(date "+%d/%b/%Y:%H:%M:%S") getting $file" >> $VPNLOG
                wget $DLDIR$file || echo "$INFO failed, trying again"
                if [ $(wc -l $file | awk '{print $1}') -ne 0 ]; then
                        if [ $(diff $file $WKDIR$file | wc -l | awk '{print $1}') -ne 0 ]; then
                                chmod +x $file; cp $file $WKDIR; fi
                        break
                else echo "$INFO failed, retry"; fi
                sleep 3
        done
done
cd -
rm -rf $TMPDIR

echo "$INFO $(date "+%d/%b/%Y:%H:%M:%S") modifying $IPUP" >> $VPNLOG
for i in 1 2 3 4 5 6 7 8 9 10 11 12
do
        if [ -e $IPUP ]; then
                sed -ie 's#exit 0#/jffs/pptp/vpnup.sh pptp\nexit 0#g' $IPUP
                echo "$INFO $(date "+%d/%b/%Y:%H:%M:%S") $IPUP modified" >> $VPNLOG
                break
        else
                echo "$INFO $(date "+%d/%b/%Y:%H:%M:%S") $IPUP not exists, sleep 10sec." >> $VPNLOG
                sleep 10
        fi
done

echo "$INFO $(date "+%d/%b/%Y:%H:%M:%S") modifying $IPDOWN" >> $VPNLOG
if [ -e $IPDOWN ]; then
        sed -ie 's#exit 0#/jffs/pptp/vpndown.sh pptp\nexit 0#g' $IPDOWN
        echo "$INFO $(date "+%d/%b/%Y:%H:%M:%S") $IPDOWN modified" >> $VPNLOG
else
        echo "$IPDOWN not exists" >> $VPNLOG
fi

echo "$INFO $(date "+%d/%b/%Y:%H:%M:%S") ALL DONE. Let's wait for VPN being 
connected." >> $VPNLOG

請提供以下資訊:

1. 您的路由器型號:ASUS RT-N16
2. DD-WRT版本:Firmware: DD-WRT v24-sp2 (08/07/10) mega

Original issue reported on code.google.com by panyvf...@gmail.com on 22 Sep 2011 at 11:58