split out pbs-buildcfg module
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
@ -14,7 +14,6 @@ use proxmox_backup::server::{
|
||||
use proxmox_backup::tools::daemon;
|
||||
use proxmox_backup::auth_helpers::*;
|
||||
use proxmox_backup::config;
|
||||
use proxmox_backup::buildcfg;
|
||||
|
||||
fn main() {
|
||||
proxmox_backup::tools::setup_safe_path_env();
|
||||
@ -58,7 +57,7 @@ async fn run() -> Result<(), Error> {
|
||||
let _ = csrf_secret(); // load with lazy_static
|
||||
|
||||
let mut config = server::ApiConfig::new(
|
||||
buildcfg::JS_DIR,
|
||||
pbs_buildcfg::JS_DIR,
|
||||
&proxmox_backup::api2::ROUTER,
|
||||
RpcEnvironmentType::PRIVILEGED,
|
||||
default_api_auth(),
|
||||
@ -66,7 +65,7 @@ async fn run() -> Result<(), Error> {
|
||||
|
||||
let mut commando_sock = server::CommandoSocket::new(server::our_ctrl_sock());
|
||||
|
||||
config.enable_file_log(buildcfg::API_ACCESS_LOG_FN, &mut commando_sock)?;
|
||||
config.enable_file_log(pbs_buildcfg::API_ACCESS_LOG_FN, &mut commando_sock)?;
|
||||
|
||||
let rest_server = RestServer::new(config);
|
||||
|
||||
@ -91,7 +90,7 @@ async fn run() -> Result<(), Error> {
|
||||
"proxmox-backup.service",
|
||||
);
|
||||
|
||||
server::write_pid(buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
|
||||
server::write_pid(pbs_buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
|
||||
daemon::systemd_notify(daemon::SystemdNotify::Ready)?;
|
||||
|
||||
let init_result: Result<(), Error> = try_block!({
|
||||
|
@ -32,10 +32,9 @@ use proxmox_backup::{
|
||||
},
|
||||
};
|
||||
|
||||
use pbs_buildcfg::configdir;
|
||||
|
||||
use proxmox_backup::api2::types::Authid;
|
||||
use proxmox_backup::configdir;
|
||||
use proxmox_backup::buildcfg;
|
||||
use proxmox_backup::server;
|
||||
use proxmox_backup::auth_helpers::*;
|
||||
use proxmox_backup::tools::{
|
||||
@ -85,7 +84,7 @@ async fn run() -> Result<(), Error> {
|
||||
let _ = csrf_secret(); // load with lazy_static
|
||||
|
||||
let mut config = ApiConfig::new(
|
||||
buildcfg::JS_DIR,
|
||||
pbs_buildcfg::JS_DIR,
|
||||
&proxmox_backup::api2::ROUTER,
|
||||
RpcEnvironmentType::PUBLIC,
|
||||
default_api_auth(),
|
||||
@ -100,14 +99,14 @@ async fn run() -> Result<(), Error> {
|
||||
config.add_alias("widgettoolkit", "/usr/share/javascript/proxmox-widget-toolkit");
|
||||
config.add_alias("docs", "/usr/share/doc/proxmox-backup/html");
|
||||
|
||||
let mut indexpath = PathBuf::from(buildcfg::JS_DIR);
|
||||
let mut indexpath = PathBuf::from(pbs_buildcfg::JS_DIR);
|
||||
indexpath.push("index.hbs");
|
||||
config.register_template("index", &indexpath)?;
|
||||
config.register_template("console", "/usr/share/pve-xtermjs/index.html.hbs")?;
|
||||
|
||||
let mut commando_sock = server::CommandoSocket::new(server::our_ctrl_sock());
|
||||
|
||||
config.enable_file_log(buildcfg::API_ACCESS_LOG_FN, &mut commando_sock)?;
|
||||
config.enable_file_log(pbs_buildcfg::API_ACCESS_LOG_FN, &mut commando_sock)?;
|
||||
|
||||
let rest_server = RestServer::new(config);
|
||||
|
||||
@ -167,7 +166,7 @@ async fn run() -> Result<(), Error> {
|
||||
"proxmox-backup-proxy.service",
|
||||
);
|
||||
|
||||
server::write_pid(buildcfg::PROXMOX_BACKUP_PROXY_PID_FN)?;
|
||||
server::write_pid(pbs_buildcfg::PROXMOX_BACKUP_PROXY_PID_FN)?;
|
||||
daemon::systemd_notify(daemon::SystemdNotify::Ready)?;
|
||||
|
||||
let init_result: Result<(), Error> = try_block!({
|
||||
@ -696,7 +695,7 @@ async fn schedule_task_log_rotate() {
|
||||
|
||||
let max_size = 32 * 1024 * 1024 - 1;
|
||||
let max_files = 14;
|
||||
let mut logrotate = LogRotate::new(buildcfg::API_ACCESS_LOG_FN, true)
|
||||
let mut logrotate = LogRotate::new(pbs_buildcfg::API_ACCESS_LOG_FN, true)
|
||||
.ok_or_else(|| format_err!("could not get API access log file names"))?;
|
||||
|
||||
if logrotate.rotate(max_size, None, Some(max_files))? {
|
||||
@ -707,7 +706,7 @@ async fn schedule_task_log_rotate() {
|
||||
worker.log("API access log was not rotated".to_string());
|
||||
}
|
||||
|
||||
let mut logrotate = LogRotate::new(buildcfg::API_AUTH_LOG_FN, true)
|
||||
let mut logrotate = LogRotate::new(pbs_buildcfg::API_AUTH_LOG_FN, true)
|
||||
.ok_or_else(|| format_err!("could not get API auth log file names"))?;
|
||||
|
||||
if logrotate.rotate(max_size, None, Some(max_files))? {
|
||||
@ -739,7 +738,7 @@ async fn command_reopen_logfiles() -> Result<(), Error> {
|
||||
let sock = server::our_ctrl_sock();
|
||||
let f1 = server::send_command(sock, "{\"command\":\"api-access-log-reopen\"}\n");
|
||||
|
||||
let pid = server::read_pid(buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
|
||||
let pid = server::read_pid(pbs_buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
|
||||
let sock = server::ctrl_sock_from_pid(pid);
|
||||
let f2 = server::send_command(sock, "{\"command\":\"api-access-log-reopen\"}\n");
|
||||
|
||||
|
@ -10,10 +10,11 @@ use proxmox::{
|
||||
tools::fs::file_get_json,
|
||||
};
|
||||
|
||||
use pbs_buildcfg;
|
||||
|
||||
use proxmox_backup::api2::access::user::UserWithTokens;
|
||||
use proxmox_backup::api2::types::*;
|
||||
use proxmox_backup::backup::BackupDir;
|
||||
use proxmox_backup::buildcfg;
|
||||
use proxmox_backup::client::*;
|
||||
use proxmox_backup::tools;
|
||||
|
||||
@ -379,7 +380,7 @@ pub fn place_xdg_file(
|
||||
/// "www-data", so we use a custom one in /run/proxmox-backup/<uid> instead.
|
||||
pub fn get_user_run_dir() -> Result<std::path::PathBuf, Error> {
|
||||
let uid = nix::unistd::Uid::current();
|
||||
let mut path: std::path::PathBuf = buildcfg::PROXMOX_BACKUP_RUN_DIR.into();
|
||||
let mut path: std::path::PathBuf = pbs_buildcfg::PROXMOX_BACKUP_RUN_DIR.into();
|
||||
path.push(uid.to_string());
|
||||
tools::create_run_dir()?;
|
||||
std::fs::create_dir_all(&path)?;
|
||||
|
@ -18,7 +18,7 @@ use proxmox::tools::{
|
||||
|
||||
use proxmox_backup::backup::backup_user;
|
||||
use proxmox_backup::client::{VsockClient, DEFAULT_VSOCK_PORT};
|
||||
use proxmox_backup::{buildcfg, tools};
|
||||
use proxmox_backup::tools;
|
||||
|
||||
use super::SnapRestoreDetails;
|
||||
|
||||
@ -26,7 +26,7 @@ const PBS_VM_NAME: &str = "pbs-restore-vm";
|
||||
const MAX_CID_TRIES: u64 = 32;
|
||||
|
||||
fn create_restore_log_dir() -> Result<String, Error> {
|
||||
let logpath = format!("{}/file-restore", buildcfg::PROXMOX_BACKUP_LOG_DIR);
|
||||
let logpath = format!("{}/file-restore", pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR);
|
||||
|
||||
proxmox::try_block!({
|
||||
let backup_user = backup_user()?;
|
||||
@ -38,7 +38,7 @@ fn create_restore_log_dir() -> Result<String, Error> {
|
||||
.owner(nix::unistd::ROOT)
|
||||
.group(nix::unistd::Gid::from_raw(0));
|
||||
|
||||
create_path(buildcfg::PROXMOX_BACKUP_LOG_DIR, None, Some(opts))?;
|
||||
create_path(pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR, None, Some(opts))?;
|
||||
create_path(&logpath, None, Some(opts_root))?;
|
||||
Ok(())
|
||||
})
|
||||
@ -48,11 +48,11 @@ fn create_restore_log_dir() -> Result<String, Error> {
|
||||
}
|
||||
|
||||
fn validate_img_existance(debug: bool) -> Result<(), Error> {
|
||||
let kernel = PathBuf::from(buildcfg::PROXMOX_BACKUP_KERNEL_FN);
|
||||
let kernel = PathBuf::from(pbs_buildcfg::PROXMOX_BACKUP_KERNEL_FN);
|
||||
let initramfs = PathBuf::from(if debug {
|
||||
buildcfg::PROXMOX_BACKUP_INITRAMFS_DBG_FN
|
||||
pbs_buildcfg::PROXMOX_BACKUP_INITRAMFS_DBG_FN
|
||||
} else {
|
||||
buildcfg::PROXMOX_BACKUP_INITRAMFS_FN
|
||||
pbs_buildcfg::PROXMOX_BACKUP_INITRAMFS_FN
|
||||
});
|
||||
if !kernel.exists() || !initramfs.exists() {
|
||||
bail!("cannot run file-restore VM: package 'proxmox-backup-restore-image' is not (correctly) installed");
|
||||
@ -93,9 +93,9 @@ async fn create_temp_initramfs(ticket: &str, debug: bool) -> Result<(Fd, String)
|
||||
tools::fd_change_cloexec(tmp_fd.0, false)?;
|
||||
|
||||
let initramfs = if debug {
|
||||
buildcfg::PROXMOX_BACKUP_INITRAMFS_DBG_FN
|
||||
pbs_buildcfg::PROXMOX_BACKUP_INITRAMFS_DBG_FN
|
||||
} else {
|
||||
buildcfg::PROXMOX_BACKUP_INITRAMFS_FN
|
||||
pbs_buildcfg::PROXMOX_BACKUP_INITRAMFS_FN
|
||||
};
|
||||
|
||||
let mut f = File::from_std(unsafe { std::fs::File::from_raw_fd(tmp_fd.0) });
|
||||
@ -184,7 +184,7 @@ pub async fn start_vm(
|
||||
"none",
|
||||
"-enable-kvm",
|
||||
"-kernel",
|
||||
buildcfg::PROXMOX_BACKUP_KERNEL_FN,
|
||||
pbs_buildcfg::PROXMOX_BACKUP_KERNEL_FN,
|
||||
"-initrd",
|
||||
&ramfs_path,
|
||||
"-append",
|
||||
|
Reference in New Issue
Block a user