proxmox-boot: add get_first_line_from_file helper and use it

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
This commit is contained in:
Stoiko Ivanov 2022-01-31 18:59:15 +01:00 committed by Thomas Lamprecht
parent 605438b0ac
commit 8de0567d10
2 changed files with 9 additions and 3 deletions

View File

@ -101,3 +101,11 @@ loop_esp_list() {
"$@"
done
}
get_first_line() {
file="$1"
while IFS= read -r line || [ -n "$line" ]; do
break
done < "${file}"
echo "$line"
}

View File

@ -46,9 +46,7 @@ update_esps() {
fi
if [ -f /etc/kernel/cmdline ]; then
# we can have cmdline files with multiple or no new line at all, handle both!
while IFS= read -r CMDLINE || [ -n "$CMDLINE" ]; do
break
done < /etc/kernel/cmdline
CMDLINE=$(get_first_line /etc/kernel/cmdline)
echo ${CMDLINE} | grep -q 'root=' || \
{ warn "No root= parameter in /etc/kernel/cmdline found!"; exit 1; }
else