More detailed output when activating.
This commit is contained in:
parent
f784f06107
commit
c83afe6788
1 changed files with 14 additions and 5 deletions
19
src/main.rs
19
src/main.rs
|
|
@ -69,9 +69,8 @@ impl ServiceConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: error message if not euid 0
|
|
||||||
fn activate(store_path: StorePath) -> Result<(), Box<dyn Error>> {
|
fn activate(store_path: StorePath) -> Result<(), Box<dyn Error>> {
|
||||||
if nix::unistd::Uid::is_root(nix::unistd::getuid()) {
|
if !nix::unistd::Uid::is_root(nix::unistd::getuid()) {
|
||||||
return Err("We need root permissions.".into());
|
return Err("We need root permissions.".into());
|
||||||
}
|
}
|
||||||
println!("Activating service-manager profile: {}", store_path);
|
println!("Activating service-manager profile: {}", store_path);
|
||||||
|
|
@ -89,6 +88,12 @@ fn activate(store_path: StorePath) -> Result<(), Box<dyn Error>> {
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
start_services(&services);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn start_services(services: &[ServiceConfig]) {
|
||||||
if process::Command::new("systemctl")
|
if process::Command::new("systemctl")
|
||||||
.arg("daemon-reload")
|
.arg("daemon-reload")
|
||||||
.output()
|
.output()
|
||||||
|
|
@ -97,17 +102,21 @@ fn activate(store_path: StorePath) -> Result<(), Box<dyn Error>> {
|
||||||
.success()
|
.success()
|
||||||
{
|
{
|
||||||
services.iter().for_each(|service| {
|
services.iter().for_each(|service| {
|
||||||
print_out_and_err(
|
println!("Starting service {} ...", service.name);
|
||||||
|
let output = print_out_and_err(
|
||||||
process::Command::new("systemctl")
|
process::Command::new("systemctl")
|
||||||
.arg("start")
|
.arg("start")
|
||||||
.arg(&service.name)
|
.arg(&service.name)
|
||||||
.output()
|
.output()
|
||||||
.expect("Unable to run systemctl"),
|
.expect("Unable to run systemctl"),
|
||||||
);
|
);
|
||||||
|
if output.status.success() {
|
||||||
|
println!("Started service {}", service.name);
|
||||||
|
} else {
|
||||||
|
println!("Error starting service {}", service.name);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate(flake_uri: &str) -> Result<(), Box<dyn Error>> {
|
fn generate(flake_uri: &str) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue