]> git.proxmox.com Git - pve-kernel-meta.git/commitdiff
proxmox-boot: add get_first_line_from_file helper and use it
authorStoiko Ivanov <s.ivanov@proxmox.com>
Mon, 31 Jan 2022 17:59:15 +0000 (18:59 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 4 Feb 2022 16:46:07 +0000 (17:46 +0100)
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
proxmox-boot/functions
proxmox-boot/zz-proxmox-boot

index 6e19c2016ddf896ba210ac8a8d7d0352b6308ac1..4515a2d9139cf53e5e947678e06de655e85b3cda 100755 (executable)
@@ -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"
+}
index 90d4aa94730b8ea9eb2bf1f9072a2ac2215e07c0..db73166190b0ed8b662505d96a9a2a4e91249952 100755 (executable)
@@ -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