#!/usr/bin/env bash

set -e

# Verify and update the repo. Previously run by cron but to mitigate/remove
# race condion it moved here.
cd /var/cache/metadata_r1.komreg.net && make update

cd /opt/metadata

incoming_dir=/opt/mdqp/work/incoming_metadata
mkdir -p ${incoming_dir}
tmp_dir=$(mktemp -d)

#rsync -a production-idp/*.xml production-sp/*.xml ${tmp_dir}/
rsync -a --delete ${tmp_dir}/ ${incoming_dir}/

rm -rf "${tmp_dir}"