#!/bin/sh -e ########################################################################### # # dn42 registry - object validation # ########################################################################### mntner="$1" if [ -z "$mntner" ] then >&2 echo "Usage: $0 YOUR-MNT" exit 1 fi check_script='utils/schema-check/dn42_schema_local.py' ########################################################################### # determine registry directory # # this will fail if the script is in the PATH or is sourced but those # both seem unlikely. In any case if it does fail an env var can be used # to override the check rdir="$REGDIR" if [ -z "$rdir" ] then rdir=$(cd -- "$(dirname -- "$0")" && pwd) fi if ! [ -x "${rdir}/${check_script}" ] then >&2 cat <&2 echo 'Schema validation failed!' exit 1 fi else # check single mntner mfile="data/mntner/$mntner" if ! [ -f "$mfile" ] then >&2 echo "MNTNER object does not exist: $mfile" exit 1 fi if ! "$check_script" -v scan data/ -f "$mfile" then >&2 echo 'Schema validation for mntner object failed!' exit 1 fi if ! "$check_script" -v scan data/ -m "$mntner" then >&2 echo 'Schema validation for related objects failed!' exit 1 fi fi # all good exit 0 ########################################################################### # end of file