mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
29 lines
546 B
Bash
Executable File
29 lines
546 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
WORKDIR=$(dirname "$0")
|
|
|
|
# Pre-flight checks
|
|
# -----------------
|
|
|
|
# Check files are readable JSON files.
|
|
PRE_FLIGHT_CHECKS_RESULT=0
|
|
for FILE in "${WORKDIR}/parts/"*.lsrules
|
|
do
|
|
if ! jq '.' "$FILE" > /dev/null
|
|
then
|
|
echo "$FILE"
|
|
PRE_FLIGHT_CHECKS_RESULT=1
|
|
fi
|
|
done
|
|
|
|
[[ "$PRE_FLIGHT_CHECKS_RESULT" -ne 0 ]] && exit "$PRE_FLIGHT_CHECKS_RESULT"
|
|
|
|
# Actual work
|
|
# -----------
|
|
|
|
jq --indent 4 -M \
|
|
'.rules=([inputs.rules]|flatten)' \
|
|
"${WORKDIR}/all.lsrules" \
|
|
"${WORKDIR}/parts/"*.lsrules \
|
|
| sponge "${WORKDIR}/all.lsrules"
|