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:
95
docker/openwrt-luci-entrypoint.sh
Executable file
95
docker/openwrt-luci-entrypoint.sh
Executable 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"
|
||||
Reference in New Issue
Block a user