more overlay files

This commit is contained in:
Maria Haider 2023-09-06 13:28:12 +02:00
parent c62c908a3e
commit 318b1d7c1a
Signed by: mariah
GPG key ID: 7414A760CA747E57
3 changed files with 80 additions and 0 deletions

View file

@ -0,0 +1,39 @@
#!/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"; do
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"
;;
*)
echo "Unsupported expression ${expression}"
exit 1
;;
esac
curl ${base_url}/${url} -o "${tmpfile}"
if ! grep -q entityID "${tmpfile}" ; then
echo "No entityID found in file for ${expression}"
exit 1
fi
full_path=${base_dir}${file}
mkdir -p "$(dirname ${full_path})"
mv "${tmpfile}" "${full_path}"
done

View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -e
# Cleanup stale files (removed files that the main script missout of removing (race))
find /opt/mdqp/work/seen_metadata/ -type f -mtime +2 -print -delete

View file

@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -e
metadata_dir="/opt/mdqp/work/incoming_metadata/"
signed_dir="/opt/mdqp/work/signed_metadata/entities/"
loaded_entites_in_pyff=$(curl -s 172.16.0.2:8080/api/status | jq .store.size)
entities_on_disk=$(find ${metadata_dir} -type f -printf "%f\n" |sort |uniq | wc -l)
exit_status=0
if [ "${loaded_entites_in_pyff}" -ne "${entities_on_disk}" ]; then
echo "Pyff has ${loaded_entites_in_pyff} entites loaded but there are ${entities_on_disk} entities in ${metadata_dir}. Please investigate pyffs logs."
exit_status=1
fi
incoming_files=$(find ${metadata_dir}/* -type f | wc -l)
signed_files=$(find ${signed_dir} -type f ! -name 'index.html' | wc -l)
if [ "${incoming_files}" -ne "${signed_files}" ]; then
exit_status=1
echo "The incoming metadata dir (${metadata_dir}) contains ${incoming_files} and the signed metadata dir (${signed_dir}) contains ${signed_files}. That ain't right. Please investigate."
echo "The following files might help you investigate:"
entities_file=$(mktemp)
cd /opt/mdqp/work
grep entityID signed_metadata/entities/%7Bsha1%7D* | sed -e 's/.*entityID="\(.*\)" ID=.*/\1.xml/' -e 's/".*.xml/.xml/' -e 's@https://@@' -e 's@http://@@' | tr ':/?=' '----' | sort > "${entities_file}"
find incoming_metadata/ -type f -printf '%f\n' | sort | comm -3 - "${entities_file}"
if [ -f "${entities_file}" ]; then
rm "${entities_file}"
fi
fi
exit ${exit_status}