+};
+
+sub run_cli {
+ my ($class, $pwcallback, $podfn, $preparefunc) = @_;
+
+ # Note: "depreciated function run_cli - use run_cli_handler instead";
+ # silently ignore $podfn , which is no longer supported.
+
+ die "password callback is no longer supported" if $pwcallback;
+
+ run_cli_handler($class, prepare => $preparefunc);
+}
+
+sub run_cli_handler {
+ my ($class, %params) = @_;
+
+ $cli_handler_class = $class;
+
+ $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
+
+ foreach my $key (keys %params) {
+ next if $key eq 'prepare';
+ next if $key eq 'no_init'; # used by lxc hooks
+ next if $key eq 'no_rpcenv';
+ die "unknown parameter '$key'";
+ }
+
+ my $preparefunc = $params{prepare};
+ my $no_init = $params{no_init};
+ my $no_rpcenv = $params{no_rpcenv};
+
+ my $pwcallback = $class->can('read_password');
+ my $stringfilemap = $class->can('string_param_file_mapping');
+
+ $exename = &$get_exe_name($class);
+
+ initlog($exename);
+
+ if ($class !~ m/^PVE::Service::/) {
+ die "please run as root\n" if $> != 0;
+
+ PVE::INotify::inotify_init() if !$no_init;
+
+ if (!$no_rpcenv) {
+ my $rpcenv = PVE::RPCEnvironment->init('cli');
+ $rpcenv->init_request() if !$no_init;
+ $rpcenv->set_language($ENV{LANG});
+ $rpcenv->set_user('root@pam');
+ }
+ }
+
+ no strict 'refs';
+ my $def = ${"${class}::cmddef"};
+
+ if (ref($def) eq 'ARRAY') {
+ &$handle_simple_cmd($def, \@ARGV, $pwcallback, $preparefunc, $stringfilemap);
+ } else {
+ $cmddef = $def;
+ my $cmd = shift @ARGV;
+ &$handle_cmd($cmddef, $exename, $cmd, \@ARGV, $pwcallback, $preparefunc, $stringfilemap);
+ }
+
+ exit 0;