feat(deploy): one-step install/update from the Proxmox host (#6)

bootstrap.sh runs on the Proxmox host via
  bash -c "$(curl -fsSL .../deploy/proxmox/bootstrap.sh)"
It unpacks the repository into a temporary directory, runs
create-ct.sh and removes everything again; create-ct.sh also removes
the installer files it pushed into the CT. Nothing stays on the host.

install.sh now installs or updates: an existing checkout is pulled
(fast-forward, SHELLBOOK_REF pins are kept), the service is restarted
and health-checked, and the summary prints the address, the one-time
setup token while setup is pending, the Claude login state and the
SSH public key.

It also installs a root-owned `shellbook-update` that downloads the
installer from the repository and reruns it. Root never executes
scripts from /opt/shellbook, which the service user and its terminal
panel can modify, so deploy/update.sh is removed.

Verified in a Debian 13 container: fresh install, then an update that
pulls a new commit while a tampered checkout script is not executed;
bootstrap.test.sh checks that host and CT keep no installer files.
This commit is contained in:
Florian Schmidt
2026-11-16 10:57:42 +01:00
parent 5e60973ebf
commit 399628bf16
8 changed files with 152 additions and 41 deletions
+16 -7
View File
@@ -3,12 +3,21 @@ 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
# 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/install.sh" | head -n1 | cut -d: -f1)
first_use=$(grep -nE '\b(node|pnpm|npm|corepack)\b' "$dir/install.sh" | grep -v '^[0-9]*:#' | head -n1 | cut -d: -f1)
[[ -n $first_path && $first_path -lt $first_use ]] || { echo 'install.sh: PATH not set before node/pnpm use' >&2; exit 1; }
# 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'
# The root-run updater must not execute anything from the service-user-writable checkout.
updater=$(sed -n "/^cat > \/usr\/local\/sbin\/shellbook-update <<'EOF'$/,/^EOF$/p" "$dir/install.sh" | sed '1d;$d')
[[ -n $updater ]] || { echo 'install.sh: shellbook-update not generated' >&2; exit 1; }
bash -n <<< "$updater" || { echo 'shellbook-update: syntax error' >&2; exit 1; }
[[ $updater != */opt/shellbook* ]] || { echo 'shellbook-update: references /opt/shellbook' >&2; exit 1; }
[[ $updater == *"$path_line"* ]] || { echo 'shellbook-update: PATH not set' >&2; exit 1; }
# An existing checkout must be updated, not just rebuilt.
grep -q 'git_app pull --ff-only' "$dir/install.sh" || { echo 'install.sh: existing checkout is not pulled' >&2; exit 1; }
# Nothing may remain in the CT's /root after the Proxmox install.
grep -q 'rm -f /root/shellbook-install.env /root/shellbook-install.sh' "$dir/proxmox/create-ct.sh" \
|| { echo 'create-ct.sh: installer files left in the CT' >&2; exit 1; }
printf '8 install script checks passed\n'