initial commit: wirecon WireGuard stack

Rootless-Docker server (wireguard-go + Caddy sharing netns) and
unprivileged-LXC client (kernel WG + systemd watchdog/monitor/MTU-probe)
with curl-pipeable bootstrap. Tuned for Telekom DSL/LTE Hybrid uplinks.
This commit is contained in:
d4nn13 committed 2026-04-19 18:20:21 +02:00
commit 49b01dfcd3
19 files changed
+770

No files matched your search

Executable
+100
View File
@@ -0,0 +1,100 @@
#!/bin/bash
# Installer for the LXC side. Run as root inside the LXC.
#
# sudo ./install.sh
#
# Idempotent: re-running only updates files that changed. Does NOT touch
# wg0.conf if it already exists (so real keys aren't clobbered).
set -euo pipefail
if [[ $EUID -ne 0 ]]; then
echo "must run as root" >&2
exit 1
fi
SRC="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
log() { printf '[install] %s\n' "$*"; }
# --- packages ---------------------------------------------------------------
log "installing packages"
if command -v apt-get >/dev/null; then
DEBIAN_FRONTEND=noninteractive apt-get update -q
DEBIAN_FRONTEND=noninteractive apt-get install -yq \
wireguard wireguard-tools iptables iproute2 iputils-ping conntrack
elif command -v dnf >/dev/null; then
dnf install -y wireguard-tools iptables iproute iputils conntrack-tools
else
echo "unsupported distro: need apt-get or dnf" >&2
exit 1
fi
# --- /dev/net/tun sanity ----------------------------------------------------
if [[ ! -e /dev/net/tun ]]; then
cat >&2 <<'EOF'
ERROR: /dev/net/tun is not present in this unprivileged LXC.
On the Proxmox host, append proxmox/lxc.conf.snippet to
/etc/pve/lxc/<VMID>.conf
and restart the container.
EOF
exit 1
fi
# --- files ------------------------------------------------------------------
install -d -m 0755 /etc/wirecon /etc/wireguard /usr/local/bin \
/etc/systemd/system/wg-quick@wg0.service.d
log "deploying scripts"
install -m 0755 "$SRC/usr/local/bin/wirecon-watchdog.sh" /usr/local/bin/
install -m 0755 "$SRC/usr/local/bin/wirecon-monitor.sh" /usr/local/bin/
install -m 0755 "$SRC/usr/local/bin/wirecon-mtu-probe.sh" /usr/local/bin/
log "deploying systemd units"
install -m 0644 "$SRC/etc/systemd/system/wirecon-watchdog.service" /etc/systemd/system/
install -m 0644 "$SRC/etc/systemd/system/wirecon-watchdog.timer" /etc/systemd/system/
install -m 0644 "$SRC/etc/systemd/system/wirecon-monitor.service" /etc/systemd/system/
install -m 0644 "$SRC/etc/systemd/system/wg-quick@wg0.service.d/override.conf" \
/etc/systemd/system/wg-quick@wg0.service.d/override.conf
if [[ ! -e /etc/wirecon/wirecon.conf ]]; then
log "installing default /etc/wirecon/wirecon.conf"
install -m 0644 "$SRC/etc/wirecon/wirecon.conf" /etc/wirecon/wirecon.conf
else
log "keeping existing /etc/wirecon/wirecon.conf"
fi
if [[ ! -e /etc/wireguard/wg0.conf ]]; then
log "installing wg0.conf.example → /etc/wireguard/wg0.conf (EDIT BEFORE STARTING)"
install -m 0600 "$SRC/etc/wireguard/wg0.conf.example" /etc/wireguard/wg0.conf
EDIT_REQUIRED=1
else
log "keeping existing /etc/wireguard/wg0.conf"
EDIT_REQUIRED=0
fi
# --- systemd wiring ---------------------------------------------------------
systemctl daemon-reload
if [[ "$EDIT_REQUIRED" == "1" ]]; then
cat <<'EOF'
NEXT STEPS:
1. Generate keys, edit /etc/wireguard/wg0.conf (server pubkey, endpoint,
private key, LAN iface name in PostUp rules).
2. Tune /etc/wirecon/wirecon.conf if defaults don't fit.
3. Start everything:
systemctl enable --now wg-quick@wg0
systemctl enable --now wirecon-watchdog.timer
systemctl enable --now wirecon-monitor.service
4. Watch it:
journalctl -f -t wirecon-watchdog -t wirecon-monitor
EOF
else
log "enabling + (re)starting services"
systemctl enable --now wg-quick@wg0
systemctl enable --now wirecon-watchdog.timer
systemctl enable --now wirecon-monitor.service
systemctl restart wirecon-monitor.service
log "done. tail logs with: journalctl -f -t wirecon-watchdog -t wirecon-monitor"
fi