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