Add a deactivate subcommand.
This commit is contained in:
parent
e2f386c21e
commit
e28ba15456
4 changed files with 47 additions and 0 deletions
|
|
@ -50,6 +50,14 @@ pub fn activate(store_path: StorePath, ephemeral: bool) -> Result<()> {
|
|||
.into_iter()
|
||||
.try_for_each(|(name, entry)| create_etc_link(&name, &entry, &etc_dir))?;
|
||||
|
||||
// TODO register the crated files (including .system-manager-static) in a
|
||||
// state file, and clean up old files from the previous generation
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// TODO we need to record in a state file which files we created and then remove them
|
||||
pub fn deactivate() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,29 @@ pub fn activate(store_path: StorePath, ephemeral: bool) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn deactivate() -> Result<()> {
|
||||
let old_linked_services = read_linked_services()?;
|
||||
log::debug!("{:?}", old_linked_services);
|
||||
|
||||
serialise_linked_services(&HashMap::new())?;
|
||||
|
||||
let service_manager = systemd::ServiceManager::new_session()?;
|
||||
let timeout = Some(Duration::from_secs(30));
|
||||
|
||||
// We need to do this before we reload the systemd daemon, so that the daemon
|
||||
// still knows about these units.
|
||||
stop_services(&service_manager, &old_linked_services, &timeout)?;
|
||||
unlink_services(&old_linked_services)?;
|
||||
|
||||
// We added all new services and removed old ones, so let's reload the units
|
||||
// to tell systemd about them.
|
||||
log::info!("Reloading the systemd daemon...");
|
||||
service_manager.daemon_reload()?;
|
||||
|
||||
log::info!("Done");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn unlink_services(services: &LinkedServices) -> Result<()> {
|
||||
services
|
||||
.values()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue