mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
fix config sync when uninstall service
This commit is contained in:
@@ -1119,13 +1119,25 @@ pub fn run_me_with(secs: u32) {
|
||||
.ok();
|
||||
}
|
||||
|
||||
fn switch_service(stop: bool) -> String {
|
||||
let home = std::env::var("HOME").unwrap_or_default();
|
||||
Config::set_option("stop-service".into(), if stop { "Y" } else { "" }.into());
|
||||
if home != "/root" && !Config::get().is_empty() {
|
||||
format!("cp -f {home}/.config/rustdesk/RustDesk.toml /root/.config/rustdesk/; cp -f {home}/.config/rustdesk/RustDesk2.toml /root/.config/rustdesk/;")
|
||||
} else {
|
||||
"".to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn uninstall_service(show_new_window: bool) -> bool {
|
||||
if !has_cmd("systemctl") {
|
||||
return false;
|
||||
}
|
||||
log::info!("Uninstalling service...");
|
||||
Config::set_option("stop-service".into(), "Y".into());
|
||||
if !run_cmds_pkexec("systemctl disable rustdesk; systemctl stop rustdesk") {
|
||||
let cp = switch_service(true);
|
||||
if !run_cmds_pkexec(&format!(
|
||||
"{cp} systemctl disable rustdesk; systemctl stop rustdesk"
|
||||
)) {
|
||||
Config::set_option("stop-service".into(), "".into());
|
||||
return true;
|
||||
}
|
||||
@@ -1140,13 +1152,7 @@ pub fn install_service() -> bool {
|
||||
return false;
|
||||
}
|
||||
log::info!("Installing service...");
|
||||
let home = std::env::var("HOME").unwrap_or_default();
|
||||
let cp = if home != "/root" && !Config::get().is_empty() {
|
||||
format!("cp -f {home}/.config/rustdesk/RustDesk.toml /root/.config/rustdesk/; cp -f {home}/.config/rustdesk/RustDesk2.toml /root/.config/rustdesk/;")
|
||||
} else {
|
||||
"".to_owned()
|
||||
};
|
||||
Config::set_option("stop-service".into(), "".into());
|
||||
let cp = switch_service(false);
|
||||
if !run_cmds_pkexec(&format!(
|
||||
"{cp}systemctl enable rustdesk; systemctl start rustdesk"
|
||||
)) {
|
||||
|
||||
Reference in New Issue
Block a user