修改服务名

This commit is contained in:
CN-JS-HuiBai
2026-04-15 19:45:50 +08:00
parent 13cbccafcb
commit 33671364c1

View File

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