File tree 3 files changed +49
-0
lines changed
jenkins/image_building/initrd_sdk
3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -21,3 +21,20 @@ dracut and the script relies on only two external tools `blkid` and
21
21
` systemd-cryptsetup ` . If an image was built with ` dracut ` and the ` dracut `
22
22
module ` crypt ` is enabled then both ` blkid ` and ` systemd-cryptsetup ` should be
23
23
present in the initrd environment.
24
+
25
+ ## unseal-and-open-luks.service
26
+
27
+ This is the systemd service unit file that automatically starts the
28
+ ` unlock-mount-luks.sh ` . This service has to be enabled with ` systemctl enable `
29
+ during or after the initrd build process.
30
+
31
+ ## verify-realroot.sh
32
+
33
+ This script is used to provide a controlled wait loop in order to give time
34
+ to other systemd services to prepare the root file system. The intention is to
35
+ have a deterministic check/wait loop before the initrd root switching is
36
+ initiated in order to avoid potential race conditions.
37
+
38
+ This script has to be executed by the ` initrd-sitch-root.service ` as a
39
+ ` ExecStartPre ` option such as:
40
+ ` ExecStartPre=/bin/sh -c '/etc/verify-realroot.sh' `
Original file line number Diff line number Diff line change
1
+ [Unit]
2
+ Description =Unseal TPM key and open LUKS volume
3
+ DefaultDependencies =no
4
+ Before =initrd.target
5
+ Wants =initrd-fs.target
6
+
7
+ [Service]
8
+ Type =oneshot
9
+ ExecStart =/bin/sh -c '/etc/unlock-mount-luks.sh'
10
+ RemainAfterExit =yes
11
+
12
+ [Install]
13
+ WantedBy =initrd-switch-root.target
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ set -eu
4
+
5
+ # This script is used to prvide a controlled wait loop in order to give time
6
+ # to other systemd srvices to prepare the root file system.
7
+
8
+ while true ; do
9
+ if [[ -e " /realroot/bin" ]]; then
10
+ printf " INFO: Realroot mount point is present.\n"
11
+ break
12
+ else
13
+ printf " INFO: Waiting for realroot!\n"
14
+ # Introduce a 1-second delay using the read command
15
+ # sleep might not be available but this way we stress
16
+ # the CPU less
17
+ read -r -t 1 || true
18
+ fi
19
+ done
You can’t perform that action at this time.
0 commit comments