Files
rustproxy-opnsense-repo/scripts/check.sh
T
2026-09-29 14:07:21 +02:00

56 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
while IFS= read -r file; do
first_line="$(head -n 1 "$file")"
if [[ "$first_line" == *bash* ]]; then
bash -n "$file"
else
sh -n "$file"
fi
done < <(find "$ROOT" -type f \( -name '*.sh' -o -path '*/src/etc/rc.d/rustproxy' -o -path '*/src/etc/rc.syshook.d/*.start' \))
python3 - "$ROOT" <<'PY'
import pathlib
import sys
import xml.etree.ElementTree as ET
root = pathlib.Path(sys.argv[1])
for path in root.glob('opnsense-plugin/**/*.xml'):
ET.parse(path)
print('xml ok:', path.relative_to(root))
PY
if command -v php >/dev/null 2>&1; then
while IFS= read -r file; do php -l "$file" >/dev/null; done < <(find "$ROOT/opnsense-plugin" -type f -name '*.php')
fi
if [[ -n "${RUSTPROXY_SOURCE_DIR:-}" ]] && [[ -f "$RUSTPROXY_SOURCE_DIR/Cargo.toml" ]] && command -v cargo >/dev/null 2>&1; then
cargo metadata --locked --no-deps --format-version 1 --manifest-path "$RUSTPROXY_SOURCE_DIR/Cargo.toml" >/dev/null
fi
if [[ -d "$ROOT/app" ]]; then
echo "RustProxy source must not be vendored in this packaging repository: $ROOT/app" >&2
exit 1
fi
if [[ -e "$ROOT/opnsense-plugin/www/rustproxy/src/sbin/rust-proxy" ]]; then
echo "Generated binary must not be committed in plugin source." >&2
exit 1
fi
[[ -f "$ROOT/builder/docker/Dockerfile" ]]
grep -q '15.1-RELEASE' "$ROOT/builder/docker/Dockerfile"
grep -q 'rust:1.88-' "$ROOT/builder/docker/Dockerfile"
grep -q 'x86_64-unknown-freebsd' "$ROOT/builder/docker/Dockerfile"
grep -q 'BUILD_MODE=docker-freebsd' "$ROOT/builder.env.example"
grep -q 'PACKAGING_WORKDIR=/opt/opn-rustproxy/packaging' "$ROOT/builder.env.example"
if [[ -d "$ROOT/builder/freebsd" ]]; then
echo "Obsolete native FreeBSD builder directory is still present." >&2
exit 1
fi
echo "Repository checks passed."