From 03ebc01f8c291efc5f9eb9b3c7e46d90788ebbda Mon Sep 17 00:00:00 2001 From: Joe Ipson Date: Fri, 19 Jan 2024 23:33:14 -0700 Subject: [PATCH] More files --- modules/initramfs-setup/README.md | 57 +++++++++++++++++ modules/initramfs-setup/initramfs-setup.sh | 73 ++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 modules/initramfs-setup/README.md create mode 100644 modules/initramfs-setup/initramfs-setup.sh diff --git a/modules/initramfs-setup/README.md b/modules/initramfs-setup/README.md new file mode 100644 index 0000000..a203c6a --- /dev/null +++ b/modules/initramfs-setup/README.md @@ -0,0 +1,57 @@ +# `initramfs-setup` module for startingpoint + +This `initramfs-setup` module is intended for including files into initramfs, including dracut ones, which are useful for modifying hardware behavior. +It is similar to `rpm-ostree kargs` for this purpose, but `initramfs-setup` can load some modifications which are not possible to load with `rpm-ostree kargs`. + +Currently, it supports including file locations from `/etc` directory only by internally using `rpm-ostree initramfs-etc` component. + +Script which is responsible for this is located here: + +- `/usr/bin/initramfs-setup` + +It is run on every boot by this service: + +- `/usr/lib/systemd/system/initramfs-setup.service` + +Your modifications to initramfs are written to this file here: + +- `/etc/ublue-os/initramfs/tracked` + +Your modifications to dracut are written to this file here: + +- `/etc/ublue-os/initramfs/dracut-tracked` + +`tracked` & `dracut-tracked` files won't get written if you did not include modifications for those. This makes separation between OS & live-user modifications clearer. + +`initramfs-setup` detects your modifications & redundant file arguments, so your modification output is exactly matched to `rpm-ostree initramfs-etc` output. It also checks dracut configs the same way to trigger rebuild automatically only when necessary. When initramfs/dracut change is happening, you will see boot screen message which will say `Updating initramfs - System will reboot` or `Updating initramfs with dracut changes - System will reboot`, depending if `initramfs-setup` updates your initramfs or dracut modifications (or if it updates them both). + +To include your initramfs modifications, copy the modification files if you have those, than edit the "Example configuration" accordingly in `include`. +Do the otherwise for deleting. + +To include `dracut` files, just copy those files to `/etc/dracut.conf.d/` directory. Than put them in `dracut_include`. Do the otherwise for deleting. + +## Example configuration + +```yaml +type: initramfs-setup +include: + - /etc/crypttab + - /etc/vconsole.conf + - /etc/modprobe.d/my_config.conf +dracut_include: + - mydracut1.conf + - mydracut2.conf + - mydracut3.conf +``` + +Live-user modification is available too. + +If live-user is not satisfied with initramfs modifications done by the OS, he can add them into this file here: + +`/etc/ublue-os/initramfs/tracked-custom` + +Files contain explanations on what those do & how those should be used. + +If live-user wants to include dracut files too, he can do that by copying files to `/etc/dracut.conf.d/` & editing: + +`/etc/ublue-os/initramfs/dracut-tracked-custom` diff --git a/modules/initramfs-setup/initramfs-setup.sh b/modules/initramfs-setup/initramfs-setup.sh new file mode 100644 index 0000000..804f064 --- /dev/null +++ b/modules/initramfs-setup/initramfs-setup.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +# Tell build process to exit if there are any errors. +set -euo pipefail + +# Uncomment this when it's ready for startingpoint/bling +#BLING_DIRECTORY="${BLING_DIRECTORY:-"/tmp/bling"}" +# +#cp -r "$BLING_DIRECTORY"/files/usr/bin/initramfs-setup /usr/bin/initramfs-setup +#cp -r "$BLING_DIRECTORY"/files/usr/lib/systemd/system/initramfs-setup.service /usr/lib/systemd/system/initramfs-setup.service + +get_yaml_array INCLUDE '.include[]' "$1" +get_yaml_array DRACUT_INCLUDE '.dracut_include[]' "$1" + +echo "Installing initramfs-setup" + +if [[ ${#INCLUDE[@]} -gt 0 ]]; then + + printf "Configuring following initramfs files:\n" + for file in "${INCLUDE[@]}"; do + printf "%s\n" "$file" + done + + mkdir -p /usr/etc/ublue-os/initramfs + + echo "Writing 'tracked' file to initramfs directory with modifications" + + echo -e "# This file should not be modified by the user, as it's used by the OS directly.\n" > /usr/etc/ublue-os/initramfs/tracked + printf "%s" "${INCLUDE[@]}" >> /usr/etc/ublue-os/initramfs/tracked +fi + +if [[ ${#DRACUT_INCLUDE[@]} -gt 0 ]]; then + + printf "Configuring following dracut files:\n" + for file in "${DRACUT_INCLUDE[@]}"; do + printf "%s\n" "$file" + done + + mkdir -p /usr/etc/ublue-os/initramfs + + echo "Writing 'dracut_tracked' file to initramfs directory with modifications" + + echo -e "# This file should not be modified by the user, as it's used by the OS directly.\n" > /usr/etc/ublue-os/initramfs/dracut-tracked + printf "%s" "${DRACUT_INCLUDE[@]}" >> /usr/etc/ublue-os/initramfs/dracut-tracked +fi + +mkdir -p /usr/etc/ublue-os/initramfs + +echo "Writing 'tracked-custom' file to initramfs directory for live-user modifications" +echo "# This file can be modified by live-users if they want to have custom file location arguments in initramfs. +# Be sure to check if the arguments you want already exist in initramfs by issuing \`rpm-ostree initramfs-etc\` command before modifying this file. +# Also don't forget to copy your initramfs modification files if you have those. +# Here's an example on how to edit this file (ignore # symbol): +# +# /etc/vconsole.conf +# /etc/crypttab +# /etc/modprobe.d/my-modprobe.conf" > /usr/etc/ublue-os/initramfs/tracked-custom + +echo "Writing 'dracut-tracked-custom' file to initramfs directory for live-user modifications" +echo "# This file can be modified by live-users if they want to have custom dracut configs. +# Be sure that you copied your dracut configs to \`/etc/dracut.conf.d\` location before editing this file. +# When you edit this file & reboot, you will notice boot screen message which says: \"Updating initramfs with dracut changes - System will reboot\" +# Here's an example on how to edit this file (ignore # symbol): +# +# mydracut1.conf +# mydracut2.conf +# mydracut3.conf" > /usr/etc/ublue-os/initramfs/dracut-tracked-custom + +# Uncomment this when it's ready for startingpoint/bling +#echo "Enabling initramfs-setup service" +#mkdir -p /usr/etc/flatpak/{system,user} +#systemctl enable -f initramfs-setup.service +echo "Initramfs-setup is successfully installed & configured"