diff options
Diffstat (limited to 'scripts/get-metadata.sh')
-rwxr-xr-x | scripts/get-metadata.sh | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/scripts/get-metadata.sh b/scripts/get-metadata.sh index c3be62a4..c26262ba 100755 --- a/scripts/get-metadata.sh +++ b/scripts/get-metadata.sh @@ -22,13 +22,7 @@ EOF exit 1 fi -script_cwd=`dirname "$0"` -if test -d swamid-2.0 ; then - echo "Moving into swamid-2.0/" - cd swamid-2.0 - echo "$script_cwd" | grep -q ^/ || script_cwd=../$script_cwd -fi - +xmldir=swamid-2.0 update_xml=true if echo "$metadataurl" | grep -qE '^http://|^https://' ; then metadata=`curl -L -s -k -f "$metadataurl"` @@ -42,6 +36,7 @@ else else case $metadataurl in [0-9][0-9]*) + xmldir=$(curl -L -m 5 -s -k -f "https://metadata.swamid.se/?show=feed&id=${metadataurl}") urls="https://metadata.swamid.se/?rawXML=${metadataurl}" update_xml=false ;; @@ -60,6 +55,13 @@ else fi [ -n "$metadata" ] || error "Failed to fetch metadata from $metadataurl" +script_cwd=`dirname "$0"` +if test -d $xmldir ; then + echo "Moving into $xmldir/" + cd $xmldir + echo "$script_cwd" | grep -q ^/ || script_cwd=../$script_cwd +fi + entityid=`echo "$metadata" | sed -n 's/.*entityID=['\''"]\([^"]*\)['\''"].*/\1/p'` [ -n "$entityid" ] || error "Failed to find entityID in metadata" [ `echo "$entityid" | wc -l` = 1 ] || error "Multiple entityid:s found: `echo $entityid`" @@ -79,25 +81,6 @@ fi read x case $x in Y|y|"") - if $new ; then - echo -n "Add swamid-2.0/$entityidfn to swamid-sp-2.0.mxml [Y/n]? " - read x - case $x in - Y|y|"") - sed -i.bak "s;^</md:EntitiesDescriptor>; <xi:include href=\"swamid-2.0/$entityidfn\"/>\n&;" ../swamid-sp-2.0.mxml - if [ -f ../swamid-sp-2.0.mxml.bak ]; then - rm ../swamid-sp-2.0.mxml.bak - fi - echo -- - tail -n 10 ../swamid-sp-2.0.mxml | sed 's/^/ /' - echo -- - ;; - *) - echo "Not added" - ;; - esac - fi - echo "$metadata" > $entityidfn tmp=`mktemp` if $update_xml ; then @@ -122,4 +105,3 @@ case $x in echo "Nothing done" ;; esac - |