fix(traefik): v1.0.0 binary with world-readable dynamic dir fallback
Keep the v1.0.0 codebase unchanged (main.go untouched). Two installer script fixes on top: - scripts/30-traefik.sh: make /etc/traefik and the dynamic dir 0755 (world-readable) instead of relying on the vps<->traefik group cross-link, so traefik can always read the dynamic dir regardless of install order or group membership. vps still owns the dir and writes as the owner. - scripts/40-panel.sh: fix the prebuilt-download EXIT trap to not reference a function-local variable under `set -u` (unbound variable skipped cleanup). Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
This commit is contained in:
1 parent
18b8542663
commit
2980e3a9ce
5 files changed
+17
-22
No files matched your search
@@ -26,7 +26,7 @@ always blocked for containers, both directions — anti-spam, no toggle.
|
||||
Both amd64 and arm64 are supported; testing has primarily been done on amd64.
|
||||
|
||||
```
|
||||
git clone https://github.com/bluebluesoda/lxc-hosting.git && cd lxc-hosting
|
||||
git clone https://github.com/bluebluesoda/vpsmgr.git && cd vpsmgr
|
||||
sudo ./install.sh # install the stable prebuilt binary
|
||||
#sudo ./install.sh --local-build # force a local build from source
|
||||
```
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
amd64/arm64 均可,主要在amd64上进行了测试
|
||||
|
||||
```
|
||||
git clone https://github.com/bluebluesoda/lxc-hosting.git && cd lxc-hosting
|
||||
git clone https://github.com/bluebluesoda/vpsmgr.git && cd vpsmgr
|
||||
sudo ./install.sh # 安装稳定版预编译二进制
|
||||
#sudo ./install.sh --local-build # 强制本地编译
|
||||
```
|
||||
|
||||
+7
-17
@@ -51,28 +51,18 @@ fi
|
||||
|
||||
if [[ ! -f /etc/systemd/system/traefik.service ]]; then
|
||||
# Fresh install: run Traefik as a dedicated unprivileged user that can only
|
||||
# read /etc/traefik (config + dynamic rules) and bind ports 80/443. The panel
|
||||
# (unprivileged 'vps') writes the dynamic files, so the two groups cross-link:
|
||||
# vps joins traefik (to traverse /etc/traefik) and traefik joins vps (to read
|
||||
# the dynamic dir, which vps owns). Existing installs are untouched.
|
||||
# read /etc/traefik (config + dynamic rules) and bind ports 80/443. The
|
||||
# dynamic dir is world-readable (traefik reads it as any other user) and
|
||||
# owned by 'vps' once that user exists; until then root owns it, and
|
||||
# ensureVPSUser (40-panel.sh -> vps install) chowns it to vps:vps 0755.
|
||||
if ! id -u traefik >/dev/null 2>&1; then
|
||||
useradd --system --no-create-home --home-dir /nonexistent --shell /usr/sbin/nologin traefik
|
||||
log "created unprivileged user 'traefik'"
|
||||
fi
|
||||
if id -u vps >/dev/null 2>&1; then
|
||||
usermod -aG traefik vps >/dev/null 2>&1 || true
|
||||
usermod -aG vps traefik >/dev/null 2>&1 || true
|
||||
log "cross-linked groups: vps<->traefik (panel writes dynamic, traefik reads it)"
|
||||
fi
|
||||
chown -R root:traefik /etc/traefik
|
||||
chmod 750 /etc/traefik
|
||||
# The panel user 'vps' is created later by 40-panel.sh / `vps install`; when
|
||||
# it does not exist yet, skip the chown here and let ensureVPSUser do it
|
||||
# (it re-chowns the dynamic dir on every install).
|
||||
if id -u vps >/dev/null 2>&1; then
|
||||
chown vps:vps /etc/traefik/dynamic
|
||||
fi
|
||||
chmod 750 /etc/traefik/dynamic
|
||||
chmod 755 /etc/traefik
|
||||
chown root:traefik /etc/traefik/dynamic
|
||||
chmod 755 /etc/traefik/dynamic
|
||||
chmod 640 /etc/traefik/traefik.yaml
|
||||
cp "$ROOT/configs/systemd/traefik.service" /etc/systemd/system/traefik.service
|
||||
systemctl daemon-reload
|
||||
|
||||
+7
-2
@@ -8,7 +8,7 @@ log(){ echo "[40] $*"; }
|
||||
die(){ echo "[40] error: $*" >&2; exit 1; }
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
REPO="bluebluesoda/lxc-hosting"
|
||||
REPO="bluebluesoda/vpsmgr"
|
||||
|
||||
ensure_go(){
|
||||
# Reuse a usable go on PATH (>= 1.21, toolchain auto-switch works) when one
|
||||
@@ -100,7 +100,12 @@ install_prebuilt(){
|
||||
*) log "warn: no prebuilt binary for $(uname -m), falling back to local build"; return 1 ;;
|
||||
esac
|
||||
dir="$(mktemp -d /tmp/vpsmgr-dl.XXXXXX)"
|
||||
trap 'rm -rf "$dir"' EXIT
|
||||
# EXIT trap for cleanup. Must NOT reference the local $dir: the trap string
|
||||
# is evaluated when the script EXITS, after the function returned and $dir
|
||||
# went out of scope — under `set -u` that would raise "unbound variable"
|
||||
# (and skip the cleanup) at the very end of a successful install. Globbing
|
||||
# the unique mktemp prefix is local-agnostic and only ever matches this dir.
|
||||
trap 'rm -rf /tmp/vpsmgr-dl.*' EXIT
|
||||
bin_url="https://github.com/$REPO/releases/latest/download/vps-$arch"
|
||||
sum_url="https://github.com/$REPO/releases/latest/download/SHA256SUMS"
|
||||
log "downloading prebuilt vpsmgr (linux/$arch) from GitHub releases..."
|
||||
|
||||
@@ -196,7 +196,7 @@ apt-get update && apt-get install -y nginx{{end}}">{{.InitScript}}</textarea>
|
||||
|
||||
</div>
|
||||
|
||||
<footer><a href="https://github.com/bluebluesoda/lxc-hosting" target="_blank" rel="noopener">Vpsmgr lite</a></footer>
|
||||
<footer><a href="https://github.com/bluebluesoda/vpsmgr" target="_blank" rel="noopener">Vpsmgr lite</a></footer>
|
||||
|
||||
<div class="overlay" id="pwModal">
|
||||
<div class="modal">
|
||||
|
||||
Reference in new issue
Block a user