systemd: support systemd.tmpfiles.settings
Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>
This commit is contained in:
parent
a79e02428d
commit
91323fb350
4 changed files with 205 additions and 14 deletions
|
|
@ -82,7 +82,7 @@ pub fn activate(store_path: &StorePath, ephemeral: bool) -> Result<()> {
|
|||
match etc_files::activate(store_path, old_state.file_tree, ephemeral) {
|
||||
Ok(etc_tree) => {
|
||||
log::info!("Activating tmp files...");
|
||||
match tmp_files::activate() {
|
||||
match tmp_files::activate(&etc_tree) {
|
||||
Ok(_) => {
|
||||
log::debug!("Successfully created tmp files");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ impl FileStatus {
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct FileTree {
|
||||
status: FileStatus,
|
||||
path: PathBuf,
|
||||
pub(crate) path: PathBuf,
|
||||
// TODO directories and files are now both represented as a string associated with a nested
|
||||
// map. For files the nested map is simple empty.
|
||||
// We could potentially optimise this.
|
||||
nested: HashMap<String, FileTree>,
|
||||
pub(crate) nested: HashMap<String, FileTree>,
|
||||
}
|
||||
|
||||
impl AsRef<FileTree> for FileTree {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,26 @@
|
|||
use crate::activate;
|
||||
use crate::activate::etc_files::FileTree;
|
||||
|
||||
use super::ActivationResult;
|
||||
use std::process;
|
||||
|
||||
type TmpFilesActivationResult = ActivationResult<()>;
|
||||
|
||||
pub fn activate() -> TmpFilesActivationResult {
|
||||
pub fn activate(etc_tree: &FileTree) -> TmpFilesActivationResult {
|
||||
let conf_files = etc_tree
|
||||
.nested
|
||||
.get("etc")
|
||||
.unwrap()
|
||||
.nested
|
||||
.get("tmpfiles.d")
|
||||
.unwrap()
|
||||
.nested
|
||||
.iter()
|
||||
.map(|(_, node)| node.path.to_string_lossy().to_string())
|
||||
.collect::<Vec<_>>();
|
||||
let mut cmd = process::Command::new("systemd-tmpfiles");
|
||||
cmd.arg("--create")
|
||||
.arg("--remove")
|
||||
.arg("/etc/tmpfiles.d/00-system-manager.conf");
|
||||
cmd.arg("--create").arg("--remove").args(conf_files);
|
||||
log::debug!("running {:#?}", cmd);
|
||||
let output = cmd
|
||||
.stdout(process::Stdio::inherit())
|
||||
.stderr(process::Stdio::inherit())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue