openconnect_reconnect.sh 632 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. # fail if any commands fails
  3. set -e
  4. # debug log
  5. set -x
  6. vpn_server="boromir.fibertel.com.ar"
  7. vpn_username="username"
  8. vpn_password="password"
  9. vpn_servercert=""
  10. # try connect
  11. while true; do
  12. retry_time=$(($(date +%s) + 30))
  13. sudo openconnect \
  14. -u $vpn_username $vpn_server --non-inter --passwd-on-stdin <<<"$vpn_password"
  15. #cat ~/.ocvpn_secret | sudo /usr/bin/openconnect \
  16. #--juniper $vpn_server \
  17. #--servercert sha256:$vpn_servercert \
  18. #--user=$vpn_username \
  19. #--passwd-on-stdin
  20. current_time=$(date +%s)
  21. if [ $current_time -lt retry_time ]; then
  22. sleep $(($retry_time - $current_time))
  23. fi
  24. done