diff options
author | Anders Lördal <anders@lordal.se> | 2016-06-23 09:08:09 +0200 |
---|---|---|
committer | Anders Lördal <anders@lordal.se> | 2016-06-23 09:08:09 +0200 |
commit | 5356f9cdd1393e6b965b09beb72d98e3ceb53ba4 (patch) | |
tree | 682a405670efc252b13136bbf0e843fc5ba9af3a | |
parent | 9617412863c953dc35d0beb50a028abd4c4f9192 (diff) |
Updated get-metadata.sh
-rwxr-xr-x | scripts/get-metadata.sh | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/scripts/get-metadata.sh b/scripts/get-metadata.sh index d7275d0d..509b0d2b 100755 --- a/scripts/get-metadata.sh +++ b/scripts/get-metadata.sh @@ -17,6 +17,7 @@ Ex: `basename $0` https://shibsp.mysite.com/Shibboleth.sso/Metadata `basename $0` https://shibidp.mysite.com/idp/profile/Metadata/SAML `basename $0` some-downloaded-metadata.xml `basename $0` reep:<entityid> + `basename $0` <hostname> (tries to pull from standard locations) EOF exit 1 fi @@ -24,11 +25,19 @@ fi if echo "$metadataurl" | grep -qE '^http://|^https://' ; then metadata=`curl -s -k -f "$metadataurl"` elif echo "$metadataurl" | grep -qE '^reep:' ; then - id=`echo -n "$metadataurl" | sed 's/^reep://' | sha1sum | awk '{print $1}'` - metadataurl="http://md.reep.refeds.org/entities/%7Bsha1%7D$id" - metadata=`curl -s -k -f "$metadataurl"` + id=`echo -n "$metadataurl" | sed 's/^reep://' | sha1sum | awk '{print $1}'` + metadataurl="http://md.reep.refeds.org/entities/%7Bsha1%7D$id" + metadata=`curl -s -k -f "$metadataurl"` else - metadata=`cat "$metadataurl"` + if [ -s "${metadataurl}" ]; then + metadata=`cat "$metadataurl"` + else + urls="https://${metadataurl}/idp/shibboleth https://${metadataurl}/Shibboleth.sso/Metadata https://${metadataurl}/saml/index/sp-metadata" + for i in ${urls}; do + metadata=`curl -s -k -f "${i}"` + [ -n "${metadata}" ] && break + done + fi fi [ -n "$metadata" ] || error "Failed to fetch metadata from $metadataurl" @@ -48,6 +57,9 @@ read x case $x in Y|y|"") echo "$metadata" > $entityidfn + tmp=`mktemp` + xsltproc `dirname $0`/../xslt/clean-entitydescriptor.xsl ${entityidfn} > ${tmp} && mv ${tmp} ${entityidfn} + echo $entityidfn ;; *) |