Files

36 lines
1.2 KiB
Bash
Raw Permalink Normal View History

2026-07-18 10:02:43 +03:00
#!/bin/sh
# Container entrypoint for awg_profiler.
#
# The AmneziaWG stack is baked into the image at build time, so the profiler's
# "install-deps" step is a no-op here. We seed the deps-installed flag that
# init-server / the web setup wizard require, enable IP forwarding, then hand
# off to the profiler with whatever command was passed (defaults to `web`).
set -e
: "${AWG_PROFILER_DIR:=/data}"
export AWG_PROFILER_DIR
mkdir -p "$AWG_PROFILER_DIR" /etc/amnezia/amneziawg
# Seed the deps-installed state so init-server doesn't demand `install-deps`
# (packages are already present in the image). Written only if absent so it
# never clobbers real state on a persistent volume.
STATE_FILE="$AWG_PROFILER_DIR/awg_state.json"
if [ ! -f "$STATE_FILE" ]; then
cat > "$STATE_FILE" <<EOF
{
"deps_installed": true,
"installed_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"os_id": "alpine",
"os_version": "container"
}
EOF
chmod 0600 "$STATE_FILE"
fi
# Enable forwarding so WG→internet routing works. Requires NET_ADMIN; ignore
# failure (e.g. read-only sysctl) — the operator can also pass --sysctl.
sysctl -w net.ipv4.ip_forward=1 >/dev/null 2>&1 || true
exec /usr/local/bin/awg_profiler "$@"