small pixel drawing of a pufferfish dotfiles

bin/zora/vpn

#!/bin/sh
#
# connects or kills the gp
# vpn tunnel

if [ "$1" = "kill" ]; then
    notify-send '🤬 killing vpn' -t 2000
    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
fi