builder/adapters/container-runner-finalize.sh
2026-11-17 09:58:13 +00:00

49 lines
3.2 KiB
Bash

# Container Runner installed-system defaults. No graphical target or desktop stack.
systemctl --root=/job/core disable systemd-networkd archipelago-firstboot@tty1 archipelago-firstboot@ttyS0 serial-getty@ttyS0
# The server console is the plain kernel console (Terminus via vconsole.conf) with
# getty on tty1; the packaged getty@tty1 drop-in runs onboarding. kmscon needs
# mesa, which this image does not carry, so it is not enabled here.
systemctl --root=/job/core enable NetworkManager cockpit.socket getty@tty1
# Cockpit Machines runs guests through libvirt-dbus -> libvirtd. The Purpose
# preset records the same intent; enabling here also covers images composed from
# an older Core without a preset run.
systemctl --root=/job/core enable libvirtd.service
test -x /job/core/usr/bin/qemu-system-x86_64
test -f /job/core/usr/lib/systemd/system/libvirtd.service
test -f /job/core/usr/share/cockpit/machines/manifest.json
# Start libvirt's stock NAT network on boot. The package ships the definition but
# no autostart link, so a fresh host would otherwise reject a networked guest.
test -f /job/core/etc/libvirt/qemu/networks/default.xml
mkdir -p /job/core/etc/libvirt/qemu/networks/autostart
ln -sfn ../default.xml /job/core/etc/libvirt/qemu/networks/autostart/default.xml
systemctl --root=/job/core set-default multi-user.target
mkdir -p /job/core/etc/cockpit /job/core/etc/NetworkManager/conf.d /job/core/etc/sudoers.d
# Cockpit's stock self-signed certificate; never allow plaintext or unauthenticated use.
printf '[WebService]\nAllowUnencrypted = false\n' > /job/core/etc/cockpit/cockpit.conf
printf '[main]\ndns=systemd-resolved\n' > /job/core/etc/NetworkManager/conf.d/20-archipelago.conf
# Machine-level profile: existing Core images may predate the container ref,
# and /etc takes precedence over the Core-owned /usr/lib/archipelago/update.json.
mkdir -p /job/core/etc/archipelago
cat > /job/core/etc/archipelago/update.json <<'JSON'
{
"version": 1,
"url": "https://mirror.nw-sys.ru/archipelago/ostree/images",
"refs": {"container": "stable/container"},
"public_key_file": "/usr/share/archipelago/keys/ostree.asc"
}
JSON
printf '%%wheel ALL=(ALL:ALL) ALL\n' > /job/core/etc/sudoers.d/10-archipelago-wheel
chmod 0440 /job/core/etc/sudoers.d/10-archipelago-wheel
arch-chroot /job/core visudo -c
# binfmt registrations are applied by the statically enabled systemd-binfmt.service.
compgen -G '/job/core/usr/lib/binfmt.d/qemu-*.conf' >/dev/null
# Tailscale and firewalld are installed but deliberately not enabled; no keys,
# accounts or firewall rules are baked into the image.
test "$(systemctl --root=/job/core is-enabled tailscaled.service 2>/dev/null || true)" != enabled
test "$(systemctl --root=/job/core is-enabled firewalld.service 2>/dev/null || true)" != enabled
arch-chroot /job/core pacman --config /dev/null --dbpath /usr/lib/archipelago/package-db -Qq > /job/evidence/container-runner-package-names.txt
if grep -Ei '^(packagekit($|-)|libpackagekit)' /job/evidence/container-runner-package-names.txt; then
echo 'D-095: PackageKit is excluded from Container Runner' >&2
exit 1
fi
printf 'Container Runner: Cockpit enabled; Tailscale and firewall are operator actions\n' > /job/core/usr/lib/archipelago/container-runner-status