guanghulab/_deploy/maomao-deploy.sh
铸渊 d2e6095219
Some checks failed
自动更新代码和重启 / update-and-restart (push) Has been cancelled
CI检查 + 自动部署 / check (push) Has been cancelled
CI检查 + 自动部署 / deploy (push) Has been cancelled
D125: 毛毛服务器入池 · MM-GZ-001 · 算力池+15台 · 部署脚本+激活记录
2026-06-05 22:52:59 +08:00

54 lines
2.2 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 光湖驱动引擎 v2.1 · 毛毛服务器一键部署
# 粘贴到服务器终端回车即可
set -e
echo "⚡ 光湖驱动引擎 v2.1 · 毛毛服务器 175.178.176.145"
echo "[1/5] 环境: $(lsb_release -ds 2>/dev/null||cat /etc/os-release|head -1), $(nproc)核, $(free -h|grep Mem|awk '{print $2}')"
echo "[2/5] 安装Node.js..."
if command -v node &>/dev/null; then echo " $(node -v)"; else
apt-get update -qq && apt-get install -y -qq curl
curl -fsSL https://deb.nodesource.com/setup_22.x|bash -
apt-get install -y nodejs && echo " $(node -v)"
fi
echo "[3/5] 部署gatekeeper..."
mkdir -p /opt/guanghu /var/log/guanghu
curl -fsSL -o /opt/guanghu/gatekeeper.js \
"https://guanghulab.com/code/bingshuo/guanghulab/raw/branch/main/_deploy/gatekeeper.js" 2>/dev/null \
|| curl -fsSL -o /opt/guanghu/gatekeeper.js \
"https://gitee.com/lingdianyuanhe/zero-point-prokaryotic/raw/main/_deploy/gatekeeper.js" 2>/dev/null \
|| { echo " 下载失败请手动上传gatekeeper.js到/opt/guanghu/"; exit 1; }
echo " $(wc -c < /opt/guanghu/gatekeeper.js) bytes"
echo "[4/5] systemd服务..."
cat > /etc/systemd/system/guanghu-engine.service << 'SVC'
[Unit]
Description=光湖驱动引擎 v2.1
After=network.target
[Service]
Type=simple;User=root;WorkingDirectory=/opt/guanghu
ExecStartPre=/bin/bash -c 'fuser -k 3910/tcp 2>/dev/null;sleep 1;true'
ExecStart=/usr/bin/node /opt/guanghu/gatekeeper.js 3910
Restart=always;RestartSec=3
StandardOutput=append:/var/log/guanghu/engine.log
StandardError=append:/var/log/guanghu/engine.log
[Install]
WantedBy=multi-user.target
SVC
systemctl daemon-reload && systemctl enable guanghu-engine
echo "[5/5] 防火墙+启动..."
apt-get install -y -qq ufw 2>/dev/null; ufw --force enable 2>/dev/null
ufw allow 3910/tcp;ufw allow 80/tcp;ufw allow 22/tcp
systemctl restart guanghu-engine;sleep 2
echo "════════════════════════════════════════"
if systemctl is-active --quiet guanghu-engine; then
echo "✅ 成功! 端口3910"
else
echo "❌ 失败 journalctl -u guanghu-engine -n 30"
fi
echo "════════════════════════════════════════"