builder/adapters/container-runner-finalize.sh

35 lines
2.3 KiB
Bash

# Container Runner installed-system defaults. No graphical target or desktop stack.
systemctl --root=/job/core disable systemd-networkd archipelago-firstboot@ttyS0 serial-getty@ttyS0
# Keep the console onboarding path; the installed system is a multi-user server.
systemctl --root=/job/core enable NetworkManager cockpit.socket getty@tty1 archipelago-firstboot@tty1
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