From b71d162a7ad55263d7bc9ba55065e17f87cf1e84 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 2 Jun 2017 18:07:25 +0900 Subject: [PATCH] kernel-install: Skip to create initrd if /etc/machine-id is missing or empty From systemd-234, kernel-install plugins are called even if /etc/machine-id is missing or empty, and in that case BOOT_DIR_ABS is a fake directory. So, let's skip to create initrd in that case. --- 50-dracut.install | 6 ++++++ 51-dracut-rescue.install | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/50-dracut.install b/50-dracut.install index 54c71d4ec..f1314d022 100755 --- a/50-dracut.install +++ b/50-dracut.install @@ -5,6 +5,12 @@ KERNEL_VERSION="$2" BOOT_DIR_ABS="$3" KERNEL_IMAGE="$4" +# If KERNEL_INSTALL_MACHINE_ID is defined but empty, BOOT_DIR_ABS is a fake directory. +# So, let's skip to create initrd. +if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then + exit 0 +fi + ret=0 case "$COMMAND" in add) diff --git a/51-dracut-rescue.install b/51-dracut-rescue.install index 0a5f14be4..7fbeac1d4 100755 --- a/51-dracut-rescue.install +++ b/51-dracut-rescue.install @@ -33,11 +33,15 @@ dropindirs_sort() [[ -f /etc/os-release ]] && . /etc/os-release -if [[ ! -f /etc/machine-id ]] || [[ ! -s /etc/machine-id ]]; then - systemd-machine-id-setup +if [[ ${KERNEL_INSTALL_MACHINE_ID+x} ]]; then + MACHINE_ID=$KERNEL_INSTALL_MACHINE_ID +elif [[ -f /etc/machine-id ]] ; then + read MACHINE_ID < /etc/machine-id fi -[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id +if ! [[ $MACHINE_ID ]]; then + exit 0 +fi if [[ -f /etc/kernel/cmdline ]]; then read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline -- 2.47.2