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 0941D63423 for ; Mon, 14 Feb 2022 16:57:56 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E925C258AF for ; Mon, 14 Feb 2022 16:57:55 +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 07E392586D for ; Mon, 14 Feb 2022 16:57:54 +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 CEF5046208 for ; Mon, 14 Feb 2022 16:57:53 +0100 (CET) From: Stoiko Ivanov To: pve-devel@lists.proxmox.com Date: Mon, 14 Feb 2022 16:57:32 +0100 Message-Id: <20220214155737.1444136-3-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220214155737.1444136-1-s.ivanov@proxmox.com> References: <20220214155737.1444136-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.236 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 2/5] proxmox-boot: add reinit subcommand 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: Mon, 14 Feb 2022 15:57:56 -0000 to iterate over all configured ESPs and refresh the boot-loader installations. the init function was changed to not run refresh directly - to prevent refresh from running once for each ESP currently reinit does not imply refresh Signed-off-by: Stoiko Ivanov --- bin/grub-install-wrapper | 19 ++----------------- bin/proxmox-boot-tool | 39 +++++++++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/bin/grub-install-wrapper b/bin/grub-install-wrapper index 9facd04..90c144e 100755 --- a/bin/grub-install-wrapper +++ b/bin/grub-install-wrapper @@ -2,22 +2,6 @@ set -e -. /usr/share/pve-kernel-helper/scripts/functions - -init_boot_disks() { - if ! (echo "${curr_uuid}" | grep -qE '[0-9a-fA-F]{4}-[0-9a-fA-F]{4}'); then - warn "WARN: ${curr_uuid} read from ${ESP_LIST} does not look like a VFAT-UUID - skipping" - return - fi - - path="/dev/disk/by-uuid/$curr_uuid" - if [ ! -e "${path}" ]; then - warn "WARN: ${path} does not exist - clean '${ESP_LIST}'! - skipping" - return - fi - proxmox-boot-tool init "$path" -} - if proxmox-boot-tool status --quiet; then # detect when being called by dpkg (e.g. grub-pc.postinst if [ -n "$DPKG_RUNNING_VERSION" ] && echo "$DPKG_MAINTSCRIPT_PACKAGE" | grep -sq "^grub-"; then @@ -28,7 +12,8 @@ if proxmox-boot-tool status --quiet; then MARKER_FILE="/tmp/proxmox-boot-tool.dpkg.marker" if [ ! -e "$MARKER_FILE" ]; then warn "This system is booted via proxmox-boot-tool, running proxmox-boot-tool init for all configured bootdisks" - loop_esp_list init_boot_disks + proxmox-boot-tool reinit + proxmox-boot-tool refresh touch "$MARKER_FILE" exit 0 else diff --git a/bin/proxmox-boot-tool b/bin/proxmox-boot-tool index 178b6fb..5197f5b 100755 --- a/bin/proxmox-boot-tool +++ b/bin/proxmox-boot-tool @@ -124,7 +124,7 @@ format() { exit 0 } -init() { +init_bootloader() { part="$1" _get_partition_info "$part" @@ -174,8 +174,20 @@ init() { echo "Adding '$part' to list of synced ESPs.." _add_entry_to_list_file "$ESP_LIST" "$UUID" - echo "Refreshing kernels and initrds.." - refresh +} + +reinit() { + if ! (echo "${curr_uuid}" | grep -qE '[0-9a-fA-F]{4}-[0-9a-fA-F]{4}'); then + warn "WARN: ${curr_uuid} read from ${ESP_LIST} does not look like a VFAT-UUID - skipping" + return + fi + + path="/dev/disk/by-uuid/$curr_uuid" + if [ ! -e "${path}" ]; then + warn "WARN: ${path} does not exist - clean '${ESP_LIST}'! - skipping" + return + fi + init_bootloader "$path" } _clean_impl() { @@ -306,6 +318,7 @@ usage() { warn "" warn " $0 format [--force]" warn " $0 init " + warn " $0 reinit" warn " $0 clean [--dry-run]" warn " $0 refresh [--hook ]" warn " $0 kernel " @@ -325,6 +338,10 @@ help() { echo "" echo " initialize EFI system partition at for automatic synchronization of pve-kernels and their associated initrds." echo "" + echo "USAGE: $0 reinit" + echo "" + echo " reinitialize all configured EFI system partitions from $ESP_LIST." + echo "" echo "USAGE: $0 clean [--dry-run]" echo "" echo " remove no longer existing EFI system partition UUIDs from $ESP_LIST. Use --dry-run to only print outdated entries instead of removing them." @@ -493,7 +510,21 @@ case "$1" in usage exit 1 fi - init "$@" + init_bootloader "$@" + echo "Refreshing kernels and initrds.." + refresh + exit 0 + ;; + 'reinit') + reexec_in_mountns "$@" + shift + if [ "$#" -eq 1 ]; then + warn "E: no arguments allowed." + warn "" + usage + exit 1 + fi + loop_esp_list reinit "$@" exit 0 ;; 'clean') -- 2.30.2