Dcr 1 månad sedan
förälder
incheckning
5453a19bc6
1 ändrade filer med 28 tillägg och 0 borttagningar
  1. 28 0
      DockerFile/start.sh

+ 28 - 0
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=""