]> git.proxmox.com Git - pve-manager.git/blobdiff - bin/pveceph
move preparations into prepare()
[pve-manager.git] / bin / pveceph
index 18a4e8b15aa0948ec4f0391ba658c2ce3255297c..a7467d95ab7ec7c87a83580938b435ea5e3fcdf8 100755 (executable)
@@ -24,19 +24,24 @@ use PVE::CLIHandler;
 
 use base qw(PVE::CLIHandler);
 
-$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
+my $cmddef;
+my $nodename = PVE::INotify::nodename();
+
+sub prepare {
+    $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
 
-initlog ('pveceph');
+    initlog ('pveceph');
 
-die "please run as root\n" if $> != 0;
+    die "please run as root\n" if $> != 0;
 
-PVE::INotify::inotify_init();
+    PVE::INotify::inotify_init();
 
-my $rpcenv = PVE::RPCEnvironment->init('cli');
+    my $rpcenv = PVE::RPCEnvironment->init('cli');
 
-$rpcenv->init_request();
-$rpcenv->set_language($ENV{LANG});
-$rpcenv->set_user('root@pam');
+    $rpcenv->init_request();
+    $rpcenv->set_language($ENV{LANG});
+    $rpcenv->set_user('root@pam');
+}
 
 my $upid_exit = sub {
     my $upid = shift;
@@ -44,8 +49,6 @@ my $upid_exit = sub {
     exit($status eq 'OK' ? 0 : -1);
 };
 
-my $nodename = PVE::INotify::nodename();
-
 __PACKAGE__->register_method ({
     name => 'purge',
     path => 'purge',
@@ -169,7 +172,7 @@ my $cmddef = {
 
 my $cmd = shift;
 
-PVE::CLIHandler::handle_cmd($cmddef, "pveceph", $cmd, \@ARGV, undef, $0);
+PVE::CLIHandler::handle_cmd($cmddef, "pveceph", $cmd, \@ARGV, undef, $0, \&prepare);
 
 exit 0;