From 5356f9cdd1393e6b965b09beb72d98e3ceb53ba4 Mon Sep 17 00:00:00 2001 From: Anders Lördal Date: Thu, 23 Jun 2016 09:08:09 +0200 Subject: Updated get-metadata.sh --- scripts/get-metadata.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'scripts/get-metadata.sh') 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: + `basename $0` (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 ;; *) -- cgit v1.2.3