From 95c28bfa7830ba8b99e204c1610e07c48931b672 Mon Sep 17 00:00:00 2001 From: Stoiko Ivanov Date: Fri, 11 Feb 2022 16:15:44 +0100 Subject: [PATCH] proxmox-boot: add pin/unpin functionality for non-p-b-t systems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --next-boot ; p-b-t kernel pin Signed-off-by: Stoiko Ivanov Reviewed-by: Fabian Grünbichler Tested-by: Fabian Grünbichler Signed-off-by: Thomas Lamprecht --- bin/proxmox-boot-tool | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/bin/proxmox-boot-tool b/bin/proxmox-boot-tool index 90c4f5d..178b6fb 100755 --- a/bin/proxmox-boot-tool +++ b/bin/proxmox-boot-tool @@ -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 }