Skip to content

Commit cc51c9e

Browse files
committed
template: add precondition checks during installation into initrd
Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com>
1 parent c3ffe04 commit cc51c9e

4 files changed

Lines changed: 22 additions & 8 deletions

File tree

src/pins/file/dracut.module-setup.sh.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
#
1919

20+
check() {
21+
require_binaries clevis-decrypt-file || return 1
22+
}
23+
2024
depends() {
2125
echo clevis
2226
return 0

src/pins/file/initramfs.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ die() {
3232
exit "$code"
3333
}
3434

35-
copy_exec @bindir@/clevis-decrypt-file || die 1 "@bindir@/clevis-decrypt-file not found"
35+
if [ -x @bindir@/clevis-decrypt-file ]; then
36+
copy_exec @bindir@/clevis-decrypt-file || die 1 "Unable to copy @bindir@/clevis-decrypt-file to initrd image"
37+
fi

src/pins/template/dracut.module-setup.sh.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
#
1919

20+
check() {
21+
require_binaries clevis-decrypt-@pin@ || return 1
22+
}
23+
2024
depends() {
2125
echo clevis
2226
return 0

src/pins/template/initramfs.in

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,20 @@ die() {
3232
exit $1
3333
}
3434

35-
copy_exec @bindir@/clevis-decrypt-@pin@ || die 1 "@bindir@/clevis-decrypt-@pin@ not found"
36-
37-
#%# Possibly you to need to install additional binaries:
35+
#%# Possibly you need to find additional binaries...
3836
#%#
3937
#%# find_binary() {
4038
#%# bin_name="$1"
41-
#%# resolved=$(which ${bin_name})
39+
#%# resolved=$(command -v ${bin_name})
4240
#%# [ -z "$resolved" ] && die 1 "Unable to find ${bin_name}"
4341
#%# echo "$resolved"
4442
#%# }
45-
#%#
46-
#%# curl_bin=$(find_binary "curl")
47-
#%# copy_exec "${curl_bin}" || die 2 "Unable to copy ${curl_bin} to initrd image"
43+
44+
if [ -x @bindir@/clevis-decrypt-@pin@ ]; then
45+
copy_exec @bindir@/clevis-decrypt-@pin@ || die 1 "Unable to copy @bindir@/clevis-decrypt-@pin@ to initrd image"
46+
47+
#%# ...and install them
48+
#%#
49+
#%# curl_bin=$(find_binary "curl")
50+
#%# copy_exec "${curl_bin}" || die 2 "Unable to copy ${curl_bin} to initrd image"
51+
fi

0 commit comments

Comments
 (0)