Last active
October 12, 2020 14:18
-
-
Save blues911/68bac517ecf662cd5e2fd315c7a18277 to your computer and use it in GitHub Desktop.
Linux openconnect shell 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 | |
# 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