diff --git a/install.sh b/install.sh index 73b4565a..18195257 100644 --- a/install.sh +++ b/install.sh @@ -18,12 +18,11 @@ CONFIG_BASE_FILE="$CONFIG_MERGE_DIR/10-base.json" CONFIG_OUTBOUNDS_FILE="$CONFIG_MERGE_DIR/20-outbounds.json" WORK_DIR="/var/lib/sing-box" BINARY_PATH="/usr/local/bin/sing-box" -SERVICE_NAME="ganclient" +SERVICE_NAME="singbox" SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service" -LEGACY_SERVICE_NAME="sing-box" -LEGACY_SERVICE_FILE="/etc/systemd/system/${LEGACY_SERVICE_NAME}.service" +LEGACY_SERVICE_NAMES=("ganclient" "sing-box") -echo -e "${GREEN}Welcome to ganclient Installation Script${NC}" +echo -e "${GREEN}Welcome to singbox Installation Script${NC}" # Check root if [[ $EUID -ne 0 ]]; then @@ -135,17 +134,23 @@ install_go build_sing_box cleanup_legacy_service() { - echo -e "${YELLOW}Cleaning up legacy sing-box service if present...${NC}" - if systemctl list-unit-files | grep -q "^${LEGACY_SERVICE_NAME}\.service"; then - systemctl stop "${LEGACY_SERVICE_NAME}" 2>/dev/null || true - systemctl disable "${LEGACY_SERVICE_NAME}" 2>/dev/null || true - fi - if [[ -f "$LEGACY_SERVICE_FILE" ]]; then - rm -f "$LEGACY_SERVICE_FILE" - fi - if [[ -L "/etc/systemd/system/multi-user.target.wants/${LEGACY_SERVICE_NAME}.service" ]]; then - rm -f "/etc/systemd/system/multi-user.target.wants/${LEGACY_SERVICE_NAME}.service" - fi + echo -e "${YELLOW}Cleaning up legacy services if present...${NC}" + for legacy_service_name in "${LEGACY_SERVICE_NAMES[@]}"; do + if [[ "$legacy_service_name" == "$SERVICE_NAME" ]]; then + continue + fi + legacy_service_file="/etc/systemd/system/${legacy_service_name}.service" + if systemctl list-unit-files | grep -q "^${legacy_service_name}\.service"; then + systemctl stop "${legacy_service_name}" 2>/dev/null || true + systemctl disable "${legacy_service_name}" 2>/dev/null || true + fi + if [[ -f "$legacy_service_file" ]]; then + rm -f "$legacy_service_file" + fi + if [[ -L "/etc/systemd/system/multi-user.target.wants/${legacy_service_name}.service" ]]; then + rm -f "/etc/systemd/system/multi-user.target.wants/${legacy_service_name}.service" + fi + done } cleanup_legacy_service @@ -358,7 +363,7 @@ fi echo -e "${YELLOW}Creating systemd service...${NC}" cat > "$SERVICE_FILE" <