mirror of
https://github.com/theupriser/steamify-cachyos-dev.git
synced 2026-10-05 12:45:56 +02:00
feat: scripts/vminstall.sh installs an ssh-ready test VM unattended; TESTPLAN.md; vm-install skill
This commit is contained in:
1 parent
0f57d86bae
commit
ac8f77cf4a
19 files changed
+705
-72
No files matched your search
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
# Runs in the live ISO as root (started by the systemd.run= boot parameter
|
||||
# that scripts/vminstall.sh passes): installs CachyOS unattended with its
|
||||
# headless installer (settings.json from the host), then makes the new
|
||||
# system a test VM (SSH key, passwordless sudo, test autologin), and powers
|
||||
# off. Everything it needs comes from the host's vminstall-server.py; the log
|
||||
# and the result go back there (PUT log / status).
|
||||
set -uo pipefail
|
||||
H="http://@HOST_IP@:@PORT@"
|
||||
LOG=/tmp/vminstall.log
|
||||
exec > >(tee -a "$LOG") 2>&1
|
||||
up() { curl -fsS -T "$LOG" "$H/install.log" >/dev/null 2>&1; }
|
||||
finish() { echo "== $1"; up; curl -fsS -X PUT --data "$1" "$H/status" >/dev/null 2>&1; }
|
||||
fail() { finish "failed: $*"; exit 1; }
|
||||
|
||||
echo "== Steamify test VM: unattended install ($(date))"
|
||||
curl -fsS "$H/vminstall.env" -o /tmp/vminstall.env || fail "no vminstall.env from the host"
|
||||
# shellcheck disable=SC1091
|
||||
. /tmp/vminstall.env
|
||||
curl -fsS "$H/settings.json" -o /tmp/settings.json || fail "no settings.json from the host"
|
||||
curl -fsS "$H/vminstall-post.sh" -o /tmp/vminstall-post.sh || fail "no vminstall-post.sh from the host"
|
||||
|
||||
# Let whoever watches the VM's window follow along: a Konsole on the live
|
||||
# desktop that shows this log.
|
||||
(
|
||||
for _ in $(seq 100); do pgrep -u liveuser -x plasmashell >/dev/null && break; sleep 3; done
|
||||
sleep 5
|
||||
runuser -u liveuser -- env XDG_RUNTIME_DIR=/run/user/1000 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus \
|
||||
systemd-run --user -q konsole --hold -e tail -n +1 -f "$LOG"
|
||||
) &
|
||||
while sleep 20; do up; done &
|
||||
|
||||
systemctl is-system-running --wait >/dev/null 2>&1
|
||||
nm-online -t 180 >/dev/null || fail "no network"
|
||||
# The live ISO's mirror list and keys can be old; the installer's pacstrap needs current ones.
|
||||
pacman -Sy --noconfirm archlinux-keyring cachyos-keyring || echo "(keyring update failed, going on)"
|
||||
|
||||
echo "== cachyos-installer"
|
||||
cachyos-installer --config /tmp/settings.json || fail "cachyos-installer exited with $?"
|
||||
|
||||
# The installer leaves the new system mounted on /mnt, or not: mount it.
|
||||
if ! mountpoint -q /mnt; then
|
||||
mount -o subvol=@ "${DEVICE}2" /mnt || fail "can't mount the new system"
|
||||
mount -o subvol=@home "${DEVICE}2" /mnt/home 2>/dev/null
|
||||
mount "${DEVICE}1" /mnt/boot 2>/dev/null
|
||||
fi
|
||||
[[ -d "/mnt/home/$VM_USER" ]] || fail "the installer created no /home/$VM_USER"
|
||||
|
||||
echo "== test VM setup"
|
||||
cp /tmp/vminstall-post.sh /tmp/vminstall.env /mnt/root/
|
||||
arch-chroot /mnt bash /root/vminstall-post.sh || fail "test VM setup exited with $?"
|
||||
rm -f /mnt/root/vminstall-post.sh /mnt/root/vminstall.env
|
||||
cp "$LOG" /mnt/var/log/vminstall.log
|
||||
sync
|
||||
finish ok
|
||||
sleep 2
|
||||
systemctl poweroff
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
# Runs inside the freshly installed system (arch-chroot, from
|
||||
# vminstall-live.sh): what guest-ssh-setup.sh and the old manual steps did,
|
||||
# so the VM is ssh-ready without touching it: sshd with the host's key,
|
||||
# passwordless sudo, the test autologin into Plasma, tmux and shellcheck.
|
||||
set -euo pipefail
|
||||
# shellcheck disable=SC1091
|
||||
. /root/vminstall.env
|
||||
|
||||
echo "$VM_HOSTNAME" > /etc/hostname
|
||||
pacman -S --needed --noconfirm openssh tmux shellcheck
|
||||
systemctl enable sshd
|
||||
|
||||
home="/home/$VM_USER"
|
||||
install -d -m 700 -o "$VM_USER" -g "$VM_USER" "$home/.ssh"
|
||||
printf '%s\n' "$VM_PUBKEY" > "$home/.ssh/authorized_keys"
|
||||
chown "$VM_USER:$VM_USER" "$home/.ssh/authorized_keys"
|
||||
chmod 600 "$home/.ssh/authorized_keys"
|
||||
|
||||
# Test VM only: the host drives it without a password.
|
||||
echo "$VM_USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/99-test-vm
|
||||
chmod 440 /etc/sudoers.d/99-test-vm
|
||||
|
||||
# Log straight into Plasma (gamescope doesn't render in the VM). The
|
||||
# scripts expect plasma-login-manager, like a CachyOS install from Calamares.
|
||||
pacman -Q plasma-login-manager >/dev/null 2>&1 || pacman -S --needed --noconfirm plasma-login-manager
|
||||
systemctl disable sddm.service 2>/dev/null || true
|
||||
systemctl enable plasmalogin.service
|
||||
mkdir -p /etc/plasmalogin.conf.d
|
||||
printf '[Autologin]\nUser=%s\nSession=plasma.desktop\n' "$VM_USER" > /etc/plasmalogin.conf.d/00-test-autologin.conf
|
||||
|
||||
# cachyos-installer's limine.conf has no default_entry: entry 1 is the
|
||||
# "CachyOS" folder, so the first boot waits in the menu. 2 is its first
|
||||
# kernel (linux-cachyos); limine-update keeps the line.
|
||||
if [[ -f /boot/limine.conf ]] && ! grep -q '^default_entry:' /boot/limine.conf; then
|
||||
sed -i 's/^timeout: .*/&\ndefault_entry: 2/' /boot/limine.conf
|
||||
fi
|
||||
|
||||
# English everywhere, whatever the live ISO picked.
|
||||
echo 'LANG=en_US.UTF-8' > /etc/locale.conf
|
||||
|
||||
# mirror5.krfoss.org served broken signatures; skip it (vmreset.sh does too).
|
||||
for f in /etc/pacman.d/*mirrorlist*; do sed -i '/krfoss/s/^Server/#Server/' "$f"; done
|
||||
echo "Test VM setup done: $VM_USER@$VM_HOSTNAME"
|
||||
Reference in new issue
Block a user