#!/bin/bash # # Purpose : Turn Arch's cloud image into the machine CoreDesktop's README starts # from: Arch with archinstall's desktop profile and GNOME. Run as root # in the VM while building the smoketest's base image. # # Differences from a real archinstall machine, on purpose: the user (tester) # logs in to GNOME automatically and has passwordless sudo, so the smoketest # runs without anyone at the keyboard. set -euo pipefail USER_NAME=tester echo "== Growing / to fill the disk" btrfs filesystem resize max / || echo "Couldn't grow /; continuing." df -h / echo "== Sharing the host's package cache" if ! grep -q '^pkgcache ' /etc/fstab; then echo 'pkgcache /var/cache/pacman/pkg 9p trans=virtio,version=9p2000.L,msize=524288,nofail 0 0' >> /etc/fstab fi systemctl daemon-reload mountpoint -q /var/cache/pacman/pkg || mount /var/cache/pacman/pkg \ || echo "No shared package cache; packages download into the VM." echo "== Installing GNOME" pacman -Sy --needed --noconfirm archlinux-keyring # archinstall's desktop profile with GNOME, NetworkManager and PipeWire pacman -Su --needed --noconfirm \ gnome gnome-tweaks gdm \ networkmanager \ pipewire pipewire-alsa pipewire-pulse pipewire-jack wireplumber \ base-devel git sudo openssh nano vim htop wget smartmontools xdg-utils echo "== Locale" sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen locale-gen echo LANG=en_US.UTF-8 > /etc/locale.conf echo "== NetworkManager instead of systemd-networkd" systemctl disable systemd-networkd.service systemd-networkd.socket systemd-resolved.service || true # NetworkManager writes its own resolv.conf; the cloud image's points at # systemd-resolved rm -f /etc/resolv.conf systemctl enable NetworkManager.service gdm.service sshd.service echo "== Automatic login to GNOME as $USER_NAME" cat > /etc/gdm/custom.conf << EOF [daemon] AutomaticLoginEnable=True AutomaticLogin=$USER_NAME EOF echo "== Smoketest folder" install -d -o "$USER_NAME" -g "$USER_NAME" /srv/smoketest # cloud-init has done its job (the user, their SSH key and sudo rights) touch /etc/cloud/cloud-init.disabled echo "== Done"