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:
+4
-1
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
[[ $EUID == 0 ]] || { echo 'Run as root inside Debian 13' >&2; exit 1; }
|
||||
# `pct exec` starts with PATH=/sbin:/bin:/usr/sbin:/usr/bin; Node and pnpm live in /usr/local/bin.
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
# shellcheck source=/dev/null
|
||||
source /etc/os-release
|
||||
[[ $ID == debian && $VERSION_ID == 13 ]] || { echo 'Debian 13 required' >&2; exit 1; }
|
||||
@@ -22,7 +24,8 @@ curl -fsSL "https://nodejs.org/dist/latest-v22.x/$node_file" -o "$node_temp/$nod
|
||||
awk -v file="$node_file" '$2 == file' "$node_temp/SHASUMS256.txt" > "$node_temp/checksum"
|
||||
(cd "$node_temp"; sha256sum -c checksum)
|
||||
mkdir "$node_temp/unpacked"
|
||||
tar -xJf "$node_temp/$node_file" -C "$node_temp/unpacked" --strip-components=1
|
||||
# Root-owned: tar as root would keep the archive's uid, and cp -a would carry it into /usr/local.
|
||||
tar --no-same-owner -xJf "$node_temp/$node_file" -C "$node_temp/unpacked" --strip-components=1
|
||||
# Replace the executable rather than truncating one a running service uses.
|
||||
install -m 0755 "$node_temp/unpacked/bin/node" /usr/local/bin/node
|
||||
rm "$node_temp/unpacked/bin/node"
|
||||
|
||||
Reference in New Issue
Block a user