Skip to content

Commit b260d93

Browse files
committed
muvm-guest: Add support for running as muvm-remote and muvm-configure-network
To better support running under a custom service manager (e.g. systemd), allow running individual functions of the guest binary when called with distinct binary names. Signed-off-by: Val Packett <[email protected]>
1 parent 80f516f commit b260d93

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

crates/muvm/src/guest/bin/muvm-guest.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::fs::File;
22
use std::io::Read;
33
use std::os::fd::AsFd;
44
use std::panic::catch_unwind;
5+
use std::path::PathBuf;
56
use std::process::{Command, ExitCode};
67
use std::{cmp, env, fs, thread};
78

@@ -27,6 +28,19 @@ const KRUN_CONFIG: &str = "KRUN_CONFIG";
2728
fn main() -> Result<ExitCode> {
2829
env_logger::init();
2930

31+
let binary_path = env::args().next().context("arg0")?;
32+
let bb = binary_path.split('/').next_back().context("arg0 split")?;
33+
match bb {
34+
"muvm-configure-network" => return configure_network(),
35+
"muvm-remote" => {
36+
let rt = tokio::runtime::Runtime::new().unwrap();
37+
let mut command_args = env::args().skip(1);
38+
let command = command_args.next().context("command name")?;
39+
return rt.block_on(server_main(PathBuf::from(command), command_args.collect()));
40+
},
41+
_ => { /* continue with all-in-one mode */ },
42+
}
43+
3044
if let Ok(val) = env::var("__X11BRIDGE_DEBUG") {
3145
start_x11bridge(val.parse()?);
3246
return Ok(ExitCode::SUCCESS);

0 commit comments

Comments
 (0)