From c136e452db4799d5f1bd4995129448324e8273d0 Mon Sep 17 00:00:00 2001 From: Akizon77 Date: Fri, 16 May 2025 21:16:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=BC=BA=E5=8D=B8=E8=BD=BD?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E7=A1=AE=E4=BF=9D=E6=97=A7=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=92=8C=E4=BA=8C=E8=BF=9B=E5=88=B6=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=A2=AB=E6=AD=A3=E7=A1=AE=E7=A7=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index ab7a895..5fdc2ec 100644 --- a/install.sh +++ b/install.sh @@ -9,6 +9,34 @@ if [ "$EUID" -ne 0 ]; then exit 1 fi +# Function to uninstall the previous installation +uninstall_previous() { + echo "Checking for previous installation..." + + # Stop and disable service if it exists + if command -v systemctl >/dev/null 2>&1 && systemctl list-unit-files | grep -q "${service_name}.service"; then + echo "Stopping and disabling existing systemd service..." + systemctl stop ${service_name}.service + systemctl disable ${service_name}.service + rm -f "/etc/systemd/system/${service_name}.service" + systemctl daemon-reload + elif command -v rc-service >/dev/null 2>&1 && [ -f "/etc/init.d/${service_name}" ]; then + echo "Stopping and disabling existing OpenRC service..." + rc-service ${service_name} stop + rc-update del ${service_name} default + rm -f "/etc/init.d/${service_name}" + fi + + # Remove old binary if it exists + if [ -f "$komari_agent_path" ]; then + echo "Removing old binary..." + rm -f "$komari_agent_path" + fi +} + +# Uninstall previous installation +uninstall_previous + install_dependencies() { echo "Checking and installing dependencies..." @@ -107,7 +135,7 @@ After=network.target Type=simple ExecStart=${komari_agent_path} ${komari_args} WorkingDirectory=${target_dir} -Restart=on-failure +Restart=always User=root [Install]