This commit is contained in:
iceBear67
2026-07-05 13:49:09 +08:00
parent a37aece686
commit bf67b8b95f
21 changed files with 230 additions and 61 deletions

58
scripts/validate.sh Executable file
View File

@@ -0,0 +1,58 @@
#!/bin/sh
root="$PWD/image/overlay"
env_file="${1:-.env}"
if [ ! -f "$env_file" ]; then
echo "cannot find $env_file"
exit 1
fi
current_file=""
fail=0
while IFS= read -r line; do
case "$line" in
\#\ /*)
current_file="${line#\# }"
target="$root$current_file"
if [ ! -f "$target" ]; then
echo "missing file: $target" >&2
fail=1
current_file=""
fi
;;
\#\:*)
continue
;;
*=*)
if [ -z "$current_file" ]; then
echo "warning: value without file: $line" >&2
continue
fi
key="${line%%=*}"
target="$root$current_file"
if ! grep -q "_${key}_" "$target"; then
echo "missing variable: _${key}_ in $target" >&2
fail=1
fi
;;
"")
continue
;;
*)
echo "unknown line: $line" >&2
fail=1
;;
esac
done < "$env_file"
exit "$fail"