Signed-off-by: Stoiko Ivanov <s.iva...@proxmox.com>
---
new in v2 - should reduce code copying in the future

 bin/proxmox-boot-tool        |  4 ++--
 proxmox-boot/functions       | 16 ++++++++++++++++
 proxmox-boot/zz-proxmox-boot |  4 ++--
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/bin/proxmox-boot-tool b/bin/proxmox-boot-tool
index 5197f5b..a499154 100755
--- a/bin/proxmox-boot-tool
+++ b/bin/proxmox-boot-tool
@@ -395,14 +395,14 @@ _status_detail() {
                { warn "mount of ${path} failed - skipping"; return; }
 
        result=""
-       if [ -f "${mountpoint}/$PMX_LOADER_CONF" ]; then
+       if mountpoint_has_sd_boot "${mountpoint}"; then
                if [ ! -d "${mountpoint}/$PMX_ESP_DIR" ]; then
                        warn "${path}/$PMX_ESP_DIR does not exist"
                fi
                versions_uefi=$(ls -1 ${mountpoint}/$PMX_ESP_DIR | awk '{printf 
(NR>1?", ":"") $0}')
                result="uefi (versions: ${versions_uefi})"
        fi
-       if [ -d "${mountpoint}/grub" ]; then
+       if mountpoint_has_grub "${mountpoint}"; then
                versions_grub=$(ls -1 ${mountpoint}/vmlinuz-* | awk '{ 
gsub(/.*\/vmlinuz-/, ""); printf (NR>1?", ":"") $0 }')
                if [ -n "$result" ]; then
                    result="${result}, grub (versions: ${versions_grub})"
diff --git a/proxmox-boot/functions b/proxmox-boot/functions
index bdab987..3ec1cad 100755
--- a/proxmox-boot/functions
+++ b/proxmox-boot/functions
@@ -154,3 +154,19 @@ set_systemd_boot_default() {
                "${mountpoint}/$PMX_LOADER_CONF"
 
 }
+
+mountpoint_has_grub() {
+       mountpoint="$1"
+       if [ -d "${mountpoint}/grub" ]; then
+               return 0;
+       fi
+       return 1;
+}
+
+mountpoint_has_sd_boot() {
+       mountpoint="$1"
+       if [ -f "${mountpoint}/$PMX_LOADER_CONF" ]; then
+               return 0;
+       fi
+       return 1;
+}
diff --git a/proxmox-boot/zz-proxmox-boot b/proxmox-boot/zz-proxmox-boot
index 5fe16a6..a6629aa 100755
--- a/proxmox-boot/zz-proxmox-boot
+++ b/proxmox-boot/zz-proxmox-boot
@@ -76,7 +76,7 @@ update_esp_func() {
        mount "${path}" "${mountpoint}" || \
                { warn "mount of ${path} failed - skipping"; return; }
        if [ -d /sys/firmware/efi ]; then
-               if [ ! -f "${mountpoint}/$PMX_LOADER_CONF" ]; then
+               if ! mountpoint_has_sd_boot "${mountpoint}"; then
                        warn "${path} contains no loader.conf - skipping"
                        return
                fi
@@ -84,7 +84,7 @@ update_esp_func() {
                        warn "${path}/$PMX_ESP_DIR does not exist- skipping"
                        return
                fi
-       elif [ ! -d "${mountpoint}/grub" ]; then
+       elif ! mountpoint_has_grub "${mountpoint}"; then
                warn "${path} contains no grub directory - skipping"
                return
        fi
-- 
2.30.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to