Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions install.d/51-dracut-rescue.install
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ if ! [[ $MACHINE_ID ]]; then
exit 0
fi

ENTRY_TOKEN="${KERNEL_INSTALL_ENTRY_TOKEN:-${MACHINE_ID}}"

if [ -n "$KERNEL_INSTALL_CONF_ROOT" ]; then
if [ -f "$KERNEL_INSTALL_CONF_ROOT/cmdline" ]; then
read -r -d '' -a BOOT_OPTIONS < "$KERNEL_INSTALL_CONF_ROOT/cmdline"
Expand All @@ -85,15 +87,15 @@ else
fi

if [[ -d ${BOOT_DIR_ABS%/*} ]]; then
BOOT_DIR="/${MACHINE_ID}/0-rescue"
BOOT_DIR="/${ENTRY_TOKEN}/0-rescue"
BOOT_ROOT=${BOOT_DIR_ABS%"$BOOT_DIR"}
LOADER_ENTRY="$BOOT_ROOT/loader/entries/${MACHINE_ID}-0-rescue.conf"
LOADER_ENTRY="$BOOT_ROOT/loader/entries/${ENTRY_TOKEN}-0-rescue.conf"
KERNEL="linux"
INITRD="initrd"
else
BLS_DIR="/boot/loader/entries"
BOOT_DIR_ABS="/boot"
LOADER_ENTRY="$BLS_DIR/${MACHINE_ID}-0-rescue.conf"
LOADER_ENTRY="$BLS_DIR/${ENTRY_TOKEN}-0-rescue.conf"
KERNEL="vmlinuz-0-rescue-${MACHINE_ID}"
INITRD="initramfs-0-rescue-${MACHINE_ID}.img"
Comment on lines 99 to 100

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about KERNEL and INITRD?

fi
Expand Down Expand Up @@ -150,8 +152,8 @@ case "$COMMAND" in
echo "initrd $BOOT_DIR/initrd"
} > "$LOADER_ENTRY"
else
if [[ -e "${BLS_DIR}/${MACHINE_ID}-${KERNEL_VERSION}.conf" ]]; then
cp -aT "${BLS_DIR}/${MACHINE_ID}-${KERNEL_VERSION}.conf" "$LOADER_ENTRY"
if [[ -e "${BLS_DIR}/${ENTRY_TOKEN}-${KERNEL_VERSION}.conf" ]]; then
cp -aT "${BLS_DIR}/${ENTRY_TOKEN}-${KERNEL_VERSION}.conf" "$LOADER_ENTRY"
else
cp -aT "${KERNEL_IMAGE%/*}/bls.conf" "$LOADER_ENTRY"
fi
Expand Down
16 changes: 16 additions & 0 deletions test/TEST-43-KERNEL-INSTALL/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ test_run() {
-append "root=LABEL=dracut $TEST_KERNEL_CMDLINE" \
-initrd "$BOOT_ROOT/$TOKEN"/0-rescue/initrd
check_qemu_log

# rescue boot with custom entry token
"$testdir"/run-qemu \
"${disk_args[@]}" \
-append "root=LABEL=dracut $TEST_KERNEL_CMDLINE" \
-initrd "$BOOT_ROOT/custom-entry-token"/0-rescue/initrd
check_qemu_log
}

test_setup() {
Expand Down Expand Up @@ -62,6 +69,15 @@ test_setup() {
echo "Error: kernel-install failed to create $BOOT_ROOT/$TOKEN/$KVERSION/initrd" >&2
return 1
fi

# test with a custom entry token different from machine-id
CUSTOM_TOKEN="custom-entry-token"
mkdir -p "$BOOT_ROOT/$CUSTOM_TOKEN/$KVERSION" "$BOOT_ROOT/loader/entries" "$BOOT_ROOT/$CUSTOM_TOKEN/0-rescue"
kernel-install add --entry-token "literal:$CUSTOM_TOKEN" "$KVERSION" "$KIMAGE"
if [[ ! -e "$BOOT_ROOT/$CUSTOM_TOKEN/0-rescue/initrd" ]]; then
echo "Error: kernel-install failed to create rescue initrd with custom entry token at $BOOT_ROOT/$CUSTOM_TOKEN/0-rescue/initrd" >&2
return 1
fi
}

# shellcheck disable=SC1090
Expand Down
Loading