read HSADMINNG_CAS_USERNAME + HSADMINNG_CAS_PASSWORD if missing in env

This commit is contained in:
Michael Hoennig 2024-12-21 15:51:17 +01:00
parent 3b9f48cfd6
commit 2ebf4ea618

View File

@ -31,7 +31,6 @@ else
fi
if [ -z "$HSADMINNG_CAS_LOGIN" ] || [ -z "$HSADMINNG_CAS_VALIDATE" ] || \
[ -z "$HSADMINNG_CAS_USERNAME" ] || [ -z "$HSADMINNG_CAS_PASSWORD" ] || \
[ -z "$HSADMINNG_CAS_SERVICE" ]; then
cat >&2 <<EOF
ERROR: environment incomplete
@ -39,14 +38,23 @@ if [ -z "$HSADMINNG_CAS_LOGIN" ] || [ -z "$HSADMINNG_CAS_VALIDATE" ] || \
please set the following environment variables:
export HSADMINNG_CAS_LOGIN=https://login.hostsharing.net/cas/v1/tickets
export HSADMINNG_CAS_VALIDATE=https://login.hostsharing.net/cas/proxyValidate
export HSADMINNG_CAS_USERNAME=<<your username>>
export HSADMINNG_CAS_PASSWORD=<<your password>>
export HSADMINNG_CAS_USERNAME=<<optionally, your username, or leave empty after '='>>
export HSADMINNG_CAS_PASSWORD=<<optionally, your password, or leave empty after '='>>
export HSADMINNG_CAS_SERVICE=https://hsadminng.hostsharing.net:443/
EOF
exit 1
fi
function casLogin() {
if [ -z "$HSADMINNG_CAS_USERNAME" ]; then
read -p "Username: " HSADMINNG_CAS_USERNAME
fi
if [ -z "$HSADMINNG_CAS_PASSWORD" ]; then
read -p "Password: " HSADMINNG_CAS_PASSWORD
fi
HSADMINNG_CAS_TGT=`doCurl -s -i -X POST \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d "username=$HSADMINNG_CAS_USERNAME&password=$HSADMINNG_CAS_PASSWORD" \