kanit

Toy init system
Log | Files | Refs | README | LICENSE

disable.rs (480B)


      1 use std::fs::remove_file;
      2 use std::path::PathBuf;
      3 
      4 use kanit_common::constants;
      5 use kanit_common::error::{Context, Result};
      6 
      7 use crate::flags::Disable;
      8 
      9 pub fn disable(opts: Disable) -> Result<()> {
     10     let unit = PathBuf::from(constants::KAN_ENABLED_DIR)
     11         .join(opts.runlevel.unwrap_or_else(|| String::from("default")))
     12         .join(opts.unit);
     13 
     14     remove_file(&unit).context("failed to disable unit")?;
     15 
     16     println!("delete {}", unit.to_string_lossy());
     17 
     18     Ok(())
     19 }