]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
kernel-install: Skip to create initrd if /etc/machine-id is missing or empty 233/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 2 Jun 2017 09:07:25 +0000 (18:07 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 2 Jun 2017 09:07:25 +0000 (18:07 +0900)
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
51-dracut-rescue.install

index 54c71d4ec5bd59a0b8b6741afbbc81e9f558d3c8..f1314d0222c88019e18e4b6fdeb53264d1999f1b 100755 (executable)
@@ -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)
index 0a5f14be4e96a2cb7e7fa494eeea28728752fb7f..7fbeac1d4ce655d847dd77b2f0426a96792ad780 100755 (executable)
@@ -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