#!/bin/bash # Side-channel overlay used ONLY by the QEMU smoke-test harness. # Sourced into the live ISO at /usr/local/share/installer/install.conf.d/ # and /etc/profile.d/. Forces unattended + test-mode behaviour and enables # sshd in the installed system so the harness can ssh in. set -Eeuo pipefail PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" DEST="${1:?usage: $0 }" mkdir -p "$DEST/etc/profile.d" cat > "$DEST/etc/profile.d/99-void-installer-test.sh" < "$DEST/usr/local/share/installer/install.conf.d/99-test.conf" <<'EOF' # Test overrides (qemu smoke test) SSHD_ENABLE="yes" DEFAULT_DISK="/dev/vda" DEFAULT_ROOT_PART="/dev/vda5" DEFAULT_EFI_PART="/dev/vda1" # Use the local xbps proxy on the host (10.0.2.2 inside QEMU's user net). INSTALL_REPO_URL="http://10.0.2.2:3142/current" # Quieter zram in tiny VM ZRAM_SIZE_PCT="25" EOF chmod 0644 "$DEST/usr/local/share/installer/install.conf.d/99-test.conf" # Drop a public key the harness can use to ssh in as moze without a password. # Generated below (or supplied via TEST_PUBKEY env) and added to authorized_keys # under /etc/installer-ssh/ so postinstall.sh copies it into ~/.ssh/. mkdir -p "$DEST/etc/installer-ssh" if [[ -n "${TEST_PUBKEY:-}" ]]; then echo "$TEST_PUBKEY" > "$DEST/etc/installer-ssh/authorized_keys" chmod 0600 "$DEST/etc/installer-ssh/authorized_keys" fi # Enable an autostart `sshd` already inside the live env so the harness # can ssh into the live ISO too if needed (debug). mkdir -p "$DEST/etc/runit/runsvdir/default" ln -sf /etc/sv/sshd "$DEST/etc/runit/runsvdir/default/sshd" 2>/dev/null || true # Autologin root on ttyS0 so the installer's .bash_profile fires under # QEMU's `-display none -serial file:...` (no tty1 attached). mkdir -p "$DEST/etc/sv/agetty-ttyS0-autologin" cat > "$DEST/etc/sv/agetty-ttyS0-autologin/run" <<'EOF' #!/bin/sh exec /sbin/agetty --autologin root --noclear -L 115200 ttyS0 vt100 EOF chmod 0755 "$DEST/etc/sv/agetty-ttyS0-autologin/run" ln -sf /etc/sv/agetty-ttyS0-autologin "$DEST/etc/runit/runsvdir/default/agetty-ttyS0-autologin" # Make .bash_profile fire on ttyS0 AND tty1 (interactive GTK QEMU uses tty1). mkdir -p "$DEST/root" cat > "$DEST/root/.bash_profile" <<'EOF' case "$(tty)" in /dev/ttyS0|/dev/tty1) # Atomic single-instance lock. mkdir is atomic; only ONE tty wins. # Previously the check-then-touch race let both tty1 and ttyS0 enter, # running install-void twice in parallel and corrupting /mnt. if mkdir /tmp/.installer-lock 2>/dev/null; then echo "Void Linux Installer (xps9700) — TEST MODE" # Bring up networking via dhcpcd (live ISO doesn't autostart it). echo " bringing up network..." dhcpcd -b 2>/dev/null || true for i in $(seq 1 20); do if curl -sf --max-time 1 http://10.0.2.2:3142/ >/dev/null 2>&1; then echo " network up after ${i}s" break fi sleep 1 done sleep 1 set -x /usr/local/sbin/install-void 2>&1 | tee /tmp/installer.log rc=${PIPESTATUS[0]} set +x if [ "$rc" -ne 0 ]; then echo "===== INSTALLER FAILED rc=$rc =====" echo "--- ip addr ---" ip addr 2>&1 | head -20 echo "--- ip route ---" ip route 2>&1 echo "--- /etc/resolv.conf ---" cat /etc/resolv.conf 2>/dev/null echo "--- curl proxy test ---" curl -sv --max-time 3 http://10.0.2.2:3142/ 2>&1 | head -10 echo "--- /tmp/installer.log (tail) ---" tail -100 /tmp/installer.log 2>/dev/null echo "===== END FAIL DUMP =====" exec /bin/bash fi echo "Install complete. Powering off." poweroff fi ;; esac EOF chmod 0644 "$DEST/root/.bash_profile" echo ">>> test overlay staged at $DEST"