Advertisement
Guest User

Untitled

a guest
Feb 29th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #!/bin/sh
  2. #Variable to adjust
  3. HOSTPING=195.242.124.54
  4. HOSTPVN=192.168.3.1
  5. USER=wolfyxvf
  6. PASS=strongpassword
  7. INITTUN=tun8
  8. NAMETUN=ovpnc8
  9. #Tools
  10. PING='/sbin/ping'
  11. IFCONFIG='/sbin/ifconfig'
  12. OPENCONNECT='/usr/local/sbin/openconnect'
  13. DATE=`date`
  14. PINGRES=`$PING -c 2 $HOSTPING`
  15. PLOSS="$(echo $PINGRES : | grep -o '[0-9][0-9][0-9].[0-9]% packet loss' | cut -f1 -d%)"
  16.  
  17. echo "$DATE : Loss Result : $PLOSS"
  18. if [ "100.0" = "$PLOSS" ];
  19. then
  20. echo "$DATE : Deleting Old Interface : $NAMETUN"
  21. $IFCONFIG $NAMETUN down
  22. $IFCONFIG $NAMETUN destroy
  23. echo "$DATE : Creating Interface : $INITTUN"
  24. $IFCONFIG $INITTUM create
  25. $IFCONFIG $INITTUM up
  26. echo "$DATE : Starting : $NAMETUN"
  27. echo -n $PASS | exec $OPENCONNECT --background --interface=$INITTUN --user=$USER --no-cert-check $HOSTPVN
  28. echo "$DATE : Renaming Interface : $INITTUN to $NAMETUN"
  29. $IFCONFIG tun8 name ovpnc8
  30. echo "$DATE : Now running : $NAMETUN"
  31. else
  32. echo "$DATE : Already running"
  33. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement