Files
Linux_Docker_build_DayzServer/DockerFile/install_dayz.sh

40 lines
1.0 KiB
Bash
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
# DayZ服务器安装脚本
# 使用环境变量中的Steam用户名和密码
# 检查环境变量
if [ -z "$STEAM_USERNAME" ] || [ -z "$STEAM_PASSWORD" ]; then
echo "错误: 请设置 STEAM_USERNAME 和 STEAM_PASSWORD 环境变量"
echo "在本目录下执行 vi .env 设置环境变量"
echo "示例:"
echo "export STEAM_USERNAME=your_username"
echo "export STEAM_PASSWORD=your_password"
exit 1
fi
# 切换到SteamCMD目录
cd /opt/steamcmd
# 运行SteamCMD安装DayZ服务器
echo "开始安装DayZ服务器..."
./steamcmd.sh +login $STEAM_USERNAME $STEAM_PASSWORD +app_update 223350 validate +quit
# 检查安装结果
if [ $? -eq 0 ]; then
echo "DayZ服务器安装完成"
else
echo "安装失败,请检查用户名和密码是否正确"
exit 1
fi
# 初始化BERcon配置
password=$(tr -dc 'A-Za-z0-9!@%^_=+?' < /dev/urandom | head -c 12)
cat > /root/Steam/steamapps/common/DayZServer/battleye/beserver_x64.cfg << EOF
RConPort 2314
RConPassword $password
RestrictRCon 0
EOF
# 更新mod
bash /opt/updatemod.sh