修改名称

This commit is contained in:
CN-JS-HuiBai
2026-04-15 14:43:23 +08:00
parent 1bf3299302
commit 27ed827903

View File

@@ -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" <<EOF
[Unit]
Description=sing-box service
Description=ganclient service
After=network.target nss-lookup.target
[Service]
@@ -286,9 +305,9 @@ EOF
# Reload and Start
systemctl daemon-reload
systemctl enable sing-box
systemctl restart sing-box
systemctl enable "$SERVICE_NAME"
systemctl restart "$SERVICE_NAME"
echo -e "${GREEN}Service installed and started successfully.${NC}"
echo -e "${GREEN}Check status with: systemctl status sing-box${NC}"
echo -e "${GREEN}View logs with: journalctl -u sing-box -f${NC}"
echo -e "${GREEN}Check status with: systemctl status ${SERVICE_NAME}${NC}"
echo -e "${GREEN}View logs with: journalctl -u ${SERVICE_NAME} -f${NC}"