feat(installer): implement Phase 2 — uo-link install and service #5

Merged
whitlocktech merged 2 commits from feat/phase2-sidecar-service into edge 2026-08-04 21:02:02 +00:00
Showing only changes of commit 7bfb033957 - Show all commits

View File

@@ -31,7 +31,9 @@ use std::path::{Path, PathBuf};
use anyhow::{Context, Result};
use crate::util::{command_line, run, run_ok};
// `command_line` is used only by the Windows registration path, so it is qualified at its call
// site rather than imported here — an unconditional import is an unused-import error on Linux.
use crate::util::{run, run_ok};
/// The unit file name, and the systemd service name with its suffix.
pub const SYSTEMD_UNIT: &str = "runicgateway-link.service";
@@ -149,7 +151,7 @@ fn prepare_platform() -> Prepared {
/// Creates the dedicated system user if it is not already there. Returns whether it created it.
#[cfg(unix)]
fn ensure_user(user: &str) -> Result<bool> {
if run("id", &["-u", user]).map(|o| o.status.success()) == Ok(true) {
if run("id", &["-u", user]).is_ok_and(|o| o.status.success()) {
return Ok(false);
}
// `useradd` is the near-universal spelling; `adduser` is the fallback for Debian's wrapper and
@@ -373,7 +375,7 @@ fn register_windows(binary: &Path, config: &Path, restart: bool) -> Result<Outco
anyhow::bail!(
"`{}` failed with exit code {}. Check the Windows event log; a service that exits \
immediately usually cannot read its config: {}",
command_line("sc.exe", &["start", WINDOWS_SERVICE]),
crate::util::command_line("sc.exe", &["start", WINDOWS_SERVICE]),
start.status.code().unwrap_or(-1),
config.display()
);
@@ -798,6 +800,16 @@ mod tests {
// The write grant belongs to the database directory, which is not always the config's.
assert!(steps.contains("/var/lib/runicgateway'"), "{steps}");
}
#[cfg(not(windows))]
{
assert!(steps.contains("systemctl enable --now"), "{steps}");
assert!(
steps.contains("ExecStart=/usr/bin/runicgateway-link"),
"{steps}"
);
// Non-systemd hosts get the requirements, not just a unit they cannot use.
assert!(steps.contains("without systemd"), "{steps}");
}
}
#[test]
@@ -826,16 +838,6 @@ mod tests {
assert_eq!(protected, unprotected);
assert!(protected.contains("chown runicgateway"), "{protected}");
}
#[cfg(not(windows))]
{
assert!(steps.contains("systemctl enable --now"), "{steps}");
assert!(
steps.contains("ExecStart=/usr/bin/runicgateway-link"),
"{steps}"
);
// Non-systemd hosts get the requirements, not just a unit they cannot use.
assert!(steps.contains("without systemd"), "{steps}");
}
}
#[test]