Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- set -euo pipefail
- usage="$0: <up|down|state|stats> [connection name]"
- action="${1?$usage}"
- connection="${2:-GDS VPN Developer}"
- oath_key=gds-vpn
- pass_key=gds/vpn
- case "$action" in
- up)
- otp=$(ykman oath code "$oath_key" | awk '/[0-9]$/ { print $NF; }')
- : "${otp:?OTP not found}"
- password=$(pass "$pass_key")
- # Shut down the GUI app, which doesn't get along with the CLI tool
- pkill "Cisco AnyConnect Secure Mobility Client" || :
- echo -e "${USER}\n${password}\n${otp}" | \
- /opt/cisco/anyconnect/bin/vpn -s connect "$connection" | \
- grep --line-buffered -Fv 'Second Password'
- ;;
- down)
- /opt/cisco/anyconnect/bin/vpn -s disconnect
- ;;
- state)
- /opt/cisco/anyconnect/bin/vpn state
- ;;
- stats)
- /opt/cisco/anyconnect/bin/vpn stats
- ;;
- *)
- echo "$usage" >&2
- exit 1
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement