Skip to content

Instantly share code, notes, and snippets.

@angelbladex
Last active May 13, 2016 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelbladex/ddb10c30e54133cdc65a2e2078bb9a78 to your computer and use it in GitHub Desktop.
Save angelbladex/ddb10c30e54133cdc65a2e2078bb9a78 to your computer and use it in GitHub Desktop.
Using openconnect for access to VPN server via script
#!/bin/bash
username="user@hostname"
password="your-Complex-password"
url="Your-URL"
pidfile="/tmp/openconnect-pid"
case "$1" in
start)
echo "$password" | openconnect -b --pid-file=$pidfile --user=$username $url &
;;
stop)
if [ -e "$pidfile" ]
then
cat $pidfile | xargs kill -2
else
echo "Are you executed before ./vpn.sh start?"
fi
exit 1
;;
*)
echo "$0 <start|stop>"
exit 1
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment