liunian / autoddvpn

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

Patch for /trunk/vpnup.sh #172

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
針對Issue 170做出的patch,解決死循環問題

Original issue reported on code.google.com by i@blue.cat on 15 Nov 2012 at 11:16

Attachments:

GoogleCodeExporter commented 9 years ago
修改部分final check again到最後:

# final check again
echo "$INFO final check the default gw"
for i in 1 2 3 4 5 6
do
  GW=$(route -n | grep ^0.0.0.0 | awk '{print $2}')
  echo "$DEBUG my current gw is $GW"
  #route | grep ^default | awk '{print $2}'
  if [ "$GW" == "$OLDGW" ]; then 
    echo "$DEBUG still got the OLDGW, why?"
    echo "$INFO delete default gw $OLDGW" 
    route del default gw $OLDGW
    echo "$INFO add default gw $VPNGW again" 
    route add default gw $VPNGW
    sleep 3
  else
    break
  fi
done
GW=$(route -n | grep ^0.0.0.0 | awk '{print $2}')
if [ "$GW" == "$OLDGW" ]; then
  echo "$ERROR $(date "+%d/%b/%Y:%H:%M:%S") still got the old gw, it may because vpn was disconnected." >> $LOG
  echo "$INFO $(date "+%d/%b/%Y:%H:%M:%S") vpnup.sh ended" >> $LOG
else
  echo "$INFO static routes added"
  echo "$INFO $(date "+%d/%b/%Y:%H:%M:%S") vpnup.sh ended" >> $LOG
  echo "$INFO $(date "+%d/%b/%Y:%H:%M:%S") restarting DNS" >> $LOG
  restart_dns
fi
# release the lock
rm -f $LOCK

Original comment by i@blue.cat on 15 Nov 2012 at 11:20