diff --git a/Containerfile b/Containerfile index c135417..f02910e 100644 --- a/Containerfile +++ b/Containerfile @@ -63,6 +63,7 @@ RUN if grep -q "silverblue" <<< "${BASE_IMAGE_NAME}"; then \ # Setup things which are the same for every image RUN /tmp/surface-install.sh && \ + systemctl enable surface-hardware-setup && \ systemctl enable tlp && \ systemctl enable fprintd && \ rm -rf /tmp/* /var/* && \ diff --git a/system_files/shared/usr/bin/surface-hardware-setup b/system_files/shared/usr/bin/surface-hardware-setup new file mode 100755 index 0000000..84372eb --- /dev/null +++ b/system_files/shared/usr/bin/surface-hardware-setup @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +INITRAMFS=$(rpm-ostree initramfs-etc) +SURFACE_INITRAMFS=("/etc/crypttab") +APPLY_INITRAMFS=false + +echo "Current initramfs: $INITRAMFS" + +SURFACE_INITRAMFS+=("/etc/modprobe.d/ublue-surface.conf") + +# Verify initramfs options are applied +for ARG in ${SURFACE_INITRAMFS[@]}; do + if [[ ! $INITRAMFS =~ "$ARG" ]]; then + APPLY_INITRAMFS=true + fi +done + +# Update initramfs +if $APPLY_INITRAMFS; then + echo "Found needed initramfs changes, applying the following: ${SURFACE_INITRAMFS[*]}" + plymouth display-message --text="Updating initramfs - System will reboot" || true + rpm-ostree initramfs-etc "${SURFACE_INITRAMFS[@]/#/--track=}" --reboot +else + echo "No initramfs changes needed" +fi diff --git a/system_files/shared/usr/lib/systemd/system/surface-hardware-setup.service b/system_files/shared/usr/lib/systemd/system/surface-hardware-setup.service new file mode 100644 index 0000000..ad4d7dd --- /dev/null +++ b/system_files/shared/usr/lib/systemd/system/surface-hardware-setup.service @@ -0,0 +1,12 @@ +[Unit] +Description=Configure Surface hardware +After=rpm-ostreed.service +Before=systemd-user-sessions.service + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/surface-hardware-setup + +[Install] +WantedBy=multi-user.target