diff --git a/init.d/40_hwd.service b/init.d/40_hwd.service index c90650b5f8..cba12dde61 100644 --- a/init.d/40_hwd.service +++ b/init.d/40_hwd.service @@ -4,8 +4,5 @@ requires_weak = ["10_inputd.service", "10_lived.service", "20_graphics.target"] [service] cmd = "hwd" -inherit_envs = [ - "RSDP_ADDR", - "RSDP_SIZE", -] +inherit_envs = ["RSDP_ADDR", "RSDP_SIZE"] type = "notify" diff --git a/init.d/50_rootfs b/init.d/50_rootfs deleted file mode 100644 index 550cd2b3ca..0000000000 --- a/init.d/50_rootfs +++ /dev/null @@ -1,2 +0,0 @@ -requires_weak 40_drivers.target -REDOXFS_PASSWORD_ADDR=$ REDOXFS_PASSWORD_SIZE=$ redoxfs --uuid $REDOXFS_UUID file $REDOXFS_BLOCK diff --git a/init.d/50_rootfs.service b/init.d/50_rootfs.service new file mode 100644 index 0000000000..c2d8e47713 --- /dev/null +++ b/init.d/50_rootfs.service @@ -0,0 +1,9 @@ +[unit] +description = "Rootfs" +requires_weak = ["40_drivers.target"] + +[service] +cmd = "redoxfs" +args = ["--uuid" ,"$REDOXFS_UUID", "file", "$REDOXFS_BLOCK"] +inherit_envs = ["REDOXFS_PASSWORD_ADDR", "REDOXFS_PASSWORD_SIZE"] +type = "oneshot" diff --git a/init.d/90_exit_initfs.switchroot b/init.d/90_exit_initfs.switchroot index f91243b3c5..f4357eddbd 100644 --- a/init.d/90_exit_initfs.switchroot +++ b/init.d/90_exit_initfs.switchroot @@ -1,5 +1,5 @@ [unit] -requires_weak = ["50_rootfs"] +requires_weak = ["50_rootfs.service"] [switchroot] prefix = "/usr" diff --git a/init/src/script.rs b/init/src/script.rs index f61ff6fbcb..1b233d889b 100644 --- a/init/src/script.rs +++ b/init/src/script.rs @@ -4,7 +4,7 @@ use std::{env, io, iter}; use crate::service::{Service, ServiceType}; use crate::unit::UnitId; -fn subst_env<'a>(arg: &str) -> String { +pub fn subst_env<'a>(arg: &str) -> String { if arg.starts_with('$') { env::var(&arg[1..]).unwrap_or(String::new()) } else { diff --git a/init/src/service.rs b/init/src/service.rs index 0fd8ba7c0d..e0b1e682db 100644 --- a/init/src/service.rs +++ b/init/src/service.rs @@ -5,6 +5,8 @@ use std::process::Command; use serde::Deserialize; +use crate::script::subst_env; + #[derive(Clone, Debug, Deserialize)] #[serde(deny_unknown_fields)] pub struct Service { @@ -32,7 +34,7 @@ pub enum ServiceType { impl Service { pub fn spawn(&self, base_envs: &BTreeMap) { let mut command = Command::new(&self.cmd); - command.args(&self.args); + command.args(self.args.iter().map(|arg| subst_env(arg))); command.env_clear(); for env in &self.inherit_envs { if let Some(value) = env::var_os(env) {