Skip to content

Commit

Permalink
feat(antctl): use custom bootstrap cache path for root users
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandSherwin committed Dec 7, 2024
1 parent f548a71 commit 7424883
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ant-node-manager/src/cmd/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ pub async fn add(
config::get_service_data_dir_path(data_dir_path, service_user.clone())?;
let service_log_dir_path =
config::get_service_log_dir_path(ReleaseType::AntNode, log_dir_path, service_user.clone())?;
let bootstrap_cache_dir = if let Some(user) = &service_user {
Some(config::get_bootstrap_cache_owner_path(user)?)
} else {
None
};

let mut node_registry = NodeRegistry::load(&config::get_node_registry_path()?)?;
let release_repo = <dyn AntReleaseRepoActions>::default_config();
Expand All @@ -105,6 +110,7 @@ pub async fn add(
debug!("Parsing peers from PeersArgs");

peers_args.addrs.extend(PeersArgs::read_addr_from_env());
peers_args.bootstrap_cache_dir = bootstrap_cache_dir;

let options = AddNodeServiceOptions {
auto_restart,
Expand Down
16 changes: 16 additions & 0 deletions ant-node-manager/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,22 @@ pub fn get_service_data_dir_path(
Ok(path)
}

/// Get the bootstrap cache owner path
#[cfg(unix)]
pub fn get_bootstrap_cache_owner_path(owner: &str) -> Result<PathBuf> {
let path = PathBuf::from("/var/antctl/bootstrap_cache");

create_owned_dir(path.clone(), owner)?;
Ok(path)
}

#[cfg(windows)]
pub fn get_bootstrap_cache_owner_path(_owner: &str) -> Result<PathBuf> {
let path = PathBuf::from("C:\\ProgramData\\antctl\\bootstrap_cache");
std::fs::create_dir_all(&path)?;
Ok(path)
}

/// Get the logging directory for the service.
///
/// It's a little counter-intuitive, but the owner will be `None` in the case of a user-mode
Expand Down

0 comments on commit 7424883

Please sign in to comment.