initGameServer.bat 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. @echo off
  2. fsutil behavior set disablelastaccess 0 >nul
  3. ::CODER BY Mr.Yu POWERD BY iBAT
  4. cd /d %~dp0
  5. set "config=%~dp0config.json"
  6. set "jq=%~dp0bin\jq.exe"
  7. @REM get dayz game server root path
  8. for /f "delims=" %%i in ('type %config% ^|%jq% -r ".serverPath"') do (
  9. set serverPath=%%i
  10. )
  11. @REM get dayz missions path
  12. for /f "delims=" %%i in ('type %config% ^|%jq% -r ".mpmissions"') do (
  13. set mpmissions=%%i
  14. )
  15. @REM get server config file path
  16. for /f "delims=" %%i in ('type %config% ^|%jq% -r ".serverCfg"') do (
  17. set serverCfg=%%i
  18. )
  19. @REM get game service port
  20. for /f "delims=" %%i in ('type %config% ^|%jq% -r ".serverPort"') do (
  21. set serverPort=%%i
  22. )
  23. @REM get cpu counts
  24. for /f "delims=" %%i in ('type %config% ^|%jq% -r ".cpuCount"') do (
  25. set cpuCount=%%i
  26. )
  27. set "ModPath=A_Mods"
  28. set "ServerModPath=A_ServerMods"
  29. set "ProfilePath=A_Profiles"
  30. set "DelModPath=A_NeedDel"
  31. if NOT EXIST %ModPath% mkdir %ModPath%
  32. if NOT EXIST %ServerModPath% mkdir %ServerModPath%
  33. if NOT EXIST %ProfilePath% mkdir %ProfilePath%
  34. if NOT EXIST %DelModPath% mkdir %DelModPath%
  35. echo [Processing need delete modules]
  36. for /f "delims=" %%i in ('dir /a/b/s %DelModPath% ^|findstr ".bikey .bisign"') do (
  37. Setlocal enabledelayedexpansion
  38. if %%~xi == .bisign (
  39. set "dbisignName=%%~ni.bisign"
  40. del /f/q "%serverPath%\Addons\!dbisignName!"
  41. echo SignFile [!dbisignName!] was deleted
  42. )
  43. if %%~xi == .bikey (
  44. set "dbikeyName=%%~ni.bikey"
  45. del /f/q "%serverPath%\Keys\!dbikeyName!"
  46. echo KeyFile [!dbikeyName!] was deleted
  47. )
  48. endlocal
  49. )
  50. echo.
  51. rd /s/q "%DelModPath%"
  52. mkdir "%DelModPath%"
  53. set "mpath="
  54. for /l %%z in (1 1 2) do (
  55. Setlocal enabledelayedexpansion
  56. if %%z EQU 1 (
  57. set mpath=%ModPath%
  58. echo [Processing client modules]
  59. ) else (
  60. set mpath=%ServerModPath%
  61. echo [Processing server modules]
  62. )
  63. for /f "delims=" %%i in ('dir /a/b/s !mpath! ^|findstr ".bikey .bisign"') do (
  64. if %%~xi == .bisign (
  65. cd /d %%~dpi
  66. set "cbisignName=%%~ni.bisign"
  67. set "cbisignNamePath=%%~dpni.bisign"
  68. xcopy /y "!cbisignNamePath!" "%serverPath%\Addons" >nul
  69. echo signFile ["!cbisignName!"] update success
  70. )
  71. if %%~xi == .bikey (
  72. cd /d %%~dpi
  73. set "cbikeyName=%%~ni.bikey"
  74. set "cbikeyNamePath=%%~dpni.bikey"
  75. xcopy /y "!cbikeyNamePath!" "%serverPath%\Keys" >nul
  76. echo KeyFile ["!cbikeyName!"] update success
  77. )
  78. )
  79. endlocal
  80. echo.
  81. )
  82. cd /d %~dp0
  83. set "modsName="
  84. Setlocal enabledelayedexpansion
  85. for /f "delims=" %%i in ('dir /a:d /b %~dp0%ModPath% ^|findstr /b "@"') do (
  86. set currPath=%%~dpi%ModPath%\%%i
  87. set modsName=!modsName!!currPath!;
  88. )
  89. set "serverModsName="
  90. for /f "delims=" %%i in ('dir /a:d /b %~dp0%ServerModPath% ^|findstr /b "@"') do (
  91. set currPath=%%~dpi%ServerModPath%\%%i
  92. set serverModsName=!serverModsName!!currPath!;
  93. )
  94. set "clientMods=-mod=%modsName%"
  95. set "serverMods=-servermod=%serverModsName%"
  96. set "startParameter=-port=%serverPort% -cpuCount=%cpuCount%"
  97. set "otherParameter=-adminlog -dologs -netlog -noFilePatching"
  98. set "profilesPath=-profiles=%~dp0A_Profiles"
  99. set "missionsPath=-mission=%mpmissions%"
  100. set "serverCfgPath=-config=%~dp0serverDZ.cfg"
  101. echo @echo off > startDayZServer.bat
  102. echo mode con lines=32 cols=50 >> startDayZServer.bat
  103. echo title Server-side monitor >> startDayZServer.bat
  104. echo. >> startDayZServer.bat
  105. echo :setup >> startDayZServer.bat
  106. echo start /wait /high "" "%serverPath%\DayZServer_x64.exe" ^^>> startDayZServer.bat
  107. echo "%serverCfgPath%" ^^>> startDayZServer.bat
  108. echo %startParameter% ^^>> startDayZServer.bat
  109. echo %otherParameter% ^^>> startDayZServer.bat
  110. echo "%profilesPath%" ^^>> startDayZServer.bat
  111. echo "%missionsPath%" ^^>> startDayZServer.bat
  112. echo "%clientMods%" ^^>> startDayZServer.bat
  113. echo "%serverMods%">> startDayZServer.bat
  114. echo goto :setup >> startDayZServer.bat
  115. endlocal
  116. pause
  117. call startDayZServer.bat