diff --git a/bin/cas-curl b/bin/cas-curl index 41427a41..45fa22dd 100755 --- a/bin/cas-curl +++ b/bin/cas-curl @@ -1,14 +1,10 @@ #!/bin/bash -if [ "$#" -eq 0 ] || [ "$1" == "help" ] || [ "$1" == "--help" ] || [ "$1" == "-h" ]; then - cat <> [parameters] - - commands: -EOF - grep '") ''# ' $0 - exit +if [ "$2" == "--show-password" ]; then + HSADMINNG_CAS_SHOW_PASSWORD=yes + shift +else + HSADMINNG_CAS_SHOW_PASSWORD= fi if [ "$1" == "--trace" ]; then @@ -17,7 +13,10 @@ if [ "$1" == "--trace" ]; then } function doCurl() { set -x - curl --fail-with-body --header "Authorization: $HSADMINNG_CAS_TICKET" "$@" + curl --fail-with-body \ + --header "Authorization: $HSADMINNG_CAS_TICKET" \ + --header "assumed-roles: $HSADMINNG_CAS_ASSUME" \ + "$@" set +x } shift @@ -30,6 +29,13 @@ else } 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 <> [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() { @@ -63,10 +77,16 @@ function casLogin() { 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="<