Added some BEC checks.

This commit is contained in:
2024-12-23 13:28:27 +03:00
parent 143e0bc7aa
commit 39a55edced
2 changed files with 29 additions and 10 deletions

View File

@@ -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]
}