]> git.proxmox.com Git - pve-kernel-meta.git/commitdiff
proxmox-boot: add grub.cfg header snippet
authorStoiko Ivanov <s.ivanov@proxmox.com>
Fri, 23 Apr 2021 09:04:48 +0000 (11:04 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 23 Apr 2021 11:28:56 +0000 (13:28 +0200)
If the system seems to be booted using proxmox-boot, write a header at
the beginning of the grub.cfg generated when running `update-grub`

Additionally print a warning in case the script is run interactively.
This is determined by checking for DPKG_VERSION, which is set when
running as post-inst task (after a kernel install/removal)
and for PVE_EFIBOOT_UNSHARED, which is set by proxmox-boot-tool when
running `proxmox-boot-tool refresh.`

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
debian/pve-kernel-helper.install
proxmox-boot/000_proxmox_boot_header [new file with mode: 0755]
proxmox-boot/Makefile

index aae94944d9ac1b28f656a9c1ca4b4d042628ab2d..f03b05a6ddd64420f611e6d49970d3aa83267172 100644 (file)
@@ -1,3 +1,4 @@
+etc/grub.d/000_proxmox_boot_header
 etc/kernel/postinst.d/*
 etc/kernel/postrm.d/*
 etc/initramfs/post-update.d/proxmox-boot-sync
diff --git a/proxmox-boot/000_proxmox_boot_header b/proxmox-boot/000_proxmox_boot_header
new file mode 100755 (executable)
index 0000000..e230aef
--- /dev/null
@@ -0,0 +1,22 @@
+#! /bin/sh
+set -e
+
+. /usr/share/pve-kernel-helper/scripts/functions
+
+if proxmox-boot-tool status --quiet; then
+       cat <<- EOF
+       #
+       # This system is booted via proxmox-boot-tool! The grub-config used when
+       # booting from the disks configured with proxmox-boot-tool resides on the vfat
+       # partitions with UUIDs listed in ${ESP_LIST}.
+       # /boot/grub/grub.cfg is NOT read when booting from those disk!
+       EOF
+
+       if [ -z "$DPKG_RUNNING_VERSION" ] && [ -z "$PVE_EFIBOOT_UNSHARED" ]; then
+               warn "W: This system is booted via proxmox-boot-tool:"
+               warn "W: Running update-grub does not update the correct config!"
+               warn "W: Run 'proxmox-boot-tool refresh' instead."
+               warn ""
+       fi
+fi
+
index 3a36cb7d7681d29cc1a02676a564c5ad4ea998ee..effd7265b7a7b53d92491012846f2a2abee73b7b 100644 (file)
@@ -1,11 +1,13 @@
 KERNEL_HOOKSCRIPTS = proxmox-auto-removal zz-proxmox-boot
 INITRAMFS_HOOKSCRIPTS = proxmox-boot-sync
 SHARE_FILES = functions
+GRUB_CFG_SNIPPET = 000_proxmox_boot_header
 
 POSTINSTHOOKDIR = ${DESTDIR}/etc/kernel/postinst.d
 POSTRMHOOKDIR = ${DESTDIR}/etc/kernel/postrm.d
 POSTINITRAMFSHOOKDIR = ${DESTDIR}/etc/initramfs/post-update.d
 SHARE_SCRIPTDIR = ${DESTDIR}/usr/share/pve-kernel-helper/scripts
+GRUB_CFG_DIR = ${DESTDIR}/etc/grub.d
 
 .PHONY: all
 all:
@@ -19,6 +21,8 @@ install:
        install -m 0755 ${INITRAMFS_HOOKSCRIPTS} ${POSTINITRAMFSHOOKDIR}
        install -d ${SHARE_SCRIPTDIR}
        install -m 0755 ${SHARE_FILES} ${SHARE_SCRIPTDIR}
+       install -d ${GRUB_CFG_DIR}
+       install -m 0755 ${GRUB_CFG_SNIPPET} ${GRUB_CFG_DIR}
 
 .PHONY: clean distclean
 distclean: