create-lxc: prompt for web UI autostart, enable it by default
This commit is contained in:
1 parent
eaca8305ae
commit
d6e846c7a0
2 files changed
+38
-9
No files matched your search
@@ -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)"
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
|
||||
+35
-8
@@ -66,6 +66,22 @@ if [[ -z "${ROOT_PASSWORD:-}" ]]; then
|
||||
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 --------------------------------------------------------------
|
||||
VMID=$(pvesh get /cluster/nextid)
|
||||
log "VMID=$VMID hostname=$HOSTNAME cores=$CORES mem=${MEMORY}MiB disk=${DISK}GiB"
|
||||
@@ -156,15 +172,26 @@ if [[ -n "${ROOT_PASSWORD:-}" ]]; then
|
||||
'
|
||||
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
|
||||
|
||||
[create-lxc] container $VMID ($HOSTNAME) provisioned.
|
||||
[create-lxc] finish configuration inside the LXC:
|
||||
pct enter $VMID
|
||||
vi /etc/wireguard/wg0.conf # keys, endpoint, LAN iface
|
||||
vi /etc/wirecon/wirecon.conf # thresholds (optional)
|
||||
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
|
||||
${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: pct enter $VMID && vi …)
|
||||
- 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
|
||||
EOF
|
||||
Reference in new issue
Block a user