diff options
author | Björn Mattsson <bjorn@sunet.se> | 2023-03-06 11:22:05 +0100 |
---|---|---|
committer | Björn Mattsson <bjorn@sunet.se> | 2023-03-06 11:22:05 +0100 |
commit | 467dbdbf3d7212e25ee69daeaadd8adba7c7c5b8 (patch) | |
tree | d3576d5f2d4b5cc676c0a12ef8f8c3c83b474bf5 /metadata/scripts/rename-xml.sh | |
parent | bc1d55080e5d42e6ef2bba892d640aa8f68bbc90 (diff) |
Moved files to make ths repo signed
Diffstat (limited to 'metadata/scripts/rename-xml.sh')
-rwxr-xr-x | metadata/scripts/rename-xml.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/metadata/scripts/rename-xml.sh b/metadata/scripts/rename-xml.sh new file mode 100755 index 00000000..4326579f --- /dev/null +++ b/metadata/scripts/rename-xml.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Fetch Service Provider metadata and save into entityid filename +# + +error() +{ + echo "Error: $*" 1>&2 + exit 1 +} + +metadata=$1 +if [ -z "$metadata" ] ; then + cat <<EOF +Usage: `basename $0` <file to check> +Ex: `basename $0` account.eciu.eu.xml +EOF + exit 1 +fi + +entityid=`cat "$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`" + +entityidfn=`echo "$entityid" | sed 's;https*://;;' | sed 's/[^a-zA-Z0-9_.-]/-/g' | sed 's/$/.xml/'` +[ -n "$entityidfn" ] || error "Failed to generate filename from entityid $entityid" + +[ -r "$entityidfn" ] && new=false || new=true +if $new ; then + echo -n "Move $metadata into $entityidfn [Y/n]? " +else + echo "$entityidfn and $metadata are the same" + exit +fi +read x +case $x in + Y|y|"") + git mv $metadata $entityidfn + + ;; + *) + echo "Nothing done" + ;; +esac |