create-lxc: prompt for web UI autostart, enable it by default

This commit is contained in:
d4nn13 committed 2026-04-19 19:11:47 +02:00
1 parent eaca8305ae
commit d6e846c7a0
2 files changed
+38 -9

No files matched your search

+3 -1
View File
@@ -34,7 +34,9 @@ HOSTNAME=tunbox MEMORY=512 STORAGE=fast-nvme \
bash -c "$(curl -fsSL https://git.d4nn13.de/d4nn13/wirecon/raw/branch/main/proxmox/create-lxc.sh)" bash -c "$(curl -fsSL https://git.d4nn13.de/d4nn13/wirecon/raw/branch/main/proxmox/create-lxc.sh)"
``` ```
Available overrides: `HOSTNAME`, `CORES`, `MEMORY`, `DISK`, `BRIDGE`, `STORAGE`, `TEMPLATE_STORAGE`, `WIRECON_REPO`, `WIRECON_REF`, `ROOT_PASSWORD`. Available overrides: `HOSTNAME`, `CORES`, `MEMORY`, `DISK`, `BRIDGE`, `STORAGE`, `TEMPLATE_STORAGE`, `WIRECON_REPO`, `WIRECON_REF`, `ROOT_PASSWORD`, `WIRECON_WEB_AUTOSTART` (yes/no).
The script also asks (interactively, default **yes**) whether to enable the web UI on boot. Edit configs in-browser right after provisioning instead of `vi`'ing over `pct enter`.
### Root login ### Root login
+35 -8
View File
@@ -66,6 +66,22 @@ if [[ -z "${ROOT_PASSWORD:-}" ]]; then
fi fi
fi fi
# --- 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).
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
else
WIRECON_WEB_AUTOSTART=yes
fi
fi
# --- pick VMID -------------------------------------------------------------- # --- pick VMID --------------------------------------------------------------
VMID=$(pvesh get /cluster/nextid) VMID=$(pvesh get /cluster/nextid)
log "VMID=$VMID hostname=$HOSTNAME cores=$CORES mem=${MEMORY}MiB disk=${DISK}GiB" log "VMID=$VMID hostname=$HOSTNAME cores=$CORES mem=${MEMORY}MiB disk=${DISK}GiB"
@@ -156,15 +172,26 @@ if [[ -n "${ROOT_PASSWORD:-}" ]]; then
' '
fi fi
# --- optional: start web UI -------------------------------------------------
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
cat <<EOF cat <<EOF
[create-lxc] container $VMID ($HOSTNAME) provisioned. [create-lxc] container $VMID ($HOSTNAME) provisioned.
[create-lxc] finish configuration inside the LXC: ${WEB_URL:+[create-lxc] web UI: $WEB_URL}
pct enter $VMID [create-lxc] finish configuration:
vi /etc/wireguard/wg0.conf # keys, endpoint, LAN iface - edit /etc/wireguard/wg0.conf and /etc/wirecon/wirecon.conf
vi /etc/wirecon/wirecon.conf # thresholds (optional) (via the web UI above, or: pct enter $VMID && vi …)
rc-update add wg-quick.wg0 default && rc-service wg-quick.wg0 start - then start the tunnel services:
rc-update add wirecon-watchdog default && rc-service wirecon-watchdog start rc-update add wg-quick.wg0 default && rc-service wg-quick.wg0 start
rc-update add wirecon-monitor default && rc-service wirecon-monitor start rc-update add wirecon-watchdog default && rc-service wirecon-watchdog start
tail -F /var/log/wirecon-watchdog.log /var/log/wirecon-monitor.log rc-update add wirecon-monitor default && rc-service wirecon-monitor start
- tail -F /var/log/wirecon-watchdog.log /var/log/wirecon-monitor.log
EOF EOF