-sub run_cli {
- my ($class, $pwcallback, $podfn, $preparefunc) = @_;
-
- $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
-
- $exename = &$get_exe_name($class);
-
- initlog($exename);
-
-
- if ($class !~ m/^PVE::Service::/) {
- die "please run as root\n" if $> != 0;
-
- PVE::INotify::inotify_init();
-
- my $rpcenv = PVE::RPCEnvironment->init('cli');
- $rpcenv->init_request();
- $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, $podfn, $preparefunc);
- } else {
- $cmddef = $def;
- my $cmd = shift @ARGV;
- handle_cmd($cmddef, $exename, $cmd, \@ARGV, $pwcallback, $podfn, $preparefunc);
- }