修改名称
This commit is contained in:
33
install.sh
33
install.sh
@@ -15,9 +15,12 @@ NC='\033[0m'
|
|||||||
CONFIG_DIR="/etc/sing-box"
|
CONFIG_DIR="/etc/sing-box"
|
||||||
CONFIG_FILE="$CONFIG_DIR/config.json"
|
CONFIG_FILE="$CONFIG_DIR/config.json"
|
||||||
BINARY_PATH="/usr/local/bin/sing-box"
|
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
|
# Check root
|
||||||
if [[ $EUID -ne 0 ]]; then
|
if [[ $EUID -ne 0 ]]; then
|
||||||
@@ -113,6 +116,22 @@ build_sing_box() {
|
|||||||
install_go
|
install_go
|
||||||
build_sing_box
|
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
|
# Load .env if exists
|
||||||
if [[ -f ".env" ]]; then
|
if [[ -f ".env" ]]; then
|
||||||
echo -e "${YELLOW}Loading configuration from .env...${NC}"
|
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}"
|
echo -e "${YELLOW}Creating systemd service...${NC}"
|
||||||
cat > "$SERVICE_FILE" <<EOF
|
cat > "$SERVICE_FILE" <<EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=sing-box service
|
Description=ganclient service
|
||||||
After=network.target nss-lookup.target
|
After=network.target nss-lookup.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
@@ -286,9 +305,9 @@ EOF
|
|||||||
|
|
||||||
# Reload and Start
|
# Reload and Start
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable sing-box
|
systemctl enable "$SERVICE_NAME"
|
||||||
systemctl restart sing-box
|
systemctl restart "$SERVICE_NAME"
|
||||||
|
|
||||||
echo -e "${GREEN}Service installed and started successfully.${NC}"
|
echo -e "${GREEN}Service installed and started successfully.${NC}"
|
||||||
echo -e "${GREEN}Check status with: systemctl status sing-box${NC}"
|
echo -e "${GREEN}Check status with: systemctl status ${SERVICE_NAME}${NC}"
|
||||||
echo -e "${GREEN}View logs with: journalctl -u sing-box -f${NC}"
|
echo -e "${GREEN}View logs with: journalctl -u ${SERVICE_NAME} -f${NC}"
|
||||||
|
|||||||
Reference in New Issue
Block a user