Last active
May 13, 2016 16:32
-
-
Save angelbladex/ddb10c30e54133cdc65a2e2078bb9a78 to your computer and use it in GitHub Desktop.
Using openconnect for access to VPN server via script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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