Skip to content

Commit 03bb375

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 788e6d9 commit 03bb375

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;
67
use std::{cmp, env, fs, thread};
78

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

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

0 commit comments

Comments
 (0)