diff --git a/cli/src/helpers.rs b/cli/src/helpers.rs index 715f76bc5..8386378b1 100644 --- a/cli/src/helpers.rs +++ b/cli/src/helpers.rs @@ -1,4 +1,5 @@ use std::{ + env, fs::{self, File}, io::{Read, Write}, net::IpAddr, @@ -272,12 +273,20 @@ pub fn gen_periphery_config(sub_matches: &ArgMatches) { .map(|p| p.as_str()) .unwrap_or("") .split(",") + .filter(|ip| ip.len() > 0) .map(|ip| { ip.parse() .expect("given allowed ip address is not valid ip") }) .collect::>(); + let repo_dir = sub_matches + .get_one::("repo_dir") + .map(|p| p.as_str()) + .unwrap_or("~/.monitor/repos") + .to_string() + .replace("~", env::var("HOME").unwrap().as_str()); + let config = PeripheryConfig { port, stats_polling_rate, @@ -344,7 +353,10 @@ pub fn start_periphery_daemon(sub_matches: &ArgMatches) { if install_output.success() { println!("\ninstallation finished, starting monitor periphery daemon\n") } else { - eprintln!("\nāŒ there was some {} during periphery installation āŒ\n", "error".red()); + eprintln!( + "\nāŒ there was some {} during periphery installation āŒ\n", + "error".red() + ); return; } diff --git a/cli/src/main.rs b/cli/src/main.rs index 4e6e6c028..15f02baaf 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -22,6 +22,10 @@ fn cli() -> Command { .subcommand( Command::new("gen_config") .about("generate a core config file") + .arg( + arg!(--host "the host to use with oauth redirect url, whatever host the user hits to access monitor. eg 'https://monitor.mogh.tech'") + .required(true) + ) .arg( arg!(--path "sets path of generated config file. default is '~/.monitor/core.config.toml'") .required(false) @@ -110,10 +114,6 @@ fn cli() -> Command { .subcommand( Command::new("gen_config") .about("generate a periphery config file") - .arg( - arg!(--host "the host to use with oauth redirect url, whatever host the user hits to access monitor. eg 'https://monitor.mogh.tech'") - .required(true) - ) .arg( arg!(--path "sets path of generated config file. default is '~/.monitor/periphery.config.toml'") .required(false) @@ -128,6 +128,10 @@ fn cli() -> Command { ) .arg( arg!(--allowed_ips "used to only accept requests from known ips. give ips as comma seperated list, like '--allowed_ips 127.0.0.1,10.20.30.43'. default is empty, which will not block any ip.") + .required(false) + ) + .arg( + arg!(--repo_dir "if running in container, this should be '/repos'. default is ~/.monitor/repos").required(false) ) ) .subcommand(