mirror of
https://github.com/fankes/komari-agent.git
synced 2025-10-19 02:59:23 +08:00
fix: 增强卸载功能,确保旧服务和二进制文件被正确移除
This commit is contained in:
30
install.sh
30
install.sh
@@ -9,6 +9,34 @@ if [ "$EUID" -ne 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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() {
|
install_dependencies() {
|
||||||
echo "Checking and installing dependencies..."
|
echo "Checking and installing dependencies..."
|
||||||
|
|
||||||
@@ -107,7 +135,7 @@ After=network.target
|
|||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=${komari_agent_path} ${komari_args}
|
ExecStart=${komari_agent_path} ${komari_args}
|
||||||
WorkingDirectory=${target_dir}
|
WorkingDirectory=${target_dir}
|
||||||
Restart=on-failure
|
Restart=always
|
||||||
User=root
|
User=root
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
Reference in New Issue
Block a user