packager/pkgr/src/main.rs

42 lines
871 B
Rust

use crate::commands::Cli;
use clap::Parser;
use log::trace;
mod commands;
mod logging;
mod package;
mod process;
mod tmpfs;
mod config;
mod types;
thread_local! {
static CONFIG: config::Config = config::Config::from_path("/etc/pkgr.toml")
.unwrap_or(config::Config::default());
}
fn main() {
logging::setup_logger()
.expect("unable to set logger.");
#[cfg(not(debug_assertions))]
{
if unsafe { libc::getuid() } != 0 {
use log::error;
error!("pkgr must be run as root.");
std::process::exit(1);
}
}
trace!("Parsing command line arguments...");
let c = Cli::parse();
trace!("Command line arguments: {:?}", c);
trace!("Executing command...");
c.command.execute();
trace!("Command executed.");
trace!("Exiting...");
}