diff --git a/run-vpn.sh b/run-vpn.sh index 9e0723c..eca7a9b 100755 --- a/run-vpn.sh +++ b/run-vpn.sh @@ -46,20 +46,32 @@ while true; do # If yubikey is not used, use the TOTP seed if [[ -z "$OC_YUBIKEY" ]]; then - TOTP=$(oathtool --totp=sha1 -b "$SEED") - PASSWORD="$PASSWORD\n$TOTP" + + if [[ -z "$SEED" ]]; then :; else + TOTP=$(oathtool --totp=sha1 -b "$SEED") + PASSWORD="$PASSWORD\n$TOTP" + fi else YUBIKEY_TOTP="--token-mode=yubioath --token-secret=$OC_YUBIKEY" fi - echo -e "$PASSWORD" | sudo openconnect \ - --csd-wrapper hostscan-bypass.sh \ - --passwd-on-stdin \ - --os=mac-intel \ - $YUBIKEY_TOTP \ - $SCRIPT_INCLUDE \ - -u $USERNAME \ - $SERVER + if [ -z "$SEED" ] && [ -z "$OC_YUBIKEY" ]; then + sudo openconnect \ + --csd-wrapper hostscan-bypass.sh \ + --os=mac-intel \ + $SCRIPT_INCLUDE \ + -u $USERNAME \ + $SERVER + + else + echo -e "$PASSWORD" | sudo openconnect \ + --csd-wrapper hostscan-bypass.sh \ + --os=mac-intel \ + $YUBIKEY_TOTP \ + $SCRIPT_INCLUDE \ + -u $USERNAME \ + $SERVER + fi echo "Openconnect closed. Waiting 3 seconds." sleep 3