From nobody Wed Dec 15 14:24:39 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id EE44718E903E; Wed, 15 Dec 2021 14:24:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JDcvX1kWZz3s1w; Wed, 15 Dec 2021 14:24:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1878F1DB7B; Wed, 15 Dec 2021 14:24:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BFEOd2p037352; Wed, 15 Dec 2021 14:24:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BFEOd5h037351; Wed, 15 Dec 2021 14:24:39 GMT (envelope-from git) Date: Wed, 15 Dec 2021 14:24:39 GMT Message-Id: <202112151424.1BFEOd5h037351@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 9935b0e8ea41 - main - bsdinstall: zfsboot: Prompt user for zpool name if the pool already exists List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9935b0e8ea41804b32576987531be4d31ba705f1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639578280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nEHA8KkZtLdSMf7fXGAJzKYoNrmQ9jrdxilgWpNuWKw=; b=proZxdbPeG4mW2sPgmvjj7Qt5pBUu/168Y+MvfsybiUhfVMUAUrhd1IcRjVUIJc/N99gb7 ZQOydKcxl/Dy+wVK3bCHcVK/+iBcblNLuYIctsMzfbwi7MtA/imXnJhEyHJT0ROmsdDg6O nD6/1zVtioXYWAC6cIPTBmx1Ps+uhTXWYMyqaRhKXFuMgthAM63ly2paYVTlPIq9zpWCmM x1895yZjPDroVI4VwHzbvYqqOscdkYGSN1dDyLFhr6NxjG2Vps69qUzL8imrrkPg9ZEsw5 bQAMHbvqnNBeB1N0JS55M3GidJ2ZYMGv4xjpBoTROUOIwEKZWjYJy4/PArGMbQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639578280; a=rsa-sha256; cv=none; b=wO5lN1bgKcPHIH5j/DSFP+nRWt3uhWWs0ysXmYi8iiRlEHgL8v2eUM//1D4yr8X1/E4oTw klCqlkAsYCUjB8Kpgn+qYzDvgPZ5Ccrj4NUegISGaC2mgKsns/2Bffn4U5S7fblEqoVCwg 51QORCfLBvVKQ9XfnToBBG4tWTemG7dEeEGJRuIQDFyfY/NOAnXb2op3d1lYxm4RfmAcCk AjsIMD+sJzjkEtk+6XGYXQESJVmxGGhcLArJJ5YcFj2MLxf8+ByPVxQ+IssJpPzyQegNbU YZiOf9N3Upnkejq6lVv+QMHoJrW+/nvontc0E+SFEINHo2/gstL3+omM4GPKHQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=9935b0e8ea41804b32576987531be4d31ba705f1 commit 9935b0e8ea41804b32576987531be4d31ba705f1 Author: Emmanuel Vadot AuthorDate: 2021-12-08 10:37:50 +0000 Commit: Emmanuel Vadot CommitDate: 2021-12-15 14:24:07 +0000 bsdinstall: zfsboot: Prompt user for zpool name if the pool already exists If one install FreeBSD on multiple disks (say 13 and CURRENT) the first created pool will always be used. Prompt the user for a new pool name if we detect that the default or supplied one already exists. Reviewed by: imp MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D33331 --- usr.sbin/bsdinstall/scripts/zfsboot | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/usr.sbin/bsdinstall/scripts/zfsboot b/usr.sbin/bsdinstall/scripts/zfsboot index 45c8b001c393..4867538354cb 100755 --- a/usr.sbin/bsdinstall/scripts/zfsboot +++ b/usr.sbin/bsdinstall/scripts/zfsboot @@ -1573,6 +1573,28 @@ dialog_menu_diskinfo() return $SUCCESS } +dialog_zpool_name() +{ + local prompt="$* is already taken, please enter a name for the ZFS pool \ + (Or confirm using the same name by just pressing enter)" + local hline= + local value="$*" + local height width + + f_dialog_inputbox_size height width \ + "$DIALOG_TITLE" "$DIALOG_BACKTITLE" "$prompt" "$value" "$hline" + + $DIALOG \ + --title "$DIALOG_TITLE" \ + --backtitle "$DIALOG_BACKTITLE" \ + --hline "$hline" \ + --ok-label "Ok" \ + --no-cancel \ + --inputbox "$prompt" \ + $height $width "$value" \ + 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD +} + ############################################################ MAIN # @@ -1591,6 +1613,16 @@ f_dprintf "BSDINSTALL_CHROOT=[%s]" "$BSDINSTALL_CHROOT" f_dprintf "BSDINSTALL_TMPETC=[%s]" "$BSDINSTALL_TMPETC" f_dprintf "FSTAB_FMT=[%s]" "$FSTAB_FMT" +pools=$(zpool import | awk '$1 == "pool:" { print $2}') +for pool in ${pools}; do + f_dprintf "Checking ${pool} against ${ZFSBOOT_POOL_NAME}" + if [ "${pool}" = "${ZFSBOOT_POOL_NAME}" ]; then + f_dprintf "Pool ${pool} already taken" + ZFSBOOT_POOL_NAME=$(dialog_zpool_name "${ZFSBOOT_POOL_NAME}") + break; + fi +done + # # Determine default boot type #