Allow passing credentials from environment
This commit is contained in:
@@ -27,7 +27,7 @@ Rename routes.txt.sample to routes.txt or create an empty routes.txt and add sub
|
||||
## Usage
|
||||
|
||||
```
|
||||
sudo ./run-vpn.sh
|
||||
sudo -E ./run-vpn.sh
|
||||
```
|
||||
|
||||
In case of disconnect, it will try reconnecting after 3 seconds. You can stop it by pressing `CTRL+C` or killing the script.
|
||||
+16
@@ -1,10 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read from keychain on macOS by default
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
SERVER=$(security find-generic-password -l "Openconnect VPN Server" -w)
|
||||
USERNAME=$(security find-generic-password -l "Openconnect Username" -w)
|
||||
SEED=$(security find-generic-password -l "Openconnect TOTP Seed" -w)
|
||||
PASSWORD=$(security find-generic-password -l "Openconnect Account Password" -w)
|
||||
fi
|
||||
|
||||
# Allow reading from environment
|
||||
if [[ -z "$OC_SERVER" ]]; then :; else
|
||||
SERVER="$OC_SERVER"
|
||||
fi
|
||||
if [[ -z "$OC_USERNAME" ]]; then :; else
|
||||
USERNAME="$OC_USERNAME"
|
||||
fi
|
||||
if [[ -z "$OC_SEED" ]]; then :; else
|
||||
SEED="$OC_SEED"
|
||||
fi
|
||||
if [[ -z "$OC_PASSWORD" ]]; then :; else
|
||||
PASSWORD="$OC_PASSWORD"
|
||||
fi
|
||||
|
||||
SCRIPT=`realpath $0`
|
||||
SCRIPTPATH=`dirname $SCRIPT`
|
||||
|
||||
Reference in New Issue
Block a user