From 39a55edcedf6c829ac15bb450522877e6ee2496f Mon Sep 17 00:00:00 2001 From: Vladislav Salikov Date: Mon, 23 Dec 2024 13:28:27 +0300 Subject: [PATCH] Added some BEC checks. --- wDayzManager.ini | 5 ++--- wDayzManager.ps1 | 34 +++++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/wDayzManager.ini b/wDayzManager.ini index 5e7272c..7f4db51 100644 --- a/wDayzManager.ini +++ b/wDayzManager.ini @@ -1,7 +1,7 @@ ; wDayzManager.ini [Config] serverLocation=Z:\Servers\dayzserver -; serverLocation=D:\dayz\server +; serverLocation=D:\servers\dayz profilesLocation=profiles steamCMD=Z:\SteamCMD ; steamCMD=V:\SteamCMD @@ -12,8 +12,7 @@ rotateLogs=1 daysAmount=7 rotatedLogsFolderName=RotatedLogs ; rotatedLogsFolderName= -becFolderName=BEC -; becFolderName= +becLocation=D:\servers\bec atFolderName=VPPAdminTools ; atFolderName=CommunityOnlineTools ; atFolderName= diff --git a/wDayzManager.ps1 b/wDayzManager.ps1 index 12a5b4d..e1c251a 100644 --- a/wDayzManager.ps1 +++ b/wDayzManager.ps1 @@ -107,6 +107,7 @@ $ini = (Get-IniContent -FilePath $iniFile) $config = $ini.Config [string]$serverLocation = $config.serverLocation [string]$profilesLocation = $config.profilesLocation +[string]$becLocation = $config.becLocation [string]$steamCMD = $config.steamCMD [string]$steamUser = $config.steamUser [int]$appidGame = $config.appidGame @@ -246,11 +247,21 @@ if ($rotateLogs) { } } -if (-not ([string]::IsNullOrEmpty($config.becFolderName))) { - $becFolderName = $config.becFolderName - $becLocation = "$($serverLocation)\$($becFolderName)" +# Checks for BEC location +if (-not ([string]::IsNullOrEmpty($becLocation))) { + if (-not [System.IO.Path]::IsPathRooted($becLocation)) { + $becLocation = "$($serverLocation)\$($becLocation)" + } + $becLocation = [System.IO.Path]::GetFullPath($becLocation) + $becFolderName = Split-Path -Path $becLocation -Leaf + + if (-not (Test-Path -Path "$($becLocation)\")) { + New-Item -ItemType Directory -Path "$($becLocation)\" | Out-Null + New-Item -ItemType Directory -Path "$($becLocation)\Config\" | Out-Null + } } +# Checks for AdminTool folder name if (-not ([string]::IsNullOrEmpty($config.atFolderName))) { $atFolderName = $config.atFolderName } @@ -315,8 +326,17 @@ foreach ($srv in $servers) { $startupParams = @("`"-profiles=$($serverProfile)`"", "`"-config=$($serverProfile)\$($serverConfig)`"", "-port=$($serverPort)", "-cpuCount=$($serverCPU)") $dayzArguments = $startupParams + $startupMods + $additionalParams $dayz = "`"$($serverLocation)\$($serverExeName)`"" - $bec = "`"$($becLocation)\bec.exe`"" - $becArguments = "-f `"$($instance).cfg`" --dsc" + + if ($becLocation) { + if (-not (Test-Path -Path "$($becLocation)\Config\$($instance).cfg")) { + New-Item -ItemType File -Path "$($becLocation)\Config\$($instance).cfg" | Out-Null + Write-Warning "Please make shure the config file `"$($instance).cfg`" in `"$($becLocation)\Config\`" folder is valid!" + Exit + } + + $bec = "`"$($becLocation)\bec.exe`"" + $becArguments = "-f `"$($instance).cfg`" --dsc" + } # Rotate logs if ($rotateLogs) { @@ -499,14 +519,14 @@ foreach ($srv in $servers) { # Starting servers Set-Location -Path "$($serverLocation)" $dayzProcess[$processID] = Start-Process -FilePath $dayz -ArgumentList $dayzArguments -PassThru - # Write-Host "$($dayzProcess[$processID]) = Start-Process -FilePath $($dayz) -ArgumentList $($dayzArguments) -PassThru" + # Write-Host "Start-Process -FilePath $($dayz) -ArgumentList $($dayzArguments) -PassThru" # $dayzProcess[$processID] # Starting BEC if ($becLocation) { Set-Location -Path "$($becLocation)" $becProcess[$processID] = Start-Process -FilePath $bec -ArgumentList $becArguments -PassThru - # Write-Host "$($becProcess[$processID]) = Start-Process -FilePath $($bec) -ArgumentList $($becArguments) -PassThru" + # Write-Host "Start-Process -FilePath $($bec) -ArgumentList $($becArguments) -PassThru" # $becProcess[$processID] }