Files
rustproxy-opnsense-repo/scripts/check.sh
T
2026-09-29 16:53:26 +02:00

60 lines
2.4 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"
[[ -x "$ROOT/builder/freebsd/apply-patches.sh" ]]
[[ -f "$ROOT/builder/freebsd/patches/0.20.0/0001-opnsense-build.patch" ]]
grep -q 'APPLY_FREEBSD_PATCHES=1' "$ROOT/builder.env.example"
grep -q 'builder/freebsd/apply-patches.sh' "$ROOT/builder/debian/build-docker-release.sh"
grep -q 'rustproxy_run_dir:="/var/run/rustproxy"' "$ROOT/opnsense-plugin/www/rustproxy/src/etc/rc.d/rustproxy"
grep -q 'pidfile="${rustproxy_run_dir}/daemon.pid"' "$ROOT/opnsense-plugin/www/rustproxy/src/etc/rc.d/rustproxy"
grep -q 'child_pidfile="${rustproxy_run_dir}/rustproxy.pid"' "$ROOT/opnsense-plugin/www/rustproxy/src/etc/rc.d/rustproxy"
grep -q '/var/run/rustproxy' "$ROOT/opnsense-plugin/www/rustproxy/+POST_INSTALL.pre"
echo "Repository checks passed."