Skip to content

Instantly share code, notes, and snippets.

@blues911
Last active October 12, 2020 14:18
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 blues911/68bac517ecf662cd5e2fd315c7a18277 to your computer and use it in GitHub Desktop.
Save blues911/68bac517ecf662cd5e2fd315c7a18277 to your computer and use it in GitHub Desktop.
Linux openconnect shell script
#!/bin/bash
# openconnect shell script
# vpn settings
HOST="test-vpn.com"
USER="test"
PASSWORD="test"
case "$1" in
--help)
echo "usage: script [--help] [--open] [--close] [--check]"
echo "arguments:"
echo " --help show this help message and exit"
echo " --open start openconnect in a background"
echo " --close kill openconnect process"
echo " --check check openconnect process"
;;
--open)
# use `openconnect -h` for more options
echo $PASSWORD | sudo openconnect -b -u $USER $HOST --no-dtls --passwd-on-stdin
;;
--close)
sudo pkill -2 openconnect
;;
--check)
ps -ef | grep openconnect
;;
*)
echo "use [--help] for help"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment