Files
awg-profiler-golang/entrypoint.mint.sh
T

39 lines
1.4 KiB
Bash
Raw Normal View History

2026-07-18 10:02:43 +03:00
#!/bin/bash
# Container entrypoint for awg_profiler — Linux Mint image (Dockerfile.mint).
#
# Identical role to entrypoint.sh (Alpine): the AmneziaWG stack is baked into
# the image at build time, so "install-deps" 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`). Split into its own file only because the
# seeded os_id/os_version below differ from the Alpine image.
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
OS_VERSION="$(. /etc/os-release && echo "$VERSION_ID")"
cat > "$STATE_FILE" <<EOF
{
"deps_installed": true,
"installed_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"os_id": "linuxmint",
"os_version": "${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 "$@"