]> git.proxmox.com Git - pve-manager.git/commitdiff
fix #4364: pveceph: add confirmation dialogue for ceph installation
authorMax Carrara <m.carrara@proxmox.com>
Wed, 5 Jul 2023 18:02:40 +0000 (20:02 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 6 Jul 2023 14:10:25 +0000 (16:10 +0200)
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>
PVE/CLI/pveceph.pm

index b47f8cc192eb893569498989f427f384d46a8a12..8cff04c54407fdac1697e76be3fa765fd3ef6f41 100755 (executable)
@@ -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->@*);