]> git.proxmox.com Git - pve-kernel-meta.git/blame - bin/grub-install-wrapper
grub wrapper: skip if using boot-tool but also booted via EFI
[pve-kernel-meta.git] / bin / grub-install-wrapper
CommitLineData
72905061 1#! /bin/sh
ea065c7e 2
72905061
SI
3set -e
4
5. /usr/share/pve-kernel-helper/scripts/functions
6
5c5008bc 7init_boot_disks() {
ea065c7e
TL
8 if ! (echo "${curr_uuid}" | grep -qE '[0-9a-fA-F]{4}-[0-9a-fA-F]{4}'); then
9 warn "WARN: ${curr_uuid} read from ${ESP_LIST} does not look like a VFAT-UUID - skipping"
10 return
11 fi
5c5008bc 12
ea065c7e
TL
13 path="/dev/disk/by-uuid/$curr_uuid"
14 if [ ! -e "${path}" ]; then
15 warn "WARN: ${path} does not exist - clean '${ESP_LIST}'! - skipping"
16 return
17 fi
18 proxmox-boot-tool init "$path"
5c5008bc
SI
19}
20
72905061 21if proxmox-boot-tool status --quiet; then
ea065c7e
TL
22 # detect when being called by dpkg (e.g. grub-pc.postinst
23 if [ -n "$DPKG_RUNNING_VERSION" ] && echo "$DPKG_MAINTSCRIPT_PACKAGE" | grep -sq "^grub-"; then
f5ef4a67
TL
24 if [ -d /sys/firmware/efi ]; then
25 echo "Promxox's boot-tool is used and booted via EFI, skipping re-sync of GRUB"
26 exit 0
27 fi
ea065c7e
TL
28 MARKER_FILE="/tmp/proxmox-boot-tool.dpkg.marker"
29 if [ ! -e "$MARKER_FILE" ]; then
30 warn "This system is booted via proxmox-boot-tool, running proxmox-boot-tool init for all configured bootdisks"
31 loop_esp_list init_boot_disks
32 touch "$MARKER_FILE"
33 exit 0
34 else
f5ef4a67 35 echo "Proxmox's boot-tool marker file found, ignoring grub install call."
ea065c7e
TL
36 exit 0
37 fi
38 fi
39 warn "grub-install is disabled because this system is booted via proxmox-boot-tool, if you really need to run it, run /usr/sbin/grub-install.real"
40 exit 1
72905061 41else
ea065c7e 42 grub-install.real "$@"
72905061 43fi