diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-02-21 15:09:38 +0100 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-02-21 15:20:18 +0100 |
commit | 01a0756427c847b26402ceffe508d726ffb42882 (patch) | |
tree | e40e866aed5141cb7c99cc448fa5d805477d8a57 /mkosi.extra | |
parent | mkosi: Remove preset workaround (diff) | |
download | systemd-01a0756427c847b26402ceffe508d726ffb42882.tar.xz systemd-01a0756427c847b26402ceffe508d726ffb42882.zip |
mkosi: Move more logic to the postinst script
Let's move stuff that only applies to the final image to the
postinst script. Let's also move out some of the static files to
mkosi.extra/ instead of hardcoding them in scripts.
Diffstat (limited to 'mkosi.extra')
-rw-r--r-- | mkosi.extra/etc/issue | 2 | ||||
-rw-r--r-- | mkosi.extra/etc/systemd/system/mkosi-check-and-shutdown.service | 14 | ||||
-rwxr-xr-x | mkosi.extra/etc/systemd/system/mkosi-check-and-shutdown.sh | 15 | ||||
-rw-r--r-- | mkosi.extra/root/.gdbinit | 2 |
4 files changed, 33 insertions, 0 deletions
diff --git a/mkosi.extra/etc/issue b/mkosi.extra/etc/issue new file mode 100644 index 0000000000..6aa6fc0ec0 --- /dev/null +++ b/mkosi.extra/etc/issue @@ -0,0 +1,2 @@ +\S (built from systemd tree) +Kernel \r on an \m (\l) diff --git a/mkosi.extra/etc/systemd/system/mkosi-check-and-shutdown.service b/mkosi.extra/etc/systemd/system/mkosi-check-and-shutdown.service new file mode 100644 index 0000000000..6539325108 --- /dev/null +++ b/mkosi.extra/etc/systemd/system/mkosi-check-and-shutdown.service @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Unit] +Description=Check if any service failed and then shutdown the machine +After=multi-user.target network-online.target +Requires=multi-user.target +Wants=systemd-resolved.service systemd-networkd.service network-online.target +OnFailure=poweroff.target +OnFailureJobMode=replace-irreversibly + +[Service] +Type=oneshot +ExecStartPre=-rm -f /failed-services +ExecStart=/usr/lib/systemd/mkosi-check-and-shutdown.sh +ExecStartPost=systemctl poweroff --no-block diff --git a/mkosi.extra/etc/systemd/system/mkosi-check-and-shutdown.sh b/mkosi.extra/etc/systemd/system/mkosi-check-and-shutdown.sh new file mode 100755 index 0000000000..b86d2d3e69 --- /dev/null +++ b/mkosi.extra/etc/systemd/system/mkosi-check-and-shutdown.sh @@ -0,0 +1,15 @@ +#!/bin/bash -eux +# SPDX-License-Identifier: LGPL-2.1-or-later + +systemctl --failed --no-legend | tee /failed-services + +# Check that secure boot keys were properly enrolled. +if [[ -d /sys/firmware/efi/efivars/ ]]; then + cmp /sys/firmware/efi/efivars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c <(printf '\6\0\0\0\1') + cmp /sys/firmware/efi/efivars/SetupMode-8be4df61-93ca-11d2-aa0d-00e098032b8c <(printf '\6\0\0\0\0') +fi + +# Exit with non-zero EC if the /failed-services file is not empty (we have -e set) +[[ ! -s /failed-services ]] + +: >/testok diff --git a/mkosi.extra/root/.gdbinit b/mkosi.extra/root/.gdbinit new file mode 100644 index 0000000000..522e1fecb6 --- /dev/null +++ b/mkosi.extra/root/.gdbinit @@ -0,0 +1,2 @@ +set debuginfod enabled off +set build-id-verbose 0 |