add IPC directory to rpm and deb packaging

add config verify step after all command line options have been processed

closes #366
This commit is contained in:
Christien Rioux 2024-04-28 17:31:04 -04:00
parent b0ccd04a9f
commit 49e6eace8e
4 changed files with 34 additions and 11 deletions

View File

@ -9,12 +9,14 @@ adduser --system --group veilid &>/dev/null || true
mkdir -p /var/db/veilid-server/protected_store
mkdir -p /var/db/veilid-server/table_store
mkdir -p /var/db/veilid-server/block_store
mkdir -p /var/db/veilid-server/ipc
# Set permissions
chown -R veilid:veilid /var/db/veilid-server
chmod 0750 /var/db/veilid-server/protected_store
chmod 0750 /var/db/veilid-server/table_store
chmod 0750 /var/db/veilid-server/block_store
chmod 0750 /var/db/veilid-server/ipc
chmod 0750 /var/db/veilid-server
chmod 755 /usr/bin/veilid-server

View File

@ -33,10 +33,12 @@ adduser --system -U veilid &>/dev/null || true
mkdir -p /var/db/veilid-server/protected_store
mkdir -p /var/db/veilid-server/table_store
mkdir -p /var/db/veilid-server/block_store
mkdir -p /var/db/veilid-server/ipc
chown -R veilid:veilid /var/db/veilid-server
chmod 0750 /var/db/veilid-server/protected_store
chmod 0750 /var/db/veilid-server/table_store
chmod 0750 /var/db/veilid-server/block_store
chmod 0750 /var/db/veilid-server/ipc
chmod 0750 /var/db/veilid-server
chmod 755 /usr/bin/veilid-server
@ -57,3 +59,5 @@ fi
%changelog
* Sun Jul 2 2023 TC <tc@veilid.org>
- experimental RPM building
* Sun Apr 28 2024 Christien Rioux <chris@veilid.org>
- add ipc directory to installation

View File

@ -290,6 +290,9 @@ fn main() -> EyreResult<()> {
.apply_subnode_index()
.wrap_err("failed to apply subnode index")?;
// --- Verify Config ---
settings.verify()?;
// --- Dump Config ---
if args.dump_config {
return serde_yaml::to_writer(std::io::stdout(), &*settings.read())

View File

@ -736,6 +736,25 @@ impl Settings {
inner: Arc::new(RwLock::new(inner)),
})
}
pub fn verify(&self) -> EyreResult<()> {
let inner = self.inner.read();
cfg_if! {
if #[cfg(windows)] {
// no ipc setup for windows
} else {
if inner.client_api.ipc_enabled
&& !Self::get_or_create_private_directory(&inner.client_api.ipc_directory, true)
{
bail!("unable to create default IPC directory");
}
}
}
Ok(())
}
pub fn read(&self) -> RwLockReadGuard<SettingsInner> {
self.inner.read()
}
@ -849,13 +868,13 @@ impl Settings {
}
#[allow(dead_code)]
fn get_or_create_default_directory(subpath: &str) -> PathBuf {
fn get_default_directory(subpath: &str) -> PathBuf {
#[cfg(unix)]
{
let globalpath = PathBuf::from("/var/db/veilid-server").join(subpath);
let globalpath = PathBuf::from("/var/db/veilid-server");
if Self::get_or_create_private_directory(&globalpath, true) {
return globalpath;
if globalpath.exists() {
return globalpath.join(subpath);
}
}
@ -865,12 +884,7 @@ impl Settings {
PathBuf::from("./")
};
ts_path.push(subpath);
if Self::get_or_create_private_directory(&ts_path, true) {
return ts_path;
}
panic!("Failed to create private directory for '{}'", subpath);
ts_path
}
pub fn get_default_ipc_directory() -> PathBuf {
@ -878,7 +892,7 @@ impl Settings {
if #[cfg(windows)] {
PathBuf::from(r"\\.\PIPE\veilid-server")
} else {
Self::get_or_create_default_directory("ipc")
Self::get_default_directory("ipc")
}
}
}