eid-ops/natmd-test-common/overlay/opt/mdqp/post.d/40-create-transitive

54 lines
1.1 KiB
Text
Raw Normal View History

2023-09-06 13:28:12 +02:00
#!/usr/bin/env bash
set -e
base_url="http://localhost:8080"
base_dir="/opt/mdqp/work/signed_metadata"
tmpfile=$(mktemp /tmp/"$(basename "$0")".XXXXXX)
for expression in "role-sp" "role-idp" "index.html"; do
2023-09-06 13:28:12 +02:00
echo "Fetching up ${expression}"
case $expression in
role-sp)
url="role/sp.xml"
file="/role/sp.xml"
;;
role-idp)
url="role/idp.xml"
file="/role/idp.xml"
;;
index.html)
url="entities/"
file="/entities/index.html"
;;
2023-09-06 13:28:12 +02:00
*)
echo "Unsupported expression ${expression}"
exit 1
;;
esac
curl ${base_url}/${url} -o "${tmpfile}"
2023-09-26 15:16:04 +02:00
case $file in
*.json)
jq -e .[].entityID "${tmpfile}" 1> /dev/null
;;
*.xml|*.html)
xmlstarlet sel -t -v "//md:EntityDescriptor/@entityID" -n -m "//*[local-name()='EntityDescriptor']" -v "@entityID" -n "${tmpfile}" 1>/dev/null
;;
*)
echo "Unsupported file type (${file}))"
exit 1
;;
esac
2023-09-06 13:28:12 +02:00
full_path=${base_dir}${file}
mkdir -p "$(dirname ${full_path})"
mv "${tmpfile}" "${full_path}"
done