From 27ed827903a057ccbd710048d23f50002e27077e Mon Sep 17 00:00:00 2001 From: CN-JS-HuiBai Date: Wed, 15 Apr 2026 14:43:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 14b3dac2..e3dbcc38 100644 --- a/install.sh +++ b/install.sh @@ -15,9 +15,12 @@ NC='\033[0m' CONFIG_DIR="/etc/sing-box" CONFIG_FILE="$CONFIG_DIR/config.json" BINARY_PATH="/usr/local/bin/sing-box" -SERVICE_FILE="/etc/systemd/system/sing-box.service" +SERVICE_NAME="ganclient" +SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service" +LEGACY_SERVICE_NAME="sing-box" +LEGACY_SERVICE_FILE="/etc/systemd/system/${LEGACY_SERVICE_NAME}.service" -echo -e "${GREEN}Welcome to sing-box Xboard Installation Script${NC}" +echo -e "${GREEN}Welcome to ganclient Installation Script${NC}" # Check root if [[ $EUID -ne 0 ]]; then @@ -113,6 +116,22 @@ build_sing_box() { 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 +} + +cleanup_legacy_service + # Load .env if exists if [[ -f ".env" ]]; then echo -e "${YELLOW}Loading configuration from .env...${NC}" @@ -269,7 +288,7 @@ echo -e "${GREEN}Configuration written to $CONFIG_FILE${NC}" echo -e "${YELLOW}Creating systemd service...${NC}" cat > "$SERVICE_FILE" <