public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager v2] fix #4364: pveceph: add confirmation dialogue for ceph installation
@ 2023-07-05 18:02 Max Carrara
  2023-07-06 14:10 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Max Carrara @ 2023-07-05 18:02 UTC (permalink / raw)
  To: pve-devel

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 <m.carrara@proxmox.com>
---

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 = <STDIN>;
+	    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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-06 14:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-05 18:02 [pve-devel] [PATCH manager v2] fix #4364: pveceph: add confirmation dialogue for ceph installation Max Carrara
2023-07-06 14:10 ` [pve-devel] applied: " Thomas Lamprecht

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