diff --git a/DockerFile/start.sh b/DockerFile/start.sh index 44b6df8..abf0c5a 100644 --- a/DockerFile/start.sh +++ b/DockerFile/start.sh @@ -33,6 +33,34 @@ copy_files() { start_dayzserver() { cd /root/Steam/steamapps/common/DayZServer + + # 启动服务器之前,检查mod是否有更新. + updatemodpath="/root/Steam/steamapps/workshop/content/221100" + target_dir="/root/Steam/steamapps/common/DayZServer/client_mod" + + find "$updatemodpath" -mindepth 1 -maxdepth 1 -type d -print0 | while IFS= read -r -d $'\0' mod_dir; do + meta_file=$(find "$mod_dir" -type f -name "meta.cpp" -print -quit) + + if [[ -f "$meta_file" ]]; then + mod_name=$(grep -oP 'name\s*=\s*"\K[^"]*' "$meta_file") + + if [[ -n "$mod_name" ]]; then + symlink_path="${target_dir}/@${mod_name}" + if [[ ! -L "$symlink_path" ]]; then + echo "为 [$mod_name] 创建软链接: $symlink_path → $mod_dir" + ln -s "$mod_dir" "$symlink_path" + else + echo "软链接已存在: $symlink_path, 跳过创建" + fi + else + echo "警告: 在 $meta_file 中未找到 name 字段" + fi + else + echo "警告: 在 $mod_dir 中未找到 meta.cpp 文件" + fi + done + + # 初始化mod变量 client_mods="" server_mods=""