phoebus_os/installer/tests/vm/install.sh
Phoebus b8152054b6
Some checks are pending
ci / test (push) Waiting to run
fix(installer): harden boot recovery and desktop reliability
2026-10-01 07:03:42 -07:00

67 lines
2.3 KiB
Bash
Executable file

#!/bin/bash
# Guest-side automation for a disposable VM installation.
#
# Run inside the Phoebus live environment. It executes the static Rust
# installer and sys embedded in the candidate ISO, fetches only a test
# configuration and verified stage3 from the host HTTP server (QEMU user
# networking reaches the host at 10.0.2.2), supplies secrets from 0600 files,
# and drives the deterministic backend with --install. It never uses the TUI.
#
# Environment:
# PHOEBUS_BASE_URL host base URL (default http://10.0.2.2:8000)
# PHOEBUS_CONFIG config file name on the server (default test-mango.conf)
# LUKS_PASSPHRASE LUKS passphrase (kept in a 0600 temp file, never logged)
# USER_PASSWORD user password
#
# The test configuration pins STAGE3_URL to the same HTTP server so the
# stage3 checksum is verified without re-downloading from the internet.
set -u
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
export PHOEBUS_LOG_ECHO=yes
BASE="${PHOEBUS_BASE_URL:-http://10.0.2.2:8000}"
CONF="${PHOEBUS_CONFIG:-test-mango.conf}"
echo "===PHOEBUS-DRIVER-START==="
umask 077
printf '%s' "${LUKS_PASSPHRASE:-phoebus-luks-test}" >/tmp/luks.pw
printf '%s' "${USER_PASSWORD:-phoebus-user-test}" >/tmp/user.pw
chmod 600 /tmp/luks.pw /tmp/user.pw
cd /tmp || exit 1
PHOEBUS=/usr/local/bin/phoebus-installer
SYS=/usr/local/bin/sys
if [ ! -x "$PHOEBUS" ] || [ ! -x "$SYS" ]; then
echo "===ISO-PAYLOAD-MISSING==="; poweroff -f; exit 1
fi
echo "===ISO-INSTALLER-SHA256=$(sha256sum "$PHOEBUS" | cut -d' ' -f1)==="
curl -fsSL "$BASE/$CONF" -o /tmp/test.conf
echo "=== INSTALLER VERSION ==="
"$PHOEBUS" --version
echo "=== DISKS BEFORE ==="
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
"$PHOEBUS" --config /tmp/test.conf --install --yes --no-ai \
--luks-passphrase-file /tmp/luks.pw --user-password-file /tmp/user.pw
rc=$?
echo "===INSTALL-RC=$rc==="
LOG=/run/phoebus-installer/install.log
[ -r "$LOG" ] || LOG=/tmp/phoebus-installer/install.log
[ -r "$LOG" ] || LOG=/var/log/phoebus-installer/install.log
echo "=== LOG TAIL ==="
tail -n 60 "$LOG" 2>/dev/null
echo "===SECRET-SCAN==="
if grep -a -e "${LUKS_PASSPHRASE:-phoebus-luks-test}" \
-e "${USER_PASSWORD:-phoebus-user-test}" "$LOG" 2>/dev/null; then
echo "SECRET_LEAK_FOUND"
else
echo "NO_SECRET_LEAK"
fi
sync
echo "===POWEROFF==="
poweroff -f