init: Allow init to register the scheme for a daemon

Unfortunately the scheme still has to be created by the daemon due to a
kernel bug, but once that is fixed, it would allow delayed spawning of
scheme daemons.
This commit is contained in:
bjorn3
2026-02-18 22:29:56 +01:00
parent 7dad7af1f0
commit 7ebeceb41d
16 changed files with 190 additions and 74 deletions
+13
View File
@@ -124,6 +124,19 @@ fn run_command(cmd: Command, config: &InitConfig) {
daemon::Daemon::spawn(command);
}
Command::Scheme(scheme, cmd, args) => {
if config.skip_cmd.contains(&cmd) {
eprintln!("init: skipping '{} {}'", cmd, args.join(" "));
return;
}
let mut command = process::Command::new(&cmd);
for arg in args {
command.arg(arg);
}
daemon::SchemeDaemon::spawn(command, &scheme);
}
Command::Regular(cmd, args) => {
let mut command = process::Command::new(cmd.clone());
for arg in args {
+11
View File
@@ -37,6 +37,7 @@ pub enum Command {
// Service
Nowait(String, Vec<String>),
Notify(String, Vec<String>),
Scheme(String, String, Vec<String>),
Regular(String, Vec<String>),
// Modify env
@@ -110,6 +111,16 @@ impl Command {
Ok(Command::Notify(cmd, args.collect()))
}
"scheme" => {
let Some(scheme) = args.next() else {
return Err("init: failed to run scheme: no argument".to_owned());
};
let Some(cmd) = args.next() else {
return Err("init: failed to run scheme: missing command".to_owned());
};
Ok(Command::Scheme(scheme, cmd, args.collect()))
}
_ => Ok(Command::Regular(cmd, args.collect())),
}
}