mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 06:23:44 +08:00
fix: try to fix service not started on linux
This commit is contained in:
parent
89ce497431
commit
a013fe663c
@ -89,20 +89,18 @@ pub async fn reinstall_service() -> Result<()> {
|
|||||||
let install_shell: String = install_path.to_string_lossy().replace(" ", "\\ ");
|
let install_shell: String = install_path.to_string_lossy().replace(" ", "\\ ");
|
||||||
let uninstall_shell: String = uninstall_path.to_string_lossy().replace(" ", "\\ ");
|
let uninstall_shell: String = uninstall_path.to_string_lossy().replace(" ", "\\ ");
|
||||||
|
|
||||||
let elevator = crate::utils::help::linux_elevator();
|
|
||||||
let _ = match get_effective_uid() {
|
let _ = match get_effective_uid() {
|
||||||
0 => StdCommand::new(uninstall_path).status()?,
|
0 => StdCommand::new(uninstall_path).status()?,
|
||||||
_ => StdCommand::new(elevator)
|
_ => StdCommand::new("sudo")
|
||||||
.arg("sh")
|
.arg("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(uninstall_shell)
|
.arg(uninstall_shell)
|
||||||
.status()?,
|
.status()?,
|
||||||
};
|
};
|
||||||
|
|
||||||
let elevator = crate::utils::help::linux_elevator();
|
|
||||||
let status = match get_effective_uid() {
|
let status = match get_effective_uid() {
|
||||||
0 => StdCommand::new(install_shell).status()?,
|
0 => StdCommand::new(install_shell).status()?,
|
||||||
_ => StdCommand::new(elevator)
|
_ => StdCommand::new("sudo")
|
||||||
.arg("sh")
|
.arg("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(install_shell)
|
.arg(install_shell)
|
||||||
|
@ -105,21 +105,6 @@ pub fn open_file(app: tauri::AppHandle, path: PathBuf) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
pub fn linux_elevator() -> &'static str {
|
|
||||||
use std::process::Command;
|
|
||||||
match Command::new("which").arg("pkexec").output() {
|
|
||||||
Ok(output) => {
|
|
||||||
if output.stdout.is_empty() {
|
|
||||||
"sudo"
|
|
||||||
} else {
|
|
||||||
"pkexec"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(_) => "sudo",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! error {
|
macro_rules! error {
|
||||||
($result: expr) => {
|
($result: expr) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user