summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFredrik Domeij <fredrik.domeij@umu.se>2017-03-17 07:58:03 +0100
committerFredrik Domeij <fredrik.domeij@umu.se>2017-03-17 07:58:03 +0100
commit982d79e47a7fc6d5bd9e5473fa195afece2a4c7f (patch)
tree34bb7763012366fe6a5c9124d6ca36545641c88e /scripts
parent033d20f87dfc10471b4a991727ac00c192cbe8a2 (diff)
jira-test.its.umu.se added
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/get-metadata.sh45
1 files changed, 40 insertions, 5 deletions
diff --git a/scripts/get-metadata.sh b/scripts/get-metadata.sh
index 88938b61..efc73c7d 100755
--- a/scripts/get-metadata.sh
+++ b/scripts/get-metadata.sh
@@ -22,6 +22,13 @@ 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
+
if echo "$metadataurl" | grep -qE '^http://|^https://' ; then
metadata=`curl -s -k -f "$metadataurl"`
elif echo "$metadataurl" | grep -qE '^reep:' ; then
@@ -48,19 +55,47 @@ entityid=`echo "$metadata" | sed -n 's/.*entityID=['\''"]\([^"]*\)['\''"].*/\1/p
entityidfn=`echo "$entityid" | sed 's;https*://;;' | tr 'A-Z' 'a-z' | sed 's;/$;;' | sed 's/[^a-z0-9_.-]/-/g' | sed 's/\.xml$//;s/$/.xml/'`
[ -n "$entityidfn" ] || error "Failed to generate filename from entityid $entityid"
-if [ -r "$entityidfn" ] ; then
- echo -n "Replace $entityidfn with metadata [Y/n]? "
-else
+[ -r "$entityidfn" ] && new=false || new=true
+if $new ; then
echo -n "Save metadata into $entityidfn [Y/n]? "
+else
+ echo -n "Replace $entityidfn with metadata [Y/n]? "
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 "s;^</md:EntitiesDescriptor>; <xi:include href=\"swamid-2.0/$entityidfn\"/>\n&;" ../swamid-sp-2.0.mxml
+ echo --
+ tail -n 10 ../swamid-sp-2.0.mxml | sed 's/^/ /'
+ echo --
+ ;;
+ *)
+ echo "Not added"
+ ;;
+ esac
+ fi
+
echo "$metadata" > $entityidfn
tmp=`mktemp`
- xsltproc `dirname $0`/../xslt/clean-entitydescriptor.xsl ${entityidfn} > ${tmp} && mv ${tmp} ${entityidfn}
+ xsltproc $script_cwd/../xslt/clean-entitydescriptor.xsl ${entityidfn} > ${tmp} && mv ${tmp} ${entityidfn}
- echo $entityidfn
+ if $new ; then
+ echo -n "Add swamid-2.0/$entityidfn to git [Y/n]? "
+ read x
+ case $x in
+ Y|y|"")
+ git add $entityidfn
+ ;;
+ *)
+ echo "Not added"
+ ;;
+ esac
+ fi
;;
*)
echo "Nothing done"