auto-start services, prompt for WG + LAN nets, fix busybox httpd applet

- create-lxc.sh prompts for WIRECON_NET / PEER_IP / CLIENT_IP / LAN_CIDR
  (defaults 10.13.13.0/24, .1, .2, 192.168.1.0/24) and passes them through
  to the in-container bootstrap
- install.sh generates a placeholder /etc/wireguard/wg0.conf from those
  env vars instead of copying the static example, and updates PEER_IP in
  wirecon.conf on first install
- install.sh always enables + starts wg-quick, watchdog, monitor and
  (if WIRECON_WEB_AUTOSTART=yes, default yes) the web UI, even before
  keys are filled in — wg-quick will fail until then, and the web UI
  is the way to finish configuration
- apk installs busybox-extras and wirecon-web now runs /usr/sbin/httpd
  (fixes "httpd: applet not found" on base busybox)
- create-lxc.sh drops its own web-UI start block (install.sh owns it)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
d4nn13andClaude Opus 4.7 committed 2026-04-19 19:41:44 +02:00
1 parent 14fad9a49e
commit 78c3a790be
3 files changed
+112 -57

No files matched your search

+2 -2
View File
@@ -14,8 +14,8 @@ description="wirecon web UI (busybox httpd)"
: "${WEB_ROOT:=/var/www/wirecon}"
supervisor="supervise-daemon"
command="/bin/busybox"
command_args="httpd -f -v -p ${WEB_BIND}:${WEB_PORT} -h ${WEB_ROOT} -c /etc/wirecon/httpd.conf"
command="/usr/sbin/httpd"
command_args="-f -v -p ${WEB_BIND}:${WEB_PORT} -h ${WEB_ROOT} -c /etc/wirecon/httpd.conf"
respawn_delay=5
respawn_max=0
output_log="/var/log/wirecon-web.log"
+65 -35
View File
@@ -27,6 +27,7 @@ log "installing packages"
apk add --no-cache \
bash \
nano \
busybox-extras \
wireguard-tools \
wireguard-tools-openrc \
iptables \
@@ -85,52 +86,81 @@ if [[ ! -L /etc/init.d/wg-quick.wg0 ]]; then
ln -s wg-quick /etc/init.d/wg-quick.wg0
fi
# --- env-driven defaults (propagated from create-lxc.sh / bootstrap.sh) -----
: "${WIRECON_NET:=10.13.13.0/24}"
: "${WIRECON_PEER_IP:=10.13.13.1}"
: "${WIRECON_CLIENT_IP:=10.13.13.2}"
: "${WIRECON_LAN_CIDR:=192.168.1.0/24}"
: "${WIRECON_WEB_AUTOSTART:=yes}"
# CIDR prefix (e.g. 24) — carry onto the client Address line.
WIRECON_NET_PREFIX="${WIRECON_NET##*/}"
[[ "$WIRECON_NET_PREFIX" == "$WIRECON_NET" ]] && WIRECON_NET_PREFIX=24
if [[ ! -e /etc/wirecon/wirecon.conf ]]; then
log "installing default /etc/wirecon/wirecon.conf"
log "installing default /etc/wirecon/wirecon.conf (PEER_IP=$WIRECON_PEER_IP)"
install -m 0644 "$SRC/etc/wirecon/wirecon.conf" /etc/wirecon/wirecon.conf
sed -i "s|^PEER_IP=.*|PEER_IP=${WIRECON_PEER_IP}|" /etc/wirecon/wirecon.conf
else
log "keeping existing /etc/wirecon/wirecon.conf"
fi
if [[ ! -e /etc/wireguard/wg0.conf ]]; then
log "seeding /etc/wireguard/wg0.conf from example (EDIT BEFORE STARTING)"
install -m 0600 "$SRC/etc/wireguard/wg0.conf.example" /etc/wireguard/wg0.conf
EDIT_REQUIRED=1
log "generating placeholder /etc/wireguard/wg0.conf (edit keys via web UI or nano)"
umask 077
cat > /etc/wireguard/wg0.conf <<EOF
# /etc/wireguard/wg0.conf — generated by wirecon install.sh
# Fill in PrivateKey, PublicKey, Endpoint. Until then wg-quick will fail to
# dial; the watchdog keeps retrying and the web UI lets you edit this file.
[Interface]
Address = ${WIRECON_CLIENT_IP}/${WIRECON_NET_PREFIX}
PrivateKey = REPLACE_WITH_CLIENT_PRIVATE_KEY
# Default 1280 for Telekom DSL/LTE Hybrid (GRE overlay eats headroom).
# Run wirecon-mtu-probe.sh to find a better value.
MTU = 1280
# MASQ traffic from the WG tunnel onto the LAN. Replace eth0 with the LXC's
# LAN interface name if it differs.
PostUp = sysctl -w net.ipv4.ip_forward=1
# LAN subnet: ${WIRECON_LAN_CIDR}
PostUp = iptables -t nat -A POSTROUTING -s ${WIRECON_NET} -o eth0 -j MASQUERADE
PostUp = iptables -A FORWARD -i %i -o eth0 -j ACCEPT
PostUp = iptables -A FORWARD -i eth0 -o %i -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
PostDown = iptables -t nat -D POSTROUTING -s ${WIRECON_NET} -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -o eth0 -j ACCEPT
PostDown = iptables -D FORWARD -i eth0 -o %i -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
[Peer]
PublicKey = REPLACE_WITH_SERVER_PUBLIC_KEY
Endpoint = REPLACE_WITH_SERVER_PUBLIC_HOST:51820
AllowedIPs = ${WIRECON_PEER_IP}/32
PersistentKeepalive = 25
EOF
chmod 0600 /etc/wireguard/wg0.conf
else
log "keeping existing /etc/wireguard/wg0.conf"
EDIT_REQUIRED=0
fi
# --- enable services --------------------------------------------------------
if [[ "$EDIT_REQUIRED" == "1" ]]; then
cat <<'EOF'
# --- enable + start services (always, even with placeholder keys) -----------
# wg-quick will fail until keys are filled in — that's fine. The watchdog
# will keep retrying, and the web UI is how you finish configuration.
log "enabling + starting services"
rc-update add wg-quick.wg0 default 2>/dev/null || true
rc-update add wirecon-watchdog default 2>/dev/null || true
rc-update add wirecon-monitor default 2>/dev/null || true
NEXT STEPS:
1. Generate keys and edit /etc/wireguard/wg0.conf:
- [Interface] PrivateKey + MTU + PostUp LAN iface name
- [Peer] Server PublicKey + Endpoint
2. Review /etc/wirecon/wirecon.conf (PEER_IP, thresholds).
3. Start everything:
rc-update add wg-quick.wg0 default
rc-update add wirecon-watchdog default
rc-update add wirecon-monitor default
rc-update add wirecon-web default # optional, http://<lxc>:8080
rc-service wg-quick.wg0 start
rc-service wirecon-watchdog start
rc-service wirecon-monitor start
rc-service wirecon-web start
4. Watch the logs:
tail -F /var/log/wirecon-watchdog.log /var/log/wirecon-monitor.log
EOF
rc-service wg-quick.wg0 start 2>/dev/null || log "wg-quick.wg0 failed to start (expected until keys are set in /etc/wireguard/wg0.conf)"
rc-service wirecon-watchdog start 2>/dev/null || true
rc-service wirecon-monitor start 2>/dev/null || true
if [[ "$WIRECON_WEB_AUTOSTART" == "yes" ]]; then
rc-update add wirecon-web default 2>/dev/null || true
rc-service wirecon-web start 2>/dev/null || true
log "web UI enabled on http://<lxc-ip>:${WEB_PORT:-8080}/"
else
log "enabling + (re)starting services"
rc-update add wg-quick.wg0 default 2>/dev/null || true
rc-update add wirecon-watchdog default 2>/dev/null || true
rc-update add wirecon-monitor default 2>/dev/null || true
rc-update add wirecon-web default 2>/dev/null || true
rc-service wg-quick.wg0 restart
rc-service wirecon-watchdog restart
rc-service wirecon-monitor restart
rc-service wirecon-web restart
log "done. UI: http://<lxc-ip>:${WEB_PORT:-8080}/ | logs: tail -F /var/log/wirecon-watchdog.log /var/log/wirecon-monitor.log"
log "web UI disabled (enable: rc-update add wirecon-web default && rc-service wirecon-web start)"
fi
log "done. logs: tail -F /var/log/wirecon-watchdog.log /var/log/wirecon-monitor.log"