From 4d7a6dd66179fd6250c5b883ffe29b873bb113af Mon Sep 17 00:00:00 2001 From: rustdesk Date: Thu, 27 Jul 2023 16:49:19 +0800 Subject: [PATCH] install-service/uninstall-service --- src/core_main.rs | 7 +++++++ src/platform/macos.rs | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/core_main.rs b/src/core_main.rs index cd972b25d..47e7e7834 100644 --- a/src/core_main.rs +++ b/src/core_main.rs @@ -208,6 +208,13 @@ pub fn core_main() -> Option> { crate::tray::start_tray(); } return None; + } else if args[0] == "--install-service" { + log::info!("start --install-service"); + crate::platform::install_service(); + return None; + } else if args[0] == "--uninstall-service" { + log::info!("start --uninstall-service"); + crate::platform::uninstall_service(false); } else if args[0] == "--service" { log::info!("start --service"); crate::start_os_service(); diff --git a/src/platform/macos.rs b/src/platform/macos.rs index f00435907..02fc828a6 100644 --- a/src/platform/macos.rs +++ b/src/platform/macos.rs @@ -132,6 +132,10 @@ pub fn is_can_screen_recording(prompt: bool) -> bool { can_record_screen } +pub fn install_service() -> bool { + is_installed_daemon(false) +} + pub fn is_installed_daemon(prompt: bool) -> bool { let daemon = format!("{}_service.plist", crate::get_full_name()); let agent = format!("{}_server.plist", crate::get_full_name());