#!/usr/bin/env bash # Install the XAMXAM server runtime stack on the fresh Debian box. # # This is the "apt-get install" bootstrap you'd run manually on a greenfield # Debian server (Debian trixie — ships PHP 8.4, which the project requires) # before running the project's setup/deploy scripts. It installs only the # packages; the project's own scripts (setup-server.sh / deploy-server.sh / # provision-server-env.sh / just deploy*) handle directories, permissions, # nginx config, .env and migrations, so the recipes stay the thing under test. # # Run on the HOST through the test-env shim so `xamxam` resolves to the podman # box (NOT production): # PATH=test-env/bin:$PATH bash test-env/scripts/provision-server-packages.sh # or # just test-env-provision # # The install block is written to a temp file, rsynced to the box and run with # `sudo bash` (mirroring how the project's own scripts are deployed and run). set -euo pipefail TARGET="${1:-xamxam}" INSTALL_SH="/tmp/xamxam-provision-packages.sh" cat > "$INSTALL_SH" <<'REMOTE' #!/usr/bin/env bash set -euo pipefail export DEBIAN_FRONTEND=noninteractive # Rootless podman can leave /var/lib/apt/lists/partial missing, which makes # apt-get update silently fail. Recreate it before updating. install -d -m 755 /var/lib/apt/lists/partial 2>/dev/null || mkdir -p /var/lib/apt/lists/partial chown _apt:root /var/lib/apt/lists/partial 2>/dev/null || true apt-get update # ── Web + PHP 8.4 ────────────────────────────────────────────────────────── # nginx ships /etc/nginx/snippets/fastcgi-php.conf (referenced by the project # xamxam.conf). php8.4-fpm exposes unix:/run/php/php8.4-fpm.sock (the socket # path the nginx config fastcgi_passes to). apt-get install -y --no-install-recommends \ nginx \ php8.4-fpm \ php8.4-cli \ php8.4-curl \ php8.4-sqlite3 \ php8.4-mbstring \ php8.4-xml # ── Deploy utilities (what the just recipes call on the server) ──────────── # composer installs deps during `just deploy-deps`; `just` runs recipes. apt-get install -y --no-install-recommends \ composer \ sqlite3 \ gzip \ rsync \ git \ just \ openssh-client REMOTE echo "▶ Installing XAMXAM server packages on $TARGET (Debian trixie)…" # No -e here: the test-env rsync shim injects the correct ssh transport # (`real-rsync -e "/usr/sbin/ssh -F …/config" …`). Passing `-e ssh` ourselves # would override the shim and route to the host's real ~/.ssh/config (prod!). rsync -a "$INSTALL_SH" "$TARGET:$INSTALL_SH" ssh "$TARGET" "sudo bash '$INSTALL_SH'" ssh "$TARGET" "rm -f '$INSTALL_SH'" rm -f "$INSTALL_SH" echo "▶ Ensuring php8.4-fpm and nginx start automatically with systemd…" ssh "$TARGET" "sudo systemctl enable --now nginx php8.4-fpm" || true echo "✓ Packages installed. Next:" echo " just test-env-run # just deploy (app + nginx + deps + migrate)" echo " just test-env-run recipe=setup-server # role/user/dir bootstrap" echo " just test-env-run recipe=provision-server # full server provisioning chain"