mirror of
https://git.dn42.dev/dn42/registry.git
synced 2026-02-04 03:11:43 -08:00
55 lines
1.3 KiB
Bash
Executable File
55 lines
1.3 KiB
Bash
Executable File
#!/bin/sh -e
|
|
###########################################################################
|
|
#
|
|
# dn42 registry - object formatting
|
|
#
|
|
###########################################################################
|
|
|
|
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 <<EOF
|
|
ERROR: Unable to automatically find the registry directory,
|
|
or the script '$check_script' is not executable
|
|
|
|
You can set the directory manually using the
|
|
REGDIR environment variable.
|
|
|
|
For example:
|
|
REGDIR='path/to/registry' $0 $mntner
|
|
EOF
|
|
exit 1
|
|
fi
|
|
|
|
###########################################################################
|
|
|
|
grep -lrE "(\s|:)$mntner(\s|\$)" "${rdir}/data/" | \
|
|
while read -r line; do
|
|
"$check_script" fmt -i "$line"
|
|
done
|
|
|
|
###########################################################################
|
|
# end of file
|