chore: clean up repo structure

- Add node_modules/, test-results/, e2e-report/, .omp/ to .gitignore
- Remove throwaway debug scripts (debug-pw*.js, debug-login-dom.js)
- Remove empty mock-server/ directory
- Untrack harness artifact (.omp/plans/)
- Add missing project files to git (e2e tests, Dockerfiles, tooling configs)
This commit is contained in:
2026-07-12 23:42:54 +05:30
parent eb04a2597d
commit c6c5a04aca
25 changed files with 1400 additions and 1458 deletions

31
docker/build-base-image.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/sh
# Build the OpenWrt base image with LuCI packages installed.
# Docker buildkit cannot build openwrt/rootfs directly because buildkit's
# seccomp profile blocks uclient-fetch (wget) syscalls used by apk 3.0.
# We use 'docker run --security-opt seccomp=unconfined' instead.
set -eu
CONTAINER_NAME="zt-gateway-luci-build-tmp"
BASE_IMAGE="zt-gateway-luci:base"
docker rm -f "$CONTAINER_NAME" 2>/dev/null || true
docker run -d --name "$CONTAINER_NAME" \
--security-opt seccomp=unconfined \
openwrt/rootfs:latest sleep infinity
# Setup repos and install packages
docker exec "$CONTAINER_NAME" mkdir -p /etc/apk/repositories.d /var/lock /var/run
docker exec "$CONTAINER_NAME" sh -c '
printf "https://downloads.openwrt.org/releases/25.12.4/targets/x86/64/packages/packages.adb\nhttps://downloads.openwrt.org/releases/25.12.4/packages/x86_64/base/packages.adb\nhttps://downloads.openwrt.org/releases/25.12.4/packages/x86_64/luci/packages.adb\nhttps://downloads.openwrt.org/releases/25.12.4/packages/x86_64/packages/packages.adb\nhttps://downloads.openwrt.org/releases/25.12.4/packages/x86_64/routing/packages.adb\n" > /etc/apk/repositories.d/distfeeds.list
apk add --no-cache --allow-untrusted \
luci-base luci-mod-admin-full luci-proto-ppp \
uhttpd uhttpd-mod-ubus ucode-mod-lua \
ca-certificates curl
'
docker commit "$CONTAINER_NAME" "$BASE_IMAGE"
docker rm -f "$CONTAINER_NAME"
echo "Built $BASE_IMAGE"

View File

@@ -0,0 +1,95 @@
#!/bin/sh
# openwrt-luci-entrypoint.sh
#
# Starts ubusd, rpcd, configures the br-zt bridge, seeds UCI state,
# and runs uhttpd in the foreground (the only foreground process).
set -eu
WIBLAN_CIDR="${ZTG_WIBLAN_CIDR:-10.99.13.0/24}"
# ── 1. Start ubusd first (required for rpcd + uci) ──────────────────────────
rm -f /var/run/ubus/ubus.sock /tmp/run/ubus/ubus.sock
rm -f /tmp/lock/procd_*.lock
mkdir -p /var/run/ubus
/sbin/ubusd &
UBUSD_PID=$!
# Wait for ubus socket (up to 10s)
for _i in 1 2 3 4 5 6 7 8 9 10; do
if [ -S /var/run/ubus/ubus.sock ]; then break; fi
sleep 1
done
if ! ubus list >/dev/null 2>&1; then
echo "ERROR: ubusd did not start in time" >&2
kill $UBUSD_PID 2>/dev/null || true
exit 1
fi
# ── 2. Start rpcd ────────────────────────────────────────────────────────────
/sbin/rpcd &
for _i in 1 2 3 4 5; do
if ubus call system board >/dev/null 2>&1; then break; fi
sleep 1
done
# ── 3. Seed root password (for LuCI login) ───────────────────────────────────
if [ -f /etc/shadow ]; then
sed -i 's|^root:.*|root::0:0:99999:7:::|' /etc/shadow
fi
# ── 4a. Seed zt-gateway config from host staging if present ─────────────────
if [ -f /host-config/zt-gateway ] && [ ! -f /etc/config/zt-gateway ]; then
cp /host-config/zt-gateway /etc/config/zt-gateway
fi
# ── 4. Configure gateway switch mode to initial state ────────────────────────
if command -v uci >/dev/null 2>&1; then
uci set zt-gateway.global.active_gateway='amsterdam' 2>/dev/null || true
uci set zt-gateway.global.switch_mode='force' 2>/dev/null || true
uci set zt-gateway.global.drain_timeout='600' 2>/dev/null || true
uci commit zt-gateway 2>/dev/null || true
fi
echo "[entrypoint] ubusd + rpcd + config done"
# ── 5. Network setup (bridge + routing) ──────────────────────────────────────
# The target bridge device (used by zt-gateway-switch and health checks).
BRIDGE="${ZTG_BRIDGE:-br-zt}"
# Detect the interface that currently holds the 10.99.12.x address.
SOURCE_IFACE=$(ip -o -4 addr show 2>/dev/null \
| awk '$4 ~ /^10\.99\.12\./ {print $2; exit}')
if [ -z "$SOURCE_IFACE" ]; then
echo "WARNING: no 10.99.12.x interface found (expected zt-exit-net); using Docker bridge"
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects 2>/dev/null || true
else
ip link add name "$BRIDGE" type bridge 2>/dev/null || true
ip link set "$BRIDGE" up
ADDR=$(ip -o -4 addr show dev "$SOURCE_IFACE" \
| awk '$4 ~ /^10\.99\.12\./ {print $4; exit}')
if [ -n "$ADDR" ]; then
ip addr del "$ADDR" dev "$SOURCE_IFACE" 2>/dev/null || true
ip addr add "$ADDR" dev "$BRIDGE"
ip link set "$SOURCE_IFACE" master "$BRIDGE"
fi
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects 2>/dev/null || true
echo 0 > /proc/sys/net/ipv4/conf/"$BRIDGE"/send_redirects 2>/dev/null || true
ip rule del from "$WIBLAN_CIDR" table 100 2>/dev/null || true
ip rule add from "$WIBLAN_CIDR" table 100 priority 100
ip route replace default via 10.99.12.3 dev "$BRIDGE" 2>/dev/null || true
ip route replace "$WIBLAN_CIDR" dev "$BRIDGE" table 1 2>/dev/null || true
echo "[entrypoint] networking: SOURCE=$SOURCE_IFACE BRIDGE=$BRIDGE ADDR=$ADDR"
fi
echo "[entrypoint] starting uhttpd..."
# ── 6. Run uhttpd in foreground (replaces shell) ─────────────────────────────
exec uhttpd -f -p 80 -h /www -u /ubus -a -r "OpenWRT-Test-Router"