fix(deploy): keep existing manual TUN passthrough on reused CTs (#6)
create-ct.sh only recognised devN passthrough and added dev0 on top of a manual lxc.mount.entry for /dev/net/tun (left by earlier Tailscale setups), so the CT failed to start in the autodev hook (EEXIST). Detection now lives in ct-config.sh with a regression test.
This commit is contained in:
+3
-1
@@ -58,6 +58,8 @@ apt signing-key compatibility issues on Debian 13. Rerun the installer to update
|
||||
Node 22 security releases; unattended upgrades cover Debian packages only.
|
||||
Build tools support node-pty compilation. Claude uses its native installer.
|
||||
|
||||
Local deployment regression: `bash deploy/test/template-picker.test.sh`.
|
||||
Local deployment regressions: `bash deploy/test/template-picker.test.sh` and
|
||||
`bash deploy/test/ct-config.test.sh`. Existing CTs with a manual TUN mount entry
|
||||
(earlier Tailscale setups) keep it; no `dev0` is added on top.
|
||||
The scripts require bash, use LF endings, and avoid early-consuming pipelines
|
||||
under pipefail. Proxmox, systemd, Tailscale and SSH require deployment validation.
|
||||
|
||||
@@ -4,6 +4,8 @@ set -euo pipefail
|
||||
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=deploy/proxmox/template-picker.sh
|
||||
source "$script_dir/template-picker.sh"
|
||||
# shellcheck source=deploy/proxmox/ct-config.sh
|
||||
source "$script_dir/ct-config.sh"
|
||||
ctid=${CTID:-501}
|
||||
[[ $ctid =~ ^[0-9]+$ ]] || { echo 'Invalid CTID' >&2; exit 1; }
|
||||
arch=$(dpkg --print-architecture)
|
||||
@@ -44,7 +46,7 @@ if [[ $features != *nesting=1* ]]; then
|
||||
needs_restart=1
|
||||
fi
|
||||
pct set "$ctid" --onboot 1
|
||||
if [[ $config != *'path=/dev/net/tun'* && $config != *'dev0: /dev/net/tun'* ]]; then
|
||||
if ! has_tun_passthrough <<< "$config"; then
|
||||
[[ $config != *'dev0:'* ]] || { echo 'dev0 already occupied; configure /dev/net/tun passthrough manually' >&2; exit 1; }
|
||||
pct set "$ctid" --dev0 /dev/net/tun
|
||||
needs_restart=1
|
||||
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Input: pct config output. True if /dev/net/tun already reaches the CT, either as a
|
||||
# devN passthrough or as a manual lxc.mount.entry (e.g. an earlier Tailscale setup).
|
||||
# Adding dev0 on top of a manual entry makes the CT fail to start (autodev hook, EEXIST).
|
||||
has_tun_passthrough() {
|
||||
grep -Eq '^(dev[0-9]+: (path=)?/dev/net/tun(,|$)|lxc\.mount\.entry: */dev/net/tun[[:space:]])'
|
||||
}
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
# shellcheck source=deploy/proxmox/ct-config.sh
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/../proxmox/ct-config.sh"
|
||||
base='arch: amd64
|
||||
features: nesting=1
|
||||
unprivileged: 1'
|
||||
has_tun_passthrough <<< "$base
|
||||
dev0: /dev/net/tun"
|
||||
has_tun_passthrough <<< "$base
|
||||
dev1: path=/dev/net/tun,mode=0666"
|
||||
# Manual Tailscale-style setup: adding dev0 on top makes the CT fail to start (EEXIST).
|
||||
has_tun_passthrough <<< "$base
|
||||
lxc.cgroup2.devices.allow: c 10:200 rwm
|
||||
lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file"
|
||||
if has_tun_passthrough <<< "$base"; then exit 1; fi
|
||||
if has_tun_passthrough <<< "$base
|
||||
dev0: /dev/net/tunnel"; then exit 1; fi
|
||||
printf '5 CT config checks passed\n'
|
||||
Reference in New Issue
Block a user