fix(lsinitrd.sh): handle /etc/machine-id empty or uninitialized

Handle the case where the user tries to query the initrd content after
explicitly resetting the /etc/machine-id file.
This commit is contained in:
Antonio Alvarez Feijoo 2023-03-20 14:09:43 +01:00 committed by Jóhann B. Guðmundsson
parent 97fe09769d
commit 971b302d70

View File

@ -111,8 +111,9 @@ if [[ $1 ]]; then
else
if [[ -d /efi/Default ]] || [[ -d /boot/Default ]] || [[ -d /boot/efi/Default ]]; then
MACHINE_ID="Default"
elif [[ -f /etc/machine-id ]]; then
elif [[ -s /etc/machine-id ]]; then
read -r MACHINE_ID < /etc/machine-id
[[ $MACHINE_ID == "uninitialized" ]] && MACHINE_ID="Default"
else
MACHINE_ID="Default"
fi