fix(deploy): set PATH and keep Node files root-owned (#6)

pct exec runs with PATH=/sbin:/bin:/usr/sbin:/usr/bin, so install.sh failed
right after installing Node to /usr/local/bin ("node: command not found");
update.sh had the same gap for pnpm. Both scripts now set PATH explicitly.

tar ran as root kept the Node tarball's uid, and cp -a carried it into
/usr/local (bin directory and npm included), handing whichever CT user has
that uid write access to code root executes. Extract with --no-same-owner;
a rerun repairs an affected CT.
This commit is contained in:
Florian Schmidt
2026-11-16 09:45:53 +01:00
parent df489fa147
commit 4fe7e4e376
4 changed files with 21 additions and 2 deletions
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail
# Static guards for regressions seen on a real Proxmox deploy (full run needs Debian 13 as root).
dir="$(dirname "${BASH_SOURCE[0]}")/.."
path_line='export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
for script in install.sh update.sh; do
# pct exec omits /usr/local/bin: PATH must be set before the first command that needs node/pnpm.
first_path=$(grep -nxF "$path_line" "$dir/$script" | head -n1 | cut -d: -f1)
first_use=$(grep -nE '\b(node|pnpm|npm|corepack)\b' "$dir/$script" | grep -v '^[0-9]*:#' | head -n1 | cut -d: -f1)
[[ -n $first_path && $first_path -lt $first_use ]] || { echo "$script: PATH not set before node/pnpm use" >&2; exit 1; }
done
# Node tarball must not hand /usr/local to the archive's uid.
grep -qE '^tar --no-same-owner .*node_file' "$dir/install.sh" || { echo 'install.sh: tar keeps archive owners' >&2; exit 1; }
printf '3 install script checks passed\n'