all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-kernel-meta v2 3/8] proxmox-boot: add helpers to check for bootloader configs
Date: Thu,  3 Mar 2022 20:07:52 +0100	[thread overview]
Message-ID: <20220303190759.3527703-4-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20220303190759.3527703-1-s.ivanov@proxmox.com>

Signed-off-by: Stoiko Ivanov <s.ivanov@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





  parent reply	other threads:[~2022-03-03 19:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03 19:07 [pve-devel] [PATCH pve-kernel-meta/pve-installer v2] improve boot-mode switching Stoiko Ivanov
2022-03-03 19:07 ` [pve-devel] [PATCH pve-kernel-meta v2 1/8] rename pve-efiboot-manual-kernels to proxmox-boot-manual-kernels Stoiko Ivanov
2022-03-04 10:51   ` Thomas Lamprecht
2022-03-03 19:07 ` [pve-devel] [PATCH pve-kernel-meta v2 2/8] proxmox-boot: add reinit subcommand Stoiko Ivanov
2022-03-03 19:07 ` Stoiko Ivanov [this message]
2022-03-03 19:07 ` [pve-devel] [PATCH pve-kernel-meta v2 4/8] proxmox-boot: refresh based on bootloader config instead of bootmode Stoiko Ivanov
2022-03-03 19:07 ` [pve-devel] [PATCH pve-kernel-meta v2 5/8] proxmox-boot: remove now obsolete EFI/proxmoxdir if it exists Stoiko Ivanov
2022-03-03 19:07 ` [pve-devel] [PATCH pve-kernel-meta v2 6/8] proxmox-boot: init bootloaders based on esp contents Stoiko Ivanov
2022-03-03 19:07 ` [pve-devel] [PATCH pve-kernel-meta v2 7/8] proxmox-boot: allow to manually specify bootloader Stoiko Ivanov
2022-03-03 19:07 ` [pve-devel] [PATCH pve-kernel-meta v2 8/8] proxmox-boot: fix #3729 add --graceful to bootctl invocation Stoiko Ivanov
2022-03-03 19:07 ` [pve-devel] [PATCH installer v2 1/2] remove /mnt/hostrun after install Stoiko Ivanov
2022-03-03 19:07 ` [pve-devel] [PATCH installer v2 2/2] use proxmox-boot-tool for all uefi installs Stoiko Ivanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220303190759.3527703-4-s.ivanov@proxmox.com \
    --to=s.ivanov@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal