From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 8822464846 for ; Thu, 3 Mar 2022 20:08:13 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 70CCF3587D for ; Thu, 3 Mar 2022 20:08:13 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 068703583A for ; Thu, 3 Mar 2022 20:08:12 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id D53B646EB4 for ; Thu, 3 Mar 2022 20:08:11 +0100 (CET) From: Stoiko Ivanov To: pve-devel@lists.proxmox.com Date: Thu, 3 Mar 2022 20:07:52 +0100 Message-Id: <20220303190759.3527703-4-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220303190759.3527703-1-s.ivanov@proxmox.com> References: <20220303190759.3527703-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.227 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH pve-kernel-meta v2 3/8] proxmox-boot: add helpers to check for bootloader configs X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Mar 2022 19:08:13 -0000 Signed-off-by: Stoiko Ivanov --- 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