Skip to content

Instantly share code, notes, and snippets.

@achilleas-k
Created October 19, 2022 13:54
Show Gist options
  • Save achilleas-k/438f397f3d60b2dd7967cb6ac56d06b8 to your computer and use it in GitHub Desktop.
Save achilleas-k/438f397f3d60b2dd7967cb6ac56d06b8 to your computer and use it in GitHub Desktop.
## runtime-postinstall.tmpl
## post-install setup required to make the system work.
<%page args="root, basearch, libdir, configdir"/>
<%
configdir = configdir + "/common"
import os, time
SOURCE_DATE_EPOCH = os.environ.get('SOURCE_DATE_EPOCH', str(int(time.time())))
%>
## move_stubs()
## VAC: Change in Anaconda spec file
move usr/share/anaconda/list-harddrives-stub usr/bin/list-harddrives
## move_repos()
## VAC: Symlink in osbuild (stage)
move etc/yum.repos.d etc/anaconda.repos.d
## Setup mdadm config to turn off homehost [https://bugzilla.redhat.com/show_bug.cgi?id=1156614]
## VAC: Add mdadm.conf stage in osbuild
remove etc/mdadm.conf
append etc/mdadm.conf "HOMEHOST <ignore>\n"
## Configure systemd to start anaconda
## VAC: Anadonda spec: move to subpackage
remove etc/systemd/system/default.target
symlink /lib/systemd/system/anaconda.target etc/systemd/system/default.target
## Make sure tmpfs is enabled
## VAC: Not relevant (probably) [https://bugzilla.redhat.com/show_bug.cgi?id=908253]
mkdir etc/systemd/system/local-fs.target.wants/
symlink /lib/systemd/system/tmp.mount etc/systemd/system/local-fs.target.wants/tmp.mount
## Disable unwanted systemd services
## VAC: osbuild stage
systemctl disable systemd-readahead-collect.service \ # VAC: Does not exist ANCIENT
systemd-readahead-replay.service \ # VAC: Does not exist ANCIENT
lvm2-monitor.service \
dnf-makecache.timer
## These services can't be disabled normally (they're linked into place in
## /usr/lib/systemd rather than /etc/systemd), so we have to mask them.
## VAC: osbuild stage
systemctl mask fedora-configure.service fedora-loadmodules.service \
fedora-autorelabel.service fedora-autorelabel-mark.service \
fedora-wait-storage.service media.mount \
systemd-tmpfiles-clean.service systemd-tmpfiles-clean.timer \
ldconfig.service
remove usr/lib/systemd/system/rngd.service ## VAC: probably unnecessary (ask Brian)
## remove because it cannot be disabled
## VAC: add remove stage to osbuild (oh no) or make a stage that specifically removes this file
remove usr/lib/systemd/system-generators/lvm2-activation-generator
## Remove the more terrible parts of systemd-tmpfiles.
## etc.conf is written with the assumption that /etc/ is empty, which is
## ridiculous, and it also creates a broken /etc/resolv.conf, which breaks
## networking.
## VAC: probably unnecessary
remove usr/lib/tmpfiles.d/etc.conf
## Make logind activate anaconda-shell@.service on switch to empty VT
## VAC: do in osbuild. Add ReserveVT to the logind stage
symlink anaconda-shell@.service lib/systemd/system/autovt@.service
replace "#ReserveVT=6" "ReserveVT=2" etc/systemd/logind.conf
## Don't write the journal to the overlay, just keep it in RAM
## VAC: DO IT PROPERLY (org.osbuild.systemd-journald volatile)
remove var/log/journal
## install some basic configuration files
## VAC: Add osbuild stages for each of these
append etc/fstab ""
install ${configdir}/i18n etc/sysconfig ## VAC: easy
install ${configdir}/rsyslog.conf etc ## VAC: lots of shit in there
install ${configdir}/bash_history root/.bash_history ## VAC: unnecessary
install ${configdir}/profile root/.profile ## VAC: make profile stage (path and prompt: REMOVE SYSIMAGE PATHS FROM $PATH. THIS IS CRAZY)
install ${configdir}/libuser.conf etc ## VAC: configure in Anaconda or drop completely (Anaconda uses chroot to configure users)
install ${configdir}/sysctl.conf etc/sysctl.d/anaconda.conf ## VAC: Anaconda spec
install ${configdir}/spice-vdagentd etc/sysconfig ## VAC: Move the spice clarg to Anaconda call
mkdir etc/NetworkManager/conf.d
install ${configdir}/91-anaconda-autoconnect-slaves.conf etc/NetworkManager/conf.d ## VAC: Anaconda spec file
install ${configdir}/vconsole.conf etc ## VAC: osbuild stage already exists
install ${configdir}/92-anaconda-loglevel-debug.conf etc/NetworkManager/conf.d ## VAC: Anaconda spec file
## set up sshd
install ${configdir}/sshd_config.anaconda etc/ssh ## VAC: move to Anaconda
install ${configdir}/pam.sshd etc/pam.d/sshd ## VAC: do in osbuild
install ${configdir}/pam.sshd etc/pam.d/login ## VAC: do in osbuild
install ${configdir}/pam.sshd etc/pam.d/remote ## VAC: do in osbuild
## set up inst.rngd support
## VAC: Move to Anaconda
install ${configdir}/inst.rngd.service etc/systemd/system/inst.rngd.service
mkdir etc/systemd/system/basic.target.wants/
symlink /etc/systemd/system/inst.rngd.service etc/systemd/system/basic.target.wants/inst.rngd.service
## set up "install" user account
## VAC: osbuild useradd stage
append etc/passwd "install:x:0:0:root:/root:/usr/libexec/anaconda/run-anaconda"
append etc/shadow "install::14438:0:99999:7:::"
## remove root password
## VAC: Already done in osbuild
replace "root:\*:" "root::" etc/shadow
## gsettings settings
## VAC: Do in Anaconda
install ${configdir}/org.gtk.Settings.Debug.gschema.override usr/share/glib-2.0/schemas
runcmd chroot ${root} glib-compile-schemas /usr/share/glib-2.0/schemas
## for compatibility with Ancient Anaconda Traditions
## VAC: Check if it works without it and fix so they're not necessary
symlink lib/modules /modules
symlink lib/firmware /firmware
symlink ../run/install mnt/install
## create_depmod_conf()
## VAC: Move to Anaconda spec
append etc/depmod.d/dd.conf "search updates built-in"
## create multipath.conf so multipath gets auto-started
## VAC: osbuild multipath.conf stage
append etc/multipath.conf "defaults {\n\tfind_multipaths smart\n\tuser_friendly_names yes\n}\n"
append etc/multipath.conf "blacklist_exceptions {\n\tproperty \"(SCSI_IDENT_|ID_WWN)\"\n}\n"
## make lvm auto-activate
## VAC: removes are (probably) unnecessary
remove etc/lvm/archive/*
remove etc/lvm/archive
remove etc/lvm/backup/*
remove etc/lvm/backup
remove etc/lvm/cache/*
remove etc/lvm/cache
remove etc/lvm/lvm.conf
append etc/lvm/lvm.conf "global {\n\tuse_lvmetad = 1\n}\n" ## VAC: option removed; no longer necessary
## TODO: we could run prelink here if we wanted? (VAC: no)
## fix fonconfig cache containing timestamps
## VAC: clamp the timestamps in osbuild with a new stage
runcmd chroot ${root} /usr/bin/find /usr/share/fonts -newermt "@${SOURCE_DATE_EPOCH}" -exec \
touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" {} +
## VAC: osbuild stage
runcmd chroot ${root} /usr/bin/fc-cache -f
## VAC: DONE! 🎉
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment