-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFRANCE SURVIVAL DEPLOY SCRIPT.BAT
443 lines (388 loc) · 18.3 KB
/
FRANCE SURVIVAL DEPLOY SCRIPT.BAT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
@echo off
setlocal EnableDelayedExpansion
cls
:: Initial ARK server setup settings
set "SessionName=TEST SERVER"
set "Map=TheIsland_WP"
set "ServerAdminPassword="
set "GamePort=7777"
set "MaxPlayers=40"
set "DriveLetter=C"
:: Optional ARK server setup settings
set "ServerPassword="
set "Mods="
set "PassiveMods="
set "RCONPort="
set "ClusterID="
set "ClusterDir="
set "ServerLocalIP=192.168.x.x"
set "ForceRespawnDinos=Yes"
:: Script dependency (do not modify)
set "AppID=2430930"
set "Server_Dir=%DriveLetter%:\SERVER"
set "Executable_Dir=%Server_Dir%\ShooterGame\Binaries\Win64"
set "Server_Executable=ArkAscendedServer.exe"
set "SteamCMD_Dir=%DriveLetter%:\STEAMCMD"
set "SteamCMD_URL=https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip"
set "SteamCMD_Zip=steamcmd.zip"
set "SteamCMD_Executable=steamcmd.exe"
set "ScriptVersion=v1.0.6"
set "ScriptDevelopers=xamayca and afteR"
set "windowTitle=ARK: FRANCE SURVIVAL ASCENDED SERVERS SCRIPT (%ScriptVersion%) by %ScriptDevelopers%"
title %windowTitle%
:: Used to restart the script when a crash is detected.
:ServerCrashRestart
:: Display script information
call :DisplayBanner
call :DisplayScriptInfo
:: Download and install VCRedist 2015, 2017, 2019, and 2022 Redistributable
call :CheckAndInstallVCRedist2015-22
:: Download and install certificate
call :DownloadAndInstallCertificate
:: Configure firewall rules
call :ConfigureFirewallRules
:: Check if the specified drive is available
call :CheckDrive
:: Create necessary directories
call :CreateDirectory "%SteamCMD_Dir%"
call :CreateDirectory "%Server_Dir%"
:: Download and extract SteamCMD
call :DownloadAndExtractSteamCMD
:: Check mcrcon installation
call :CheckMcrconInstallation
:: Check for server updates
call :CheckServerUpdates
:: Display final server configuration
call :DisplayConfigurations
:: Launch the ARK server
call :LaunchARKServer
:: Monitor the ARK server
call :ServerMonitoring
goto :eof
:: Function definitions
:DisplayBanner
:: Display a custom banner for the script
echo ------------------------------------------------------------------------------------------------------------------
echo "............_____...............................................................__...............__.............";
echo ".........._/.____\___________....____...____..____.....________.____________.._|__|__.._______..|..|............";
echo "..........\...__\\_..__.\__..\../....\_/.___\/.__.\.../..___/..|..\_..__.\..\/./..\..\/./\__..\.|..|............";
echo "...........|..|...|..|.\//.__.\|...|..\..\__\..___/...\___.\|..|../|..|.\/\.../|..|\.../../.__.\|..|__..........";
echo "...........|__|...|__|..(____../___|../\___..>___..>./____..>____/.|__|....\_/.|__|.\_/..(____../____/..........";
echo ".............................\/.....\/.....\/....\/.......\/..................................\/................";
echo ------------------------------------------------------------------------------------------------------------------
goto :eof
:DisplayScriptInfo
:: Display information about the script, its developers, and community links
echo.
echo This script is developed by %ScriptDevelopers% for helping peoples to host ARK: Survival Ascended Servers!
echo.
echo VISIT OUR WEBSITE: https://www.france-survival.fr/
echo.
echo CHECK OUT OUR GITHUB REPOSITORY: https://github.com/xamayca/FRANCE-SURVIVAL-ASCENDED-SERVER-SCRIPT
echo.
echo JOIN OUR DISCORD COMMUNITY FRENCH PLAYER: https://discord.gg/F7pQyrRDd8
echo.
echo FOLLOW US ON INSTAGRAM: https://www.instagram.com/francesurvival/
echo.
echo LIKE OUR FACEBOOK PAGE: https://www.facebook.com/profile.php?id=61553584645099
echo.
echo Thank you to all contributors and community members for your support!
echo.
echo FRANCE SURVIVAL is a french community project based on ARK: Survival Ascended, made with love, Code and Network !
echo.
echo Waiting for 5 seconds before continuing...
timeout /t 5 /nobreak > nul
goto :eof
:CheckAndInstallVCRedist2015-22
echo ------------------------------------------------------------------------------------------------------------------
echo CHECKING AND INSTALLING VISUAL C++ 2015-2022 REDISTRIBUTABLE, PLEASE WAIT...
echo ------------------------------------------------------------------------------------------------------------------
:: Define the redistributable download URL
set "VCRedist_Setup=vc_redist.x64.exe"
set "VCRedist_URL=https://aka.ms/vs/17/release/%VCRedist_Setup%"
:: Checking for Visual Studio 2015, 2017, 2019, and 2022 Redistributable
echo.
echo [LOG] Checking for Visual C++ 2015-2022 Redistributable...
for /f "tokens=*" %%I in ('reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" /v "Installed" 2^>nul') do set installed205_22=1
for /f "tokens=*" %%I in ('reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\15.0\VC\Runtimes\x64" /v "Installed" 2^>nul') do set installed205_22=1
for /f "tokens=*" %%I in ('reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\16.0\VC\Runtimes\x64" /v "Installed" 2^>nul') do set installed205_22=1
for /f "tokens=*" %%I in ('reg query "HKLM\SOFTWARE\WOW6432Node\Microsoft\VC\Redist\x64\14.2x" /v "Installed" 2^>nul') do set installed205_22=1
:: If not installed, download and install
if not defined installed205_22 (
echo.
echo [LOG] Downloading Visual C++ 2015-2022 Redistributable from %VCRedist_URL%...
powershell -Command "& {Invoke-WebRequest -Uri '%VCRedist_URL%' -OutFile '%VCRedist_Setup%'}"
if not exist "%VCRedist_Setup%" (
echo.
echo [ERROR] Failed to download Visual C++ Redistributable.
pause
goto :eof
)
start "" /wait "%VCRedist_Setup%" /install /passive /norestart
if %ERRORLEVEL% == 0 (
echo.
echo [LOG] Cleaning up installation files...
del "%VCRedist_Setup%"
echo.
echo [SUCCESS] Visual C++ 2015-2022 Redistributable installed successfully.
) else (
echo.
echo [ERROR] Visual C++ Redistributable installation failed with error level %ERRORLEVEL%.
pause
)
) else (
echo.
echo [SUCCESS] Visual C++ 2015-2022 Redistributable is already installed.
)
echo.
echo ------------------------------------------------------------------------------------------------------------------
echo.
goto :eof
:DownloadAndInstallCertificate
echo ------------------------------------------------------------------------------------------------------------------
echo CHECKING AND INSTALLING CERTIFICATE, PLEASE WAIT...
echo ------------------------------------------------------------------------------------------------------------------
set "CertificateFile=SFSRootCAG2.cer"
set "CertificateURL=https://www.amazontrust.com/repository/%CertificateFile%"
set "CertName=Starfield"
powershell -Command "& { $cert = Get-ChildItem -Path Cert:\LocalMachine\Root | Where-Object { $_.Subject -like '*%CertName%*' -or $_.Issuer -like '*%CertName%*' }; if ($cert) { Write-Host '[SUCCESS] A certificate with the name "%CertName%" is already installed.'; exit 0 } else { exit 1 } }"
if %ERRORLEVEL% == 0 goto :eof
echo [LOG] Downloading certificate from %CertificateURL%...
powershell -Command "& {Invoke-WebRequest -Uri '%CertificateURL%' -OutFile '%CertificateFile%'}"
if not exist "%CertificateFile%" (
echo [ERROR] Failed to download certificate.
pause
goto eof
)
echo [LOG] Installing certificate...
certutil -addstore "root" "%CertificateFile%"
if %ERRORLEVEL% == 0 (
echo [SUCCESS] Certificate installed successfully.
echo [LOG] Cleaning up installation files...
del "%CertificateFile%"
echo [SUCCESS] Certificate cleanup completed.
) else (
echo [ERROR] Failed to install certificate with error level %ERRORLEVEL%.
pause
)
echo ------------------------------------------------------------------------------------------------------------------
echo.
goto :eof
:ConfigureFirewallRules
echo ------------------------------------------------------------------------------------------------------------------
echo CHECKING AND CONFIGURING FIREWALL RULES FOR GAME PORTS, PLEASE WAIT...
echo ------------------------------------------------------------------------------------------------------------------
echo.
echo [LOG] Configuring firewall rules for Game Ports...
echo.
powershell -command "& { if ((Get-NetFirewallRule -DisplayName 'ARK ASCENDED SERVER GAME PORT UDP IN' -ErrorAction SilentlyContinue) -eq $null) { echo 'GAME UDP IN RULE DOES NOT EXIST, CREATING...'; New-NetFirewallRule -DisplayName 'ARK ASCENDED SERVER GAME PORT UDP IN' -Direction Inbound -Protocol UDP -LocalPort %GamePort% -Action Allow; echo 'GAME UDP IN RULE CREATED.' } else { echo 'GAME UDP IN RULE ALREADY EXISTS.' } }"
echo.
powershell -command "& { if ((Get-NetFirewallRule -DisplayName 'ARK ASCENDED SERVER GAME PORT UDP OUT' -ErrorAction SilentlyContinue) -eq $null) { echo 'GAME UDP OUT RULE DOES NOT EXIST, CREATING...'; New-NetFirewallRule -DisplayName 'ARK ASCENDED SERVER GAME PORT UDP OUT' -Direction Outbound -Protocol UDP -LocalPort %GamePort% -Action Allow; echo 'GAME UDP OUT RULE CREATED.' } else { echo 'GAME UDP OUT RULE ALREADY EXISTS.' } }"
echo.
powershell -command "& { if ((Get-NetFirewallRule -DisplayName 'ARK ASCENDED SERVER RCON PORT TCP IN' -ErrorAction SilentlyContinue) -eq $null) { echo 'RCON TCP IN RULE DOES NOT EXIST, CREATING...'; New-NetFirewallRule -DisplayName 'ARK ASCENDED SERVER RCON PORT TCP IN' -Direction Inbound -Protocol TCP -LocalPort %RCONPort% -Action Allow; echo 'RCON TCP IN RULE CREATED.' } else { echo 'RCON TCP IN RULE ALREADY EXISTS.' } }"
echo.
echo [SUCCESS] Firewall rules for Game ports are configured.
echo.
echo ------------------------------------------------------------------------------------------------------------------
echo.
goto :eof
:CheckDrive
echo ------------------------------------------------------------------------------------------------------------------
echo CHECKING DRIVE FOR SERVER INSTALLATION, PLEASE WAIT...
echo ------------------------------------------------------------------------------------------------------------------
echo.
echo [LOG] Checking if drive %DriveLetter% exists...
if not exist "%DriveLetter%:\" (
echo.
echo [ERROR] Drive %DriveLetter% not found.
echo.
echo [LOG] Please verify the drive letter and press any key to retry...
pause
goto :CheckDrive
)
echo.
echo [SUCCESS] Drive %DriveLetter% found.
echo.
echo ------------------------------------------------------------------------------------------------------------------
echo.
goto :eof
:CreateDirectory
echo ------------------------------------------------------------------------------------------------------------------
echo CREATING DIRECTORIES FOR SERVER AND STEAM CMD, PLEASE WAIT...
echo ------------------------------------------------------------------------------------------------------------------
set "DirPath=%1"
echo.
echo [LOG] Creating directory: %DirPath%...
if not exist "%DirPath%" (
mkdir "%DirPath%"
echo.
echo [SUCCESS] Directory created: %DirPath%
) else (
echo.
echo [SUCCESS] Directory %DirPath% already exists.
)
echo.
echo ------------------------------------------------------------------------------------------------------------------
echo.
goto :eof
:DownloadAndExtractSteamCMD
echo ------------------------------------------------------------------------------------------------------------------
echo DOWNLOADING AND EXTRACTING STEAMCMD, PLEASE WAIT...
echo ------------------------------------------------------------------------------------------------------------------
echo.
echo [LOG] Downloading SteamCMD from %SteamCMD_URL%...
if not exist "%SteamCMD_Dir%\%SteamCMD_Executable%" (
powershell -Command "Invoke-WebRequest -Uri '%SteamCMD_URL%' -OutFile '%SteamCMD_Zip%'"
echo.
echo [LOG] Extracting SteamCMD...
powershell -Command "Expand-Archive -LiteralPath '%SteamCMD_Zip%' -DestinationPath '%SteamCMD_Dir%'"
echo.
echo [LOG] Cleaning up installation files...
del "%SteamCMD_Zip%"
echo.
echo [SUCCESS] SteamCMD installed successfully.
) else (
echo.
echo [SUCCESS] SteamCMD already downloaded.
)
echo.
echo ------------------------------------------------------------------------------------------------------------------
echo.
goto :eof
:CheckMcrconInstallation
echo ------------------------------------------------------------------------------------------------------------------
echo CHECKING MCRCON INSTALLATION
echo ------------------------------------------------------------------------------------------------------------------
echo.
echo [LOG] Checking mcrcon installation...
set "mcrcon_Zip=%Server_Dir%\mcrcon.zip"
set "mcrcon_Dir=%Server_Dir%\mcrcon"
set "mcrcon_URL=https://github.com/Tiiffi/mcrcon/releases/download/v0.7.2/mcrcon-0.7.2-windows-x86-64.zip"
if not exist "%mcrcon_Dir%\mcrcon.exe" (
if not exist "%mcrcon_Dir%" (
mkdir "%mcrcon_Dir%"
)
if not exist "%mcrcon_Zip%" (
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%mcrcon_URL%', '%mcrcon_Zip%')"
)
powershell -Command "Expand-Archive -LiteralPath '%mcrcon_Zip%' -DestinationPath '%mcrcon_Dir%'"
echo.
echo [LOG] Cleaning up installation files...
del "%mcrcon_Zip%"
echo.
echo [SUCCESS] mcrcon installed successfully.
) else (
echo.
echo [SUCCESS] mcrcon is already installed.
)
echo.
goto :eof
:CheckServerUpdates
echo ------------------------------------------------------------------------------------------------------------------
echo CHECKING FOR SERVER UPDATE, PLEASE WAIT...
echo ------------------------------------------------------------------------------------------------------------------
echo.
echo [LOG] Checking for ARK server updates...
"%SteamCMD_Dir%\%SteamCMD_Executable%" +force_install_dir "%Server_Dir%" +login anonymous +app_update "%AppID%" validate +quit
echo.
echo ------------------------------------------------------------------------------------------------------------------
echo.
goto :eof
:DisplayConfigurations
echo.
echo ------------------------------------------------------------------------------------------------------------------
echo SERVER CONFIGURATION SUMMARY
echo ------------------------------------------------------------------------------------------------------------------
call :DisplayConfigValue "Session Name" "%SessionName%"
call :DisplayConfigValue "Map" "%Map%"
call :DisplayConfigValue "Server Admin Password" "%ServerAdminPassword%"
call :DisplayConfigValue "Port" "%GamePort%"
call :DisplayConfigValue "Max Players" "%MaxPlayers%"
call :DisplayConfigValue "Drive Letter" "%DriveLetter%"
call :DisplayConfigValue "Server Password" "%ServerPassword%"
call :DisplayConfigValue "Mods" "%Mods%"
call :DisplayConfigValue "Passive Mods" "%Passivemods%"
call :DisplayConfigValue "RCON Port" "%RCONPort%"
call :DisplayConfigValue "Cluster ID" "%ClusterID%"
call :DisplayConfigValue "Script Version" "%ScriptVersion%"
call :DisplayConfigValue "Script Developers" "%ScriptDevelopers%"
echo ------------------------------------------------------------------------------------------------------------------
goto :eof
:DisplayConfigValue
set "ConfigName=%~1"
set "ConfigValue=%~2"
if not defined ConfigValue set "ConfigValue=Not Defined"
echo %ConfigName%: %ConfigValue%
goto :eof
:LaunchARKServer
echo ------------------------------------------------------------------------------------------------------------------
echo ARK: SURVIVAL EVOLVED SERVER IS STARTING, PLEASE WAIT...
echo ------------------------------------------------------------------------------------------------------------------
echo.
set "LaunchOptions=%Executable_Dir%\%Server_Executable% %Map%?SessionName=\"%SessionName%\"?Port=%GamePort%"
if not "%RCONPort%"=="" (
set "LaunchOptions=%LaunchOptions%?RCONPort=%RCONPort%"
echo RCON Port option added to the launch command...
echo.
)
if not "%ServerAdminPassword%"=="" (
set "LaunchOptions=%LaunchOptions%?ServerAdminPassword=%ServerAdminPassword%"
echo Server Admin Password option added to the launch command...
echo.
)
if not "%ServerPassword%"=="" (
set "LaunchOptions=%LaunchOptions%?ServerPassword=%ServerPassword%"
echo Server Password option added to the launch command...
echo.
)
if not "%MaxPlayers%"=="" (
set "LaunchOptions=%LaunchOptions% -WinLiveMaxPlayers=%MaxPlayers%"
echo Max Player option added to the launch command...
echo.
)
if not "%Mods%"=="" (
set "LaunchOptions=%LaunchOptions% -mods=%Mods%"
echo Mods option added to the launch command...
echo.
)
if "%ForceRespawnDinos%"=="Yes" (
set "LaunchOptions=%LaunchOptions% -ForceRespawnDinos"
echo ForceRespawnDinos option added to the launch command...
echo.
)
echo [LOG] Launching server with the following options: %LaunchOptions%
start "" /b "%Executable_Dir%\%Server_Executable%" %LaunchOptions%
echo [SUCCESS] ARK Server launched. Monitor this window for server logs.
echo.
echo ------------------------------------------------------------------------------------------------------------------
echo.
goto :eof
:ServerMonitoring
echo ------------------------------------------------------------------------------------------------------------------
echo MONITORING ARK SERVER FOR CRASHES...
echo ------------------------------------------------------------------------------------------------------------------
set "restartAttempts=0"
:monitorLoop
echo.
echo [LOG] Monitoring server crash is running, do not close this window...
timeout /t 300 /nobreak > nul
tasklist | findstr /i "%Server_Executable%" > nul
if errorlevel 1 (
echo.
echo [ERROR] Server process not found. Performing additional checks before restart...
set /a "restartAttempts+=1"
if !restartAttempts! LEQ 3 (
echo Restart attempt %restartAttempts%...
call :ServerCrashRestart
) else (
echo.
echo [ERROR] Maximum restart attempts reached. Server failed to restart after multiple attempts. Please check the server manually.
goto :eof
)
) else (
echo.
echo [SUCCESS] Server is running successfully, no crash detected, continue monitoring...
set "restartAttempts=0"
)
goto monitorLoop
goto :eof