Skip to content

Commit

Permalink
fix(dracut.sh): handle /etc/machine-id empty or uninitialized
Browse files Browse the repository at this point in the history
Handle the case where the user tries to generate the initrd after explicitly
resetting the /etc/machine-id file.

Fixes issue #2267
  • Loading branch information
aafeijoo-suse authored and johannbg committed Apr 26, 2023
1 parent 48c2cb4 commit 97fe097
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dracut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1087,8 +1087,9 @@ if ! [[ $outfile ]]; then
|| [[ -d "$dracutsysrootdir"/boot/Default ]] \
|| [[ -d "$dracutsysrootdir"/boot/efi/Default ]]; then
MACHINE_ID="Default"
elif [[ -f "$dracutsysrootdir"/etc/machine-id ]]; then
elif [[ -s "$dracutsysrootdir"/etc/machine-id ]]; then
read -r MACHINE_ID < "$dracutsysrootdir"/etc/machine-id
[[ $MACHINE_ID == "uninitialized" ]] && MACHINE_ID="Default"
else
MACHINE_ID="Default"
fi
Expand Down

0 comments on commit 97fe097

Please sign in to comment.