efb7c5348c
this provides some generic api call mechanisms like pvesh/pmgsh. by default it uses the https api on localhost (creating a token if called as root, else requesting the root@pam password interactively) this is mainly intended for debugging, but it is also useful for situations where some api calls do not have an equivalent in a binary and a user does not want to go through the api not implemented are the http2 api calls (since it is a separate api an it wouldn't be that easy to do) there are a few quirks though, related to the 'ls' command: i extract the 'child-link' from the property name of the 'match_all' statement of the router, but this does not always match with the property from the relevant 'get' api call so it fails there (e.g. /tape/drive ) this can be fixed in the respective api calls (e.g. by renaming the parameter that comes from the path) Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
25 lines
738 B
Rust
25 lines
738 B
Rust
use proxmox::api::{
|
|
cli::{run_cli_command, CliCommandMap, CliEnvironment},
|
|
RpcEnvironment,
|
|
};
|
|
|
|
mod proxmox_backup_debug;
|
|
use proxmox_backup_debug::*;
|
|
|
|
fn main() {
|
|
let cmd_def = CliCommandMap::new()
|
|
.insert("inspect", inspect::inspect_commands())
|
|
.insert("recover", recover::recover_commands())
|
|
.insert("api", api::api_commands());
|
|
|
|
let uid = nix::unistd::Uid::current();
|
|
let username = match nix::unistd::User::from_uid(uid) {
|
|
Ok(Some(user)) => user.name,
|
|
_ => "root@pam".to_string(),
|
|
};
|
|
let mut rpcenv = CliEnvironment::new();
|
|
rpcenv.set_auth_id(Some(format!("{}@pam", username)));
|
|
|
|
run_cli_command(cmd_def, rpcenv, Some(|future| pbs_runtime::main(future)));
|
|
}
|