#!/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 localhost: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}