diff --git a/bin/zora/vpn b/bin/zora/vpn index 305c80f..4b7db0c 100755 --- a/bin/zora/vpn +++ b/bin/zora/vpn @@ -3,18 +3,30 @@ # connects or kills the gp # vpn tunnel +die() { + notify-send "💀 $1" -t 2000 + sleep 1 + exit 1 +} + +vpn_running() { + pgrep openconnect >/dev/null +} + if [ "$1" = "kill" ]; then - notify-send '🤬 killing vpn' -t 2000 - sudo pkill openconnect + vpn_running || + die 'vpn is already dead' + notify-send '🔪 killing vpn' -t 1000 + sudo pkill openconnect else - notify-send '👼 connecting vpn' -t 1000 - # the two-line pipe method used here was described - # in this issue: https://github.com/dlenski/openconnect/issues/103#issuecomment-383416545 - if pgrep openconnect; then - sleep 1 - notify-send '😳 vpn already running' -t 2000 - exit - fi - printf "%s\n%s" "$(pa show vpn)" "1" | - sudo openconnect -u jolson --passwd-on-stdin --protocol=gp https://vpn-nyc3.digitalocean.com/ssl-vpn + vpn_running && + die 'vpn is already running' + notify-send '🛡️ vpn connecting' -t 500 + # ty katco 🙌 + openconnect-gp-okta \ + -username jolson \ + -password-command 'pa show vpn' \ + -vpn-endpoint vpn-nyc3.digitalocean.com \ + -openconnect-args='--reconnect-timeout --csd-wrapper=/usr/lib/openconnect/hipreport.sh' + notify-send '🛡️ vpn connected' -t 500 fi