#!/bin/bash if [ "$2" == "--show-password" ]; then HSADMINNG_CAS_SHOW_PASSWORD=yes shift else HSADMINNG_CAS_SHOW_PASSWORD= fi if [ "$1" == "--trace" ]; then function trace() { echo "$*" >&2 } function doCurl() { set -x curl --fail-with-body \ --header "Authorization: $HSADMINNG_CAS_TICKET" \ --header "assumed-roles: $HSADMINNG_CAS_ASSUME" \ "$@" set +x } shift else function trace() { : # noop } function doCurl() { curl --fail-with-body --header "Authorization: $HSADMINNG_CAS_TICKET" "$@" } fi export HSADMINNG_CAS_ASSUME_HEADER if [ -f ~/.cas-curl-assume ]; then HSADMINNG_CAS_ASSUME="$(cat ~/.cas-curl-assume)" else HSADMINNG_CAS_ASSUME= fi if [ -z "$HSADMINNG_CAS_LOGIN" ] || [ -z "$HSADMINNG_CAS_VALIDATE" ] || \ [ -z "$HSADMINNG_CAS_SERVICE_ID" ]; then cat >&2 <> export HSADMINNG_CAS_SERVICE_ID=https://hsadminng.hostsharing.net:443/ EOF exit 1 fi function casCurlDocumentation() { cat <> [parameters] commands: EOF # filters out help texts (containing double-# and following lines with leading single-#) from the commands itself # (the '' makes sure that this line is not found, just the lines with actual help texts) sed -n '/#''#/ {x; p; x; s/#''#//; p; :a; n; /^[[:space:]]*#/!b; s/^[[:space:]]*#//; p; ba}' <$0 } function casLogin() { # ticket granting ticket exists and not expired? if find ~/.cas-login-tgt -type f -size +0c -mmin -60 2>/dev/null | grep -q .; then return fi if [ -z "$HSADMINNG_CAS_USERNAME" ]; then read -e -p "Username: " HSADMINNG_CAS_USERNAME fi if [ -z "$HSADMINNG_CAS_PASSWORD" ]; then read -s -e -p "Password: " HSADMINNG_CAS_PASSWORD fi if [ "$HSADMINNG_CAS_SHOW_PASSWORD" == "--show-password" ]; then HSADMINNG_CAS_PASSWORD_DISPLAY=$HSADMINNG_CAS_PASSWORD else HSADMINNG_CAS_PASSWORD_DISPLAY="<