mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-06-28 13:29:28 +00:00
26 lines
846 B
Bash
26 lines
846 B
Bash
#!/usr/bin/env bash
|
|
|
|
# Shared router base, sourced by each scenario's router-entrypoint.sh
|
|
|
|
set -euo pipefail
|
|
|
|
# iptables needs the wan interface's name (eth0/eth1), but podman assigns those
|
|
# names arbitrarily — so look for the name using the wan IP,
|
|
# defined in the compose file.
|
|
wanif=$(ip -o -4 addr show | awk -v ip="$ROUTER_WAN_IP" '$0 ~ ip {print $2; exit}')
|
|
|
|
if ! iptables -t nat -A POSTROUTING -s "$LAN_SUBNET" -o "$wanif" -j MASQUERADE; then
|
|
echo "ERROR: iptables NAT failed. Load netfilter modules on the host:" >&2
|
|
echo " sudo modprobe iptable_nat nf_conntrack" >&2
|
|
exit 1
|
|
fi
|
|
iptables -P FORWARD ACCEPT
|
|
|
|
# Block until `compose down`. sleep runs in the background so the SIGTERM trap
|
|
# fires immediately instead of waiting for sleep to return.
|
|
hold_until_stopped() {
|
|
trap 'exit 0' TERM INT
|
|
sleep infinity &
|
|
wait
|
|
}
|