daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest May 7th, 2016 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3.  
  4. VPN_SERVER_IP=
  5. REAL_SERVER_IP=
  6. VPN_NAME=
  7. VPN_USER=
  8. VPN_PASSWD=
  9.  
  10.  
  11. usage()
  12. {
  13.     echo ""
  14.     echo "usage:"
  15.     #echo "    `basename $0` -v vpn_server_ip -s real_server_ip -n vpn_name -u user -p password"
  16.     echo "    `basename $0` -v vpn_server_ip -s real_server_ip -n vpn_name"
  17.     echo ""
  18.     echo "vpn_server_ip: pptp server local ip(in server's file '/etc/pptpd.conf'), eg: 7.0.0.1"
  19.     echo "real_server_ip: server ip which pptp server installed on, eg: 120.92.5.82"
  20.     echo "vpn_name: pptp client vpn name, eg: ksvpn82"
  21.     #echo "user: vpn user name"
  22.     #echo "password: vpn password"
  23.     echo ""
  24.    
  25.     exit 1
  26. }
  27.  
  28.  
  29. while getopts :v:s:n:u:p: opt
  30. do
  31.     case $opt in
  32.         v)
  33.             VPN_SERVER_IP=$OPTARG
  34.             ;;
  35.         s)
  36.             REAL_SERVER_IP=$OPTARG
  37.             ;;
  38.         n)
  39.             VPN_NAME=$OPTARG
  40.             ;;
  41.         u)
  42.             VPN_USER=$OPTARG
  43.             ;;
  44.         p)
  45.             VPN_PASSWD=$OPTARG
  46.             ;;
  47.         \?)
  48.             usage
  49.             ;;
  50.     esac
  51. done
  52.  
  53.  
  54. #if [ -z $VPN_SERVER_IP ] || [ -z $REAL_SERVER_IP ] || [ -z $VPN_NAME ] || [ -z $VPN_USER ] || [ -z $VPN_PASSWD ]; then
  55. if [ -z $VPN_SERVER_IP ] || [ -z $REAL_SERVER_IP ] || [ -z $VPN_NAME ]; then
  56.     echo "invalid arguments"
  57.     usage
  58. fi
  59.  
  60.  
  61. while :
  62. do
  63.     echo "checking..."
  64.     date --rfc-3339=seconds    
  65.     until ping -c 1 $VPN_SERVER_IP > /dev/null; do
  66.         echo "can not connect to vpn server ip: $VPN_SERVER_IP"
  67.         sudo poff $VPN_NAME
  68.         #pptpsetup --delete $VPN_NAME
  69.        
  70.         until ping -c 1 $REAL_SERVER_IP > /dev/null; do
  71.             echo "can not connect to real server ip: $REAL_SERVER_IP"
  72.         done
  73.        
  74.         #pptpsetup --create $VPN_NAME --server $REAL_SERVER_IP --username $VPN_USER --password $VPN_PASSWD --encrypt --start
  75.         sudo pon $VPN_NAME
  76.         sleep 5
  77.     done
  78.     sleep 5
  79. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top