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:
1 parent
14fad9a49e
commit
78c3a790be
3 files changed
+112
-57
No files matched your search
+45
-20
@@ -40,22 +40,39 @@ fi
|
||||
|
||||
log() { printf '[create-lxc] %s\n' "$*"; }
|
||||
|
||||
# --- web UI autostart -------------------------------------------------------
|
||||
# WIRECON_WEB_AUTOSTART=yes|no overrides the prompt. Default: yes (the UI is
|
||||
# how you'll edit wg0.conf / wirecon.conf without drop-to-shell).
|
||||
# --- interactive prompts (web UI + WG network) ------------------------------
|
||||
# All settings can be preset via env vars; the prompt is skipped when set.
|
||||
# WIRECON_WEB_AUTOSTART=yes|no, WIRECON_NET=CIDR, WIRECON_PEER_IP=ip,
|
||||
# WIRECON_CLIENT_IP=ip.
|
||||
_ask() { # _ask <varname> <prompt> <default>
|
||||
local var="$1" prompt="$2" default="$3" ans=""
|
||||
if [[ -n "${!var:-}" ]]; then return; fi
|
||||
if [[ -r /dev/tty && -w /dev/tty ]]; then
|
||||
printf '%s [%s]: ' "$prompt" "$default" >/dev/tty
|
||||
IFS= read -r ans </dev/tty || ans=""
|
||||
printf -v "$var" '%s' "${ans:-$default}"
|
||||
else
|
||||
printf -v "$var" '%s' "$default"
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ -z "${WIRECON_WEB_AUTOSTART:-}" ]]; then
|
||||
if [[ -r /dev/tty && -w /dev/tty ]]; then
|
||||
printf 'start web UI automatically on boot? [Y/n] ' >/dev/tty
|
||||
IFS= read -r _ans </dev/tty || _ans=""
|
||||
case "$_ans" in
|
||||
n|N|no|NO) WIRECON_WEB_AUTOSTART=no ;;
|
||||
*) WIRECON_WEB_AUTOSTART=yes ;;
|
||||
esac
|
||||
case "$_ans" in n|N|no|NO) WIRECON_WEB_AUTOSTART=no ;; *) WIRECON_WEB_AUTOSTART=yes ;; esac
|
||||
else
|
||||
WIRECON_WEB_AUTOSTART=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
_ask WIRECON_NET "wireguard tunnel network (CIDR)" "10.13.13.0/24"
|
||||
_ask WIRECON_PEER_IP "wireguard server (peer) IP" "10.13.13.1"
|
||||
_ask WIRECON_CLIENT_IP "wireguard client (this LXC) IP" "10.13.13.2"
|
||||
_ask WIRECON_LAN_CIDR "local LAN subnet (CIDR)" "192.168.1.0/24"
|
||||
|
||||
log "wg net=$WIRECON_NET peer=$WIRECON_PEER_IP client=$WIRECON_CLIENT_IP lan=$WIRECON_LAN_CIDR web_autostart=$WIRECON_WEB_AUTOSTART"
|
||||
|
||||
# --- pick VMID --------------------------------------------------------------
|
||||
VMID=$(pvesh get /cluster/nextid)
|
||||
log "VMID=$VMID hostname=$HOSTNAME cores=$CORES mem=${MEMORY}MiB disk=${DISK}GiB"
|
||||
@@ -128,7 +145,15 @@ log "installing bootstrap prereqs inside LXC"
|
||||
pct exec "$VMID" -- sh -c 'apk add --no-cache bash curl ca-certificates >/dev/null'
|
||||
|
||||
log "running bootstrap from $BOOTSTRAP_URL"
|
||||
pct exec "$VMID" -- sh -c "curl -fsSL '$BOOTSTRAP_URL' | WIRECON_REPO='$WIRECON_REPO' WIRECON_REF='$WIRECON_REF' bash"
|
||||
pct exec "$VMID" -- sh -c "curl -fsSL '$BOOTSTRAP_URL' \
|
||||
| WIRECON_REPO='$WIRECON_REPO' \
|
||||
WIRECON_REF='$WIRECON_REF' \
|
||||
WIRECON_NET='$WIRECON_NET' \
|
||||
WIRECON_PEER_IP='$WIRECON_PEER_IP' \
|
||||
WIRECON_CLIENT_IP='$WIRECON_CLIENT_IP' \
|
||||
WIRECON_LAN_CIDR='$WIRECON_LAN_CIDR' \
|
||||
WIRECON_WEB_AUTOSTART='$WIRECON_WEB_AUTOSTART' \
|
||||
bash"
|
||||
|
||||
# --- tty1 auto-login (for Proxmox web Console) ------------------------------
|
||||
# Drop a /usr/local/sbin/autologin-root wrapper and point getty at it so the
|
||||
@@ -152,13 +177,14 @@ pct exec "$VMID" -- sh -c '
|
||||
pkill -KILL getty 2>/dev/null || true
|
||||
'
|
||||
|
||||
# --- optional: start web UI -------------------------------------------------
|
||||
# --- final summary ----------------------------------------------------------
|
||||
# install.sh (run by bootstrap) has already enabled + started wg-quick,
|
||||
# watchdog, monitor, and (if WIRECON_WEB_AUTOSTART=yes) the web UI. Keys
|
||||
# aren't filled in yet — wg-quick will be failing until you edit wg0.conf
|
||||
# in the web UI (or via the Proxmox Console).
|
||||
if [[ "$WIRECON_WEB_AUTOSTART" == "yes" ]]; then
|
||||
log "enabling + starting wirecon-web"
|
||||
pct exec "$VMID" -- sh -c 'rc-update add wirecon-web default && rc-service wirecon-web start'
|
||||
WEB_URL="http://${ip:-<lxc-ip>}:8080/"
|
||||
else
|
||||
log "wirecon-web left disabled (enable later: rc-update add wirecon-web default && rc-service wirecon-web start)"
|
||||
WEB_URL=""
|
||||
fi
|
||||
|
||||
@@ -168,12 +194,11 @@ cat <<EOF
|
||||
[create-lxc] shell: open Console in the Proxmox UI → root shell, no prompt
|
||||
[create-lxc] (or from the host: pct enter $VMID)
|
||||
${WEB_URL:+[create-lxc] web UI: $WEB_URL}
|
||||
[create-lxc] finish configuration:
|
||||
- edit /etc/wireguard/wg0.conf and /etc/wirecon/wirecon.conf
|
||||
(via the web UI above, or the Proxmox Console)
|
||||
- then start the tunnel services:
|
||||
rc-update add wg-quick.wg0 default && rc-service wg-quick.wg0 start
|
||||
rc-update add wirecon-watchdog default && rc-service wirecon-watchdog start
|
||||
rc-update add wirecon-monitor default && rc-service wirecon-monitor start
|
||||
- tail -F /var/log/wirecon-watchdog.log /var/log/wirecon-monitor.log
|
||||
[create-lxc] all services are already enabled + running; wg-quick will
|
||||
[create-lxc] fail until keys are configured. Finish setup by editing
|
||||
[create-lxc] /etc/wireguard/wg0.conf (PrivateKey, Peer PublicKey, Endpoint)
|
||||
[create-lxc] /etc/wirecon/wirecon.conf (thresholds — optional)
|
||||
[create-lxc] via the web UI above, then:
|
||||
[create-lxc] rc-service wg-quick.wg0 restart
|
||||
[create-lxc] tail -F /var/log/wirecon-watchdog.log /var/log/wirecon-monitor.log
|
||||
EOF
|
||||
Reference in new issue
Block a user