proxmox-backup-manager: avoid proxmox_rest_server::init_worker_tasks() for "bashcomplete" and "printdoc"

This commit is contained in:
Dietmar Maurer 2021-09-24 12:31:42 +02:00
parent 0fd55b08d9
commit bbd57396d7
1 changed files with 11 additions and 6 deletions

View File

@ -400,6 +400,10 @@ async fn run() -> Result<(), Error> {
CliCommand::new(&API_METHOD_GET_VERSIONS) CliCommand::new(&API_METHOD_GET_VERSIONS)
); );
let args: Vec<String> = std::env::args().take(2).collect();
let avoid_init = args.len() >= 2 && (args[1] == "bashcomplete" || args[1] == "printdoc");
if !avoid_init {
let backup_user = pbs_config::backup_user()?; let backup_user = pbs_config::backup_user()?;
let file_opts = CreateOptions::new().owner(backup_user.uid).group(backup_user.gid); let file_opts = CreateOptions::new().owner(backup_user.uid).group(backup_user.gid);
proxmox_rest_server::init_worker_tasks(pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(), file_opts.clone())?; proxmox_rest_server::init_worker_tasks(pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(), file_opts.clone())?;
@ -407,6 +411,7 @@ async fn run() -> Result<(), Error> {
let mut commando_sock = proxmox_rest_server::CommandoSocket::new(proxmox_rest_server::our_ctrl_sock(), backup_user.gid); let mut commando_sock = proxmox_rest_server::CommandoSocket::new(proxmox_rest_server::our_ctrl_sock(), backup_user.gid);
proxmox_rest_server::register_task_control_commands(&mut commando_sock)?; proxmox_rest_server::register_task_control_commands(&mut commando_sock)?;
commando_sock.spawn()?; commando_sock.spawn()?;
}
let mut rpcenv = CliEnvironment::new(); let mut rpcenv = CliEnvironment::new();
rpcenv.set_auth_id(Some(String::from("root@pam"))); rpcenv.set_auth_id(Some(String::from("root@pam")));