]> git.proxmox.com Git - pve-kernel-meta.git/blame_incremental - 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
1#! /bin/sh
2
3set -e
4
5. /usr/share/pve-kernel-helper/scripts/functions
6
7init_boot_disks() {
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
12
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"
19}
20
21if proxmox-boot-tool status --quiet; then
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
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
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
35 echo "Proxmox's boot-tool marker file found, ignoring grub install call."
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
41else
42 grub-install.real "$@"
43fi