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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 49908C126 for ; Wed, 5 Jul 2023 20:02:48 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 338D6378D4 for ; Wed, 5 Jul 2023 20:02:48 +0200 (CEST) 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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 5 Jul 2023 20:02:46 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 51C0E45A8E for ; Wed, 5 Jul 2023 20:02:46 +0200 (CEST) From: Max Carrara To: pve-devel@lists.proxmox.com Date: Wed, 5 Jul 2023 20:02:40 +0200 Message-Id: <20230705180240.300150-1-m.carrara@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.013 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com, pveceph.pm] Subject: [pve-devel] [PATCH manager v2] fix #4364: pveceph: add confirmation dialogue for ceph installation 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: Wed, 05 Jul 2023 18:02:48 -0000 Displays a confirmation dialogue if the user didn't explicitly provide a valid ceph version via the `--version` flag and if stdout is connected to a tty. Signed-off-by: Max Carrara --- v2 of this little patch incorporates the given feedback[0] (thanks btw!) Regarding exit codes: Even though it's not too important, I think we should stick with a non-zero exit code here; at least from what I've encountered, installation wizards or similar will only exit with 0 if the installation succeeded *or* if the thing to be installed is already installed. That way subsequent commands are only executed if the things to be installed are actually there, as further commands *might* already depend on them, e.g.: apt-get install -y neofetch && neofetch pveceph install --version quincy && ceph status This is mostly philosophical, but I've personally found that behaviour useful in some situations. [0]: https://lists.proxmox.com/pipermail/pve-devel/2023-July/057993.html PVE/CLI/pveceph.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/PVE/CLI/pveceph.pm b/PVE/CLI/pveceph.pm index b47f8cc1..8cff04c5 100755 --- a/PVE/CLI/pveceph.pm +++ b/PVE/CLI/pveceph.pm @@ -176,6 +176,16 @@ __PACKAGE__->register_method ({ } else { die "unsupported ceph version: $cephver"; } + + if (-t STDOUT && !$param->{version}) { + print "This will install Ceph " . ucfirst($cephver) . " - continue (y/N)? "; + + my $answer = ; + my $continue = defined($answer) && $answer =~ m/^\s*y(?:es)?\s*$/i; + + die "Aborting installation as requested\n" if !$continue; + } + PVE::Tools::file_set_contents("/etc/apt/sources.list.d/ceph.list", $repolist); my $supported_re = join('|', $supported_ceph_versions->@*); -- 2.39.2