Files
GameServerManager/start.sh
2026-10-02 14:24:08 +08:00

126 lines
4.3 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
# GSM3 游戏服务端管理面板启动脚本
echo "======================================"
echo " GSM3 游戏服务端管理面板"
echo "======================================"
echo
# 检查是否存在GSM3应用文件
if [ -f "server/index.js" ]; then
echo "🚀 启动GSM3管理面板..."
echo "📍 访问地址: http://localhost:3001"
echo "📍 默认账户: admin / admin123"
echo
# Docker 的持久卷会遮蔽镜像内的 server/data,补充卷中缺失的内置插件。
# 仅复制不存在的插件目录,避免覆盖用户配置或自行安装的插件。
DEFAULT_PLUGINS_DIR="data/plugins"
RUNTIME_PLUGINS_DIR="server/data/plugins"
if [ -d "$DEFAULT_PLUGINS_DIR" ]; then
mkdir -p "$RUNTIME_PLUGINS_DIR"
for plugin_dir in "$DEFAULT_PLUGINS_DIR"/*; do
if [ ! -d "$plugin_dir" ] || [ ! -f "$plugin_dir/plugin.json" ]; then
continue
fi
plugin_name=$(basename "$plugin_dir")
runtime_plugin_dir="$RUNTIME_PLUGINS_DIR/$plugin_name"
if [ ! -e "$runtime_plugin_dir" ]; then
cp -a "$plugin_dir" "$runtime_plugin_dir"
echo "✅ 已补充内置插件: $plugin_name"
fi
done
fi
# Docker 的持久卷会遮蔽镜像内的 server/data,补充卷中缺失的内置运行时资产。
BUILTIN_LIB_DIR="server/builtin/data/lib"
RUNTIME_LIB_DIR="server/data/lib"
if [ -d "$BUILTIN_LIB_DIR" ]; then
mkdir -p "$RUNTIME_LIB_DIR"
cp -an "$BUILTIN_LIB_DIR"/. "$RUNTIME_LIB_DIR"/ 2>/dev/null || true
fi
# PTY 文件已迁移到 data/lib/ 目录,启动时由服务端自动检测和下载
# 如果 data/lib/ 中存在 PTY 文件,验证并设置可执行权限
ARCH=$(uname -m)
PTY_SUPPORTED="yes"
if [ "$ARCH" = "x86_64" ]; then
PTY_FILE="$RUNTIME_LIB_DIR/pty_linux_x64"
elif [ "$ARCH" = "aarch64" ]; then
PTY_FILE="$RUNTIME_LIB_DIR/pty_linux_arm64"
else
PTY_FILE=""
PTY_SUPPORTED="no"
fi
if [ -n "$PTY_FILE" ] && [ -f "$PTY_FILE" ]; then
# file 命令只是启动前的轻量预检;真正的可信校验由服务端固定清单完成。
if command -v file >/dev/null 2>&1; then
if file "$PTY_FILE" 2>/dev/null | grep -q "ELF"; then
chmod +x "$PTY_FILE"
echo "✅ PTY权限设置完成 ($ARCH)"
else
echo "⚠️ PTY文件无效(非ELF二进制),已删除,服务启动时将自动重新下载"
rm -f "$PTY_FILE"
fi
else
chmod +x "$PTY_FILE"
echo "✅ PTY权限设置完成 ($ARCH)"
echo "ℹ️ 未安装 file 命令,已跳过PTY启动预检,服务端将继续执行固定清单校验"
fi
elif [ "$PTY_SUPPORTED" = "no" ]; then
echo "ℹ️ 当前架构 ($ARCH) 暂无固定PTY资产,终端功能可能不可用"
else
echo "ℹ️ PTY文件将在服务启动时自动下载"
fi
# 启动应用
cd server
node index.js
else
echo "❌ 未找到GSM3应用文件,正在启动传统Steam服务器管理..."
echo
# 传统的Steam服务器管理菜单
ARCH=$(uname -m)
while true; do
echo "请选择操作:"
if [ "$ARCH" = "x86_64" ]; then
echo "1. 启动SteamCMD"
else
echo "1. SteamCMD (不支持当前架构: $ARCH)"
fi
echo "2. 查看游戏目录"
echo "3. 退出"
echo -n "请输入选项 (1-3): "
read choice
case $choice in
1)
if [ "$ARCH" = "x86_64" ]; then
echo "启动SteamCMD..."
cd ${STEAMCMD_DIR}
./steamcmd.sh
else
echo "❌ SteamCMD不支持当前架构: $ARCH"
echo "💡 非 x86_64 架构仅支持GSM3管理面板功能"
fi
;;
2)
echo "游戏目录内容:"
ls -la ${GAMES_DIR}
;;
3)
echo "退出"
exit 0
;;
*)
echo "无效选项,请重新选择"
;;
esac
echo
done
fi