fix: installation service error

This commit is contained in:
huzibaca 2024-10-11 00:59:34 +08:00
parent 25e25c2285
commit c604ae38dd
No known key found for this signature in database
GPG Key ID: D4364EE4851DC302

View File

@ -49,20 +49,13 @@ pub async fn reinstall_service() -> Result<()> {
let token = Token::with_current_process()?; let token = Token::with_current_process()?;
let level = token.privilege_level()?; let level = token.privilege_level()?;
let status = match level { let _ = match level {
PrivilegeLevel::NotPrivileged => RunasCommand::new(uninstall_path).show(false).status()?, PrivilegeLevel::NotPrivileged => RunasCommand::new(uninstall_path).show(false).status()?,
_ => StdCommand::new(uninstall_path) _ => StdCommand::new(uninstall_path)
.creation_flags(0x08000000) .creation_flags(0x08000000)
.status()?, .status()?,
}; };
if !status.success() {
bail!(
"failed to uninstall service with status {}",
status.code().unwrap()
);
}
let status = match level { let status = match level {
PrivilegeLevel::NotPrivileged => RunasCommand::new(install_path).show(false).status()?, PrivilegeLevel::NotPrivileged => RunasCommand::new(install_path).show(false).status()?,
_ => StdCommand::new(install_path) _ => StdCommand::new(install_path)
@ -97,7 +90,7 @@ pub async fn reinstall_service() -> Result<()> {
} }
let elevator = crate::utils::help::linux_elevator(); let elevator = crate::utils::help::linux_elevator();
let status = match get_effective_uid() { let _ = match get_effective_uid() {
0 => StdCommand::new(uninstaller_path).status()?, 0 => StdCommand::new(uninstaller_path).status()?,
_ => StdCommand::new(elevator) _ => StdCommand::new(elevator)
.arg("sh") .arg("sh")
@ -106,13 +99,6 @@ pub async fn reinstall_service() -> Result<()> {
.status()?, .status()?,
}; };
if !status.success() {
bail!(
"failed to install service with status {}",
status.code().unwrap()
);
}
let elevator = crate::utils::help::linux_elevator(); let elevator = crate::utils::help::linux_elevator();
let status = match get_effective_uid() { let status = match get_effective_uid() {
0 => StdCommand::new(installer_path).status()?, 0 => StdCommand::new(installer_path).status()?,