public inbox for pve-devel@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 2/8] proxmox-boot: add reinit subcommand
Date: Thu,  3 Mar 2022 20:07:51 +0100	[thread overview]
Message-ID: <20220303190759.3527703-3-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20220303190759.3527703-1-s.ivanov@proxmox.com>

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 <s.ivanov@proxmox.com>
---
unchanged

 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 <partition> [--force]"
 	warn "       $0 init <partition>"
+	warn "       $0 reinit"
 	warn "       $0 clean [--dry-run]"
 	warn "       $0 refresh [--hook <name>]"
 	warn "       $0 kernel <add|remove> <kernel-version>"
@@ -325,6 +338,10 @@ help() {
 	echo ""
 	echo "    initialize EFI system partition at <partition> 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





  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 ` Stoiko Ivanov [this message]
2022-03-03 19:07 ` [pve-devel] [PATCH pve-kernel-meta v2 3/8] proxmox-boot: add helpers to check for bootloader configs Stoiko Ivanov
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-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal