]> git.proxmox.com Git - proxmox-kernel-helper.git/commitdiff
proxmox-boot: add pin/unpin functionality for non-p-b-t systems
authorStoiko Ivanov <s.ivanov@proxmox.com>
Fri, 11 Feb 2022 15:15:44 +0000 (16:15 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 22 Feb 2022 12:31:31 +0000 (13:31 +0100)
While running `update-grub` directly in this case is a divergence from
the semantics of the command when p-b-t handles booting it makes the
cleanup in the `next-boot` case a bit tidier.

fetching the next-boot version explicitly again before setting the
provided version is to cover the sequence:
p-b-t kernel pin <ver1> --next-boot ; p-b-t kernel pin <ver2>

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
bin/proxmox-boot-tool

index 90c4f5d9879ff913a653f5a42e2a2bd949586f62..178b6fb33110c7d80af594f0938fdbd948d7ece6 100755 (executable)
@@ -437,15 +437,33 @@ pin_kernel() {
                exit 1
        fi
        echo "$ver" > "$pin_file"
-       echo "Set kernel '$ver' in $pin_file. Use the 'refresh' command to update the ESPs."
+
+       if [ -f "${ESP_LIST}" ]; then
+               echo "Set kernel '$ver' in $pin_file. Use the 'refresh' command to update the ESPs."
+       else
+               next_boot_ver=$(get_first_line "${NEXT_BOOT_PIN}")
+               pin_ver="${next_boot_ver:-$ver}"
+               echo "Setting '$pin_ver' as grub default entry and running update-grub."
+               set_grub_default "$pin_ver"
+               update-grub
+       fi
 }
 
 unpin_kernel() {
        rm -f "$NEXT_BOOT_PIN"
-       echo "Removed $NEXT_BOOT_PIN. Use the 'refresh' command to update the ESPs."
+       echo "Removed $NEXT_BOOT_PIN."
        if [ -z "$1" ]; then
                rm -f "$PINNED_KERNEL_CONF"
-               echo "Removed $PINNED_KERNEL_CONF. Use the 'refresh' command to update the ESPs."
+               echo "Removed $PINNED_KERNEL_CONF."
+       fi
+
+       if [ -f "${ESP_LIST}" ]; then
+               echo "Use the 'refresh' command to update the ESPs."
+       else
+               echo "Reset default grub entry and running update-grub."
+               pinned_kernel=$(get_first_line "${PINNED_KERNEL_CONF}")
+               set_grub_default "$pinned_kernel"
+               update-grub
        fi
 }