Added servers updating options

This commit is contained in:
Vladislav Salikov
2024-11-11 19:12:05 +03:00
parent acdcf23a1b
commit a8a061464f
4 changed files with 188 additions and 127 deletions

View File

@@ -1,5 +1,10 @@
@echo off @echo off
set scriptPath=%~dp0 set scriptPath=%~dp0
set customPath=D:\DayZ\Server\.customs
cd /d %scriptPath%
pushd %scriptPath%
set update=0 set update=0
if "%1" equ "/U" set update=1 if "%1" equ "/U" set update=1
if "%1" equ "/u" set update=1 if "%1" equ "/u" set update=1
@@ -7,6 +12,11 @@ if "%1" equ "-U" set update=1
if "%1" equ "-u" set update=1 if "%1" equ "-u" set update=1
if "%1" equ "--update" set update=1 if "%1" equ "--update" set update=1
cd /d %scriptPath% powershell -ExecutionPolicy RemoteSigned -File wDayzManager.ps1 %update%
@REM powershell -ExecutionPolicy RemoteSigned -File wDayzManager.ps1 %update% @REM powershell -ExecutionPolicy RemoteSigned -File wDayzManager.ps1 %update% > wDayzManager.log
powershell -ExecutionPolicy RemoteSigned -File wDayzManager.ps1 %update% > wDayzManager.log
@REM echo Customization...
@REM cd /d %customPath%
@REM copy /Y messages.xml d:\dayz\server\mpmissions\hardcore.namalsk\db
popd

View File

@@ -6,15 +6,24 @@ steamCMD=D:\DayZ\SteamCMD
steamUser=w0lf_2k steamUser=w0lf_2k
appidGame=221100 appidGame=221100
appidServer=223350 appidServer=223350
namalskMission=Regular
rotateLogs=1 rotateLogs=0
daysAmount=3 daysAmount=3
rotatedLogsFolderName=RotatedLogs rotatedLogsFolderName=RotatedLogs
; rotatedLogsFolderName= ; rotatedLogsFolderName=
becFolderName=BEC becFolderName=BEC
; becFolderName= ; becFolderName=
atFolderName=CommunityOnlineTools atFolderName=VPPAdminTools
; atFolderName=VPPAdminTools ; atFolderName=CommunityOnlineTools
; Server updating settings:
; D = Daily - Updates are checked daily at the hours specified in parameter 'updateHour' (0 - 23). In this case, parameter 'updateDay' is ignored.
; W = Weekly - Updates are checked weekly at the hours specified in parameter 'updateHour' (0 - 23). Parameter 'updateDay' specifies the day of the week (0 - 6, 0 = Sunday).
; M = Monthly - Updates are checked monthly at the hours specified in parameter 'updateHour' (0 - 23). Parameter 'updateDay' specifies the day of the month (1 - 31. Be careful with February!).
; Any other value disables the updates.
updatePeriod=W
updateDay=1
updateHour=4
[ClientMods] [ClientMods]
@GAZ_TIGR=2731398623 @GAZ_TIGR=2731398623
@@ -34,13 +43,18 @@ serverPort=35500
serverConfig=serverDZ.cfg serverConfig=serverDZ.cfg
serverExeName=DayZServer_x64.exe serverExeName=DayZServer_x64.exe
serverCPU=4 serverCPU=4
startupClientMods=@CF;@COT ; startupClientMods=@CF;@COT
startupClientMods=@CF;@VPPAdminTools;@Namalsk_Island;@Namalsk_Survival
startupServerMods= startupServerMods=
additionalParams= -name=Server -filePatching
namalskMission=Hardcore
[Server 6] ; [Server 6]
serverPort=35600 ; serverPort=35600
serverConfig=serverDZ.cfg ; serverConfig=serverDZ.cfg
serverExeName=DayZServer_x64.exe ; serverExeName=DayZServer_x64.exe
serverCPU=2 ; serverCPU=2
startupClientMods=@CF;@VPPAdminTools ; startupClientMods=@CF;@VPPAdminTools
startupServerMods= ; startupServerMods=
; additionalParams= -name=Server -adminLog -filePatching
; namalskMission=Hardcore

View File

@@ -10,23 +10,24 @@ param (
[int] [int]
$param = 0 $param = 0
) )
# $date = (Get-Date).ToString()
$date = Get-Date
[string]$logFile = ".\wDayzManager.log"
# $date | Out-File -FilePath $logFile
[bool]$update = $param [bool]$update = $param
if ($update) { [bool]$noDelete = $true # For tests - don't delete logs
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { [string]$logFile = ".\wDayzManager.log"
Write-Warning "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!" [string]$steamScript = "wDayzManager.txt"
Break [string]$iniFile = "wDayzManager.ini"
} if (-not (Test-Path $iniFile)) {
Write-Error "Can't find file '$iniFile'"
Exit
} }
$date = Get-Date
[int]$currentDayOfWeek = ([datetime]$date).DayOfWeek
[int]$currentDay = ([datetime]$date).Day
[int]$currentHour = ([datetime]$date).Hour
$ini = $config = $servers = $clientMods = $serverMods = $steamProcess = $null $ini = $config = $servers = $clientMods = $serverMods = $steamProcess = $null
$namalskMission = $nPath = $nPath2 = $dayzProcess = $becProcess = $instance = $null $modNI = $modNS = $namalskMission = $pathNamalskMission = $null
$dayzProcess = $becProcess = $instance = $null
$becLocation = $rotatedLogsFolderName = $atFolderName = $serverLocation = $null $becLocation = $rotatedLogsFolderName = $atFolderName = $serverLocation = $null
$steamCMD = $steamUser = $appidServer = $appidGame = $rotateLogs = $daysAmount = $null $steamCMD = $steamUser = $appidServer = $appidGame = $rotateLogs = $daysAmount = $null
$serverPort = $serverConfig = $serverExeName = $serverCPU = $null $serverPort = $serverConfig = $serverExeName = $serverCPU = $null
@@ -34,22 +35,18 @@ $startupClientMods = $startupServerMods = $startupMods = $startupParams = $null
$serverProfile = $additionalParams = $dayzArguments = $dayz = $bec = $becArguments = $null $serverProfile = $additionalParams = $dayzArguments = $dayz = $bec = $becArguments = $null
$logsName = $atLogsLocation = $becLogsLocation = $rotatedLogsLocation = $null $logsName = $atLogsLocation = $becLogsLocation = $rotatedLogsLocation = $null
[bool]$noDelete = $true # For tests - don't delete logs
[string]$steamScript = "wDayzManager.txt"
[string]$iniFile = "wDayzManager.ini"
if (-not (Test-Path $iniFile)) {
Write-Error "Can't find file '$iniFile'"
Exit 1
}
Write-Host "==========" Write-Host "=========="
$ini = (Get-IniContent -FilePath $iniFile) $ini = (Get-IniContent -FilePath $iniFile)
$config = $ini.Config $config = $ini.Config
$serverLocation = $config.serverLocation [string]$serverLocation = $config.serverLocation
$steamCMD = $config.steamCMD [string]$steamCMD = $config.steamCMD
$steamUser = $config.steamUser [string]$steamUser = $config.steamUser
$appidServer = $config.appidServer [int]$appidGame = $config.appidGame
$appidGame = $config.appidGame [int]$appidServer = $config.appidServer
[int]$updateDay = $config.updateDay
[int]$updateHour = $config.updateHour
[string]$updatePeriod = $config.updatePeriod
[bool]$rotateLogs = [int]$config.rotateLogs [bool]$rotateLogs = [int]$config.rotateLogs
$clientMods = New-Object 'Collections.Generic.List[Tuple[string,string]]' $clientMods = New-Object 'Collections.Generic.List[Tuple[string,string]]'
@@ -66,22 +63,24 @@ foreach ($mod in $ini.ServerMods.GetEnumerator()) {
} }
} }
# $clientMods.Item1 | ForEach-Object { switch ($updatePeriod) {
# if ($_ -like "*namalsk*" -and $_ -like "*survival*") { D { if ($currentHour -eq $updateHour) { $update = $true } }
# $namalskMission = $config.namalskMission W { if (($currentDayOfWeek -eq $updateDay) -and ($currentHour -eq $updateHour)) { $update = $true } }
# if (($namalskMission -eq "regular") -or ($namalskMission -eq "hardcore")) { M { if (($currentDay -eq $updateDay) -and ($currentHour -eq $updateHour)) { $update = $true } }
# $nPath = "$($namalskMission)\$($namalskMission).namalsk" Default { $update = $param }
# $nPath2 = Split-Path -Path $nPath -Leaf }
# }
# }
# }
if ($update) { if ($update) {
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!"
Exit
}
Write-Host "Start updating server..." Write-Host "Start updating server..."
if (-not (Test-Path $steamCMD)) { if (-not (Test-Path $steamCMD)) {
Write-Error "Can't find folder '$steamCMD'" Write-Error "Can't find folder '$steamCMD'"
Exit 2 Exit
} }
$currentPath = Get-Location $currentPath = Get-Location
@@ -106,11 +105,12 @@ if ($update) {
$steamProcess = Start-Process -FilePath "$($steamCMD)\steamcmd.exe" -ArgumentList "+runscript $($currentPath)\$($steamScript) +quit" -PassThru -Wait -NoNewWindow $steamProcess = Start-Process -FilePath "$($steamCMD)\steamcmd.exe" -ArgumentList "+runscript $($currentPath)\$($steamScript) +quit" -PassThru -Wait -NoNewWindow
if ($steamProcess.ExitCode -ne 0) { if ($steamProcess.ExitCode -ne 0) {
Write-Error "$_ failed with error code $($steamProcess.ExitCode)" Write-Error "$_ failed with error code $($steamProcess.ExitCode)"
Exit $steamProcess.ExitCode Exit
} }
Write-Host
# Making symbolic links to mods # Making symbolic links to mods
Write-Host "`r`nMaking symbolic links to mods:" Write-Host "Making symbolic links to mods:"
$clientMods | ForEach-Object { $clientMods | ForEach-Object {
New-Item -ItemType SymbolicLink -Path "$($serverLocation)\$($_.Item1)" -Target "$($serverLocation)\steamapps\workshop\content\$($appidGame)\$($_.Item2)" -Force New-Item -ItemType SymbolicLink -Path "$($serverLocation)\$($_.Item1)" -Target "$($serverLocation)\steamapps\workshop\content\$($appidGame)\$($_.Item2)" -Force
Copy-Item -Path "$($serverLocation)\$($_.Item1)\Keys\*.bikey" -Destination "$($serverLocation)\keys\" -Force Copy-Item -Path "$($serverLocation)\$($_.Item1)\Keys\*.bikey" -Destination "$($serverLocation)\keys\" -Force
@@ -121,54 +121,44 @@ if ($update) {
} }
Start-Sleep -Seconds 1 Start-Sleep -Seconds 1
# Patching Namalsk # # Customizing servers
$clientMods.Item1 | ForEach-Object { # # Overwriting default messages.xml from Namalsk by custom file
if ($_ -like "*namalsk*" -and $_ -like "*survival*") { # if (Test-Path -Path "$($serverLocation)\.customs") {
$namalskMission = $config.namalskMission # Copy-Item -Path "$($serverLocation)\.customs\messages.xml" -Destination "$($serverLocation)\mpmissions\$($nPath2)\db\"
if (($namalskMission -eq "regular") -or ($namalskMission -eq "hardcore")) { # }
Write-Host "`r`nCopying $($namalskMission).namalsk ..."
$nPath = "$($namalskMission)\$($namalskMission).namalsk"
$nPath2 = Split-Path -Path $nPath -Leaf
$whatFind_NI = "2288339650" Write-Host "End of updating server."
$replaceWith_NI = "2289456201"
$whatFind_NS = "2288336145"
$replaceWith_NS = "2289461232"
Copy-Item -Path "${serverLocation}\@Namalsk_Survival\Extras\${nPath}\" -Destination "${serverLocation}\mpmissions\" -Recurse -Force
Start-Sleep -Seconds 1
# Patching meta.cpp files
Write-Host "`r`nPatching Namalsk ..."
$content = Get-Content -Path "${serverLocation}\@Namalsk_Island\meta.cpp"
$content = $content -replace $whatFind_NI, $replaceWith_NI
Set-Content -Path "${serverLocation}\@Namalsk_Island\meta.cpp" -Value $content
$content = Get-Content -Path "${serverLocation}\@Namalsk_Survival\meta.cpp"
$content = $content -replace $whatFind_NS, $replaceWith_NS
Set-Content -Path "${serverLocation}\@Namalsk_Survival\meta.cpp" -Value $content
}
}
}
# Customizing servers
# Overwriting default messages.xml from Namalsk by custom file
if (Test-Path -Path "$($serverLocation)\.customs") {
Copy-Item -Path "$($serverLocation)\.customs\messages.xml" -Destination "$($serverLocation)\mpmissions\$($nPath2)\db\"
}
Write-Host "`r`nEnd of update region.`r`n"
Start-Sleep -Seconds 1 Start-Sleep -Seconds 1
} }
Write-Host
if (-not ([string]::IsNullOrEmpty($config.becFolderName))) { # Patching Namalsk
$becLocation = "$($serverLocation)\$($config.becFolderName)" [bool]$isNamalskIslandPresent = $false
# Write-Host "becLocation: $($becLocation)" [bool]$isNamalskSurvivalPresent = $false
}
if (-not ([string]::IsNullOrEmpty($config.atFolderName))) { $clientMods.Item1 | ForEach-Object {
$atFolderName = $config.atFolderName if ($_ -like "*namalsk*" -and $_ -like "*island*") {
# Write-Host "atFolderName: $($atFolderName)" $isNamalskIslandPresent = $true
$modNI = $_
Write-Host "Patching Namalsk Island server meta.cpp file ..."
$whatFind_NI = "2288339650"
$replaceWith_NI = "2289456201"
$content = Get-Content -Path "$($serverLocation)\$($modNI)\meta.cpp"
$content = $content -replace $whatFind_NI, $replaceWith_NI
Set-Content -Path "$($serverLocation)\$($modNI)\meta.cpp" -Value $content
}
if ($_ -like "*namalsk*" -and $_ -like "*survival*") {
$isNamalskSurvivalPresent = $true
$modNS = $_
Write-Host "Patching Namalsk Survival server meta.cpp file ..."
$whatFind_NS = "2288336145"
$replaceWith_NS = "2289461232"
$content = Get-Content -Path "$($serverLocation)\$($modNS)\meta.cpp"
$content = $content -replace $whatFind_NS, $replaceWith_NS
Set-Content -Path "$($serverLocation)\$($modNS)\meta.cpp" -Value $content
}
} }
Write-Host
if ($rotateLogs) { if ($rotateLogs) {
$daysAmount = [Math]::Abs($config.daysAmount) $daysAmount = [Math]::Abs($config.daysAmount)
@@ -177,6 +167,14 @@ if ($rotateLogs) {
} }
} }
if (-not ([string]::IsNullOrEmpty($config.becFolderName))) {
$becLocation = "$($serverLocation)\$($config.becFolderName)"
}
if (-not ([string]::IsNullOrEmpty($config.atFolderName))) {
$atFolderName = $config.atFolderName
}
$servers += $ini.Keys.Where({ $_ -Match "^[Ss]erver[\s_-]?[0-9]+$" }) $servers += $ini.Keys.Where({ $_ -Match "^[Ss]erver[\s_-]?[0-9]+$" })
$processID = 0 $processID = 0
@@ -185,7 +183,6 @@ $becProcess = [Object[]]::new($servers.Count)
$dayzArguments = @() $dayzArguments = @()
foreach ($srv in $servers) { foreach ($srv in $servers) {
# Write-Host ":$($srv):"
$instance = ${srv} $instance = ${srv}
$serverPort = $ini.${srv}.serverPort $serverPort = $ini.${srv}.serverPort
$serverConfig = $ini.${srv}.serverConfig $serverConfig = $ini.${srv}.serverConfig
@@ -193,11 +190,29 @@ foreach ($srv in $servers) {
$serverCPU = $ini.${srv}.serverCPU $serverCPU = $ini.${srv}.serverCPU
$startupClientMods = $ini.${srv}.startupClientMods $startupClientMods = $ini.${srv}.startupClientMods
$startupServerMods = $ini.${srv}.startupServerMods $startupServerMods = $ini.${srv}.startupServerMods
$additionalParams = $ini.${srv}.additionalParams
$cm = $startupClientMods -Split ';'
if ($cm -contains $modNS) {
$namalskMission = $ini.${srv}.namalskMission
if (($namalskMission -eq "regular") -or ($namalskMission -eq "hardcore")) {
$pathNamalskMission = "$($namalskMission)\$($namalskMission).namalsk"
$namalskMission += ".namalsk"
if (-not (Test-Path -Path "$($serverLocation)\mpmissions\$($namalskMission)\")) {
Write-Host "Copying $($namalskMission)..."
Copy-Item -Path "$($serverLocation)\$($modNS)\Extras\$($pathNamalskMission)\" -Destination "$($serverLocation)\mpmissions\" -Recurse -Force
Start-Sleep -Seconds 1
}
}
else {
Write-Error "Error in Namalsk mission definition: '$($namalskMission)'"
Exit
}
}
$serverProfile = "$($serverLocation)\profiles\$($instance)" $serverProfile = "$($serverLocation)\profiles\$($instance)"
$startupMods = @("`"-mod=$($startupClientMods)`"", "`"-serverMod=$($startupServerMods)`"") $startupMods = @("`"-mod=$($startupClientMods)`"", "`"-serverMod=$($startupServerMods)`"")
$startupParams = @("`"-profiles=$($serverProfile)`"", "`"-config=$($serverProfile)\$($serverConfig)`"", "-port=$($serverPort)", "-name=Server") $startupParams = @("`"-profiles=$($serverProfile)`"", "`"-config=$($serverProfile)\$($serverConfig)`"", "-port=$($serverPort)", "-cpuCount=$($serverCPU)")
$additionalParams = @("-cpuCount=$($serverCPU)", "-adminLog -filePatching")
$dayzArguments = $startupParams + $startupMods + $additionalParams $dayzArguments = $startupParams + $startupMods + $additionalParams
$dayz = "`"$($serverLocation)\$($serverExeName)`"" $dayz = "`"$($serverLocation)\$($serverExeName)`""
$bec = "`"$($becLocation)\bec.exe`"" $bec = "`"$($becLocation)\bec.exe`""
@@ -211,7 +226,7 @@ foreach ($srv in $servers) {
$logsName = Get-ChildItem -Path $atLogsLocation -Directory -Filter "Log*" $logsName = Get-ChildItem -Path $atLogsLocation -Directory -Filter "Log*"
$atLogsLocation += '\' + $logsName $atLogsLocation += '\' + $logsName
} }
if ($becLocation) { if ($becLocation) {
$becLogsLocation = "$($becLocation)\Log\$($instance)" $becLogsLocation = "$($becLocation)\Log\$($instance)"
} }
@@ -224,17 +239,12 @@ foreach ($srv in $servers) {
New-Item -ItemType Directory -Path $rotatedLogsLocation | Out-Null New-Item -ItemType Directory -Path $rotatedLogsLocation | Out-Null
Write-Host "Created new folder: $($rotatedLogsLocation)" Write-Host "Created new folder: $($rotatedLogsLocation)"
} }
$fileList = $null $fileList = $null
$destDelDir = "$($rotatedLogsLocation)\DeletedLogs" $destDelDir = "$($rotatedLogsLocation)\DeletedLogs"
$becDestDir = "$($rotatedLogsLocation)\BEC" $becDestDir = "$($rotatedLogsLocation)\BEC"
$atDestDir = "$($rotatedLogsLocation)\$($atFolderName)" $atDestDir = "$($rotatedLogsLocation)\$($atFolderName)"
# Write-Host "destDelDir: $($destDelDir)"
# Write-Host "becDestDir: $($becDestDir)"
# Write-Host " atDestDir: $($atDestDir)"
# Write-Host "----------"
#region ### DayZ Game ### #region ### DayZ Game ###
Write-Host "Rotating DAYZ logs..." Write-Host "Rotating DAYZ logs..."
$fileList = Get-Item -Path $serverProfile\*.rpt, $serverProfile\*.log, $serverProfile\*.adm, $serverProfile\*.mdmp | Where-Object { $_.LastWriteTime.Date -lt $date.Date } $fileList = Get-Item -Path $serverProfile\*.rpt, $serverProfile\*.log, $serverProfile\*.adm, $serverProfile\*.mdmp | Where-Object { $_.LastWriteTime.Date -lt $date.Date }
@@ -247,7 +257,7 @@ foreach ($srv in $servers) {
} }
Write-Host "Total: $($fileList.Count)" Write-Host "Total: $($fileList.Count)"
$fileList = Get-Item -Path $rotatedLogsLocation\*.rpt, $rotatedLogsLocation\*.log, $rotatedLogsLocation\*.adm, $rotatedLogsLocation\*.mdmp | Where-Object { $_.LastWriteTime -lt $date.AddDays(-($daysAmount)) } $fileList = Get-Item -Path $rotatedLogsLocation\*.rpt, $rotatedLogsLocation\*.log, $rotatedLogsLocation\*.adm, $rotatedLogsLocation\*.mdmp | Where-Object { $_.LastWriteTime -lt $date.AddDays( - ($daysAmount)) }
# Write-Host $fileList -Separator "`n" # Write-Host $fileList -Separator "`n"
Write-Host "Removing logs:" Write-Host "Removing logs:"
@@ -256,12 +266,13 @@ foreach ($srv in $servers) {
New-Item -ItemType Directory -Path $destDelDir | Out-Null New-Item -ItemType Directory -Path $destDelDir | Out-Null
Write-Host "Created new folder: $($destDelDir)" Write-Host "Created new folder: $($destDelDir)"
} }
foreach ($file in $fileList) { foreach ($file in $fileList) {
Move-Item -Path $file -Destination $destDelDir -Force Move-Item -Path $file -Destination $destDelDir -Force
Write-Host "Moved $($file) to $($destDelDir)" Write-Host "Moved $($file) to $($destDelDir)"
} }
} else { }
else {
foreach ($file in $fileList) { foreach ($file in $fileList) {
Remove-Item -Path $file Remove-Item -Path $file
Write-Host "Removed $($file)!" Write-Host "Removed $($file)!"
@@ -291,21 +302,22 @@ foreach ($srv in $servers) {
} }
Write-Host "Total: $($fileList.Count)" Write-Host "Total: $($fileList.Count)"
$fileList = Get-Item -Path $becDestDir\*.log | Where-Object { $_.LastWriteTime -lt $date.AddDays(-($daysAmount)) } $fileList = Get-Item -Path $becDestDir\*.log | Where-Object { $_.LastWriteTime -lt $date.AddDays( - ($daysAmount)) }
# Write-Host $fileList -Separator "`n" # Write-Host $fileList -Separator "`n"
Write-Host "Removing BEC's LOGs:" Write-Host "Removing BEC's LOGs:"
if ($noDelete) { if ($noDelete) {
If (!(Test-Path -PathType Container $destDelDir)) { If (!(Test-Path -PathType Container $destDelDir)) {
New-Item -ItemType Directory -Path $destDelDir | Out-Null New-Item -ItemType Directory -Path $destDelDir | Out-Null
Write-Host "Created new folder: $($destDelDir)" Write-Host "Created new folder: $($destDelDir)"
} }
foreach ($file in $fileList) { foreach ($file in $fileList) {
Move-Item -Path $file -Destination $destDelDir Move-Item -Path $file -Destination $destDelDir
Write-Host "Moved $($file) to $($destDelDir)" Write-Host "Moved $($file) to $($destDelDir)"
} }
} else { }
else {
foreach ($file in $fileList) { foreach ($file in $fileList) {
Remove-Item -Path $file Remove-Item -Path $file
Write-Host "Removed $($file)!" Write-Host "Removed $($file)!"
@@ -325,7 +337,7 @@ foreach ($srv in $servers) {
New-Item -ItemType Directory -Path $atDestDir | Out-Null New-Item -ItemType Directory -Path $atDestDir | Out-Null
Write-Host "Created new folder: $($atDestDir)" Write-Host "Created new folder: $($atDestDir)"
} }
$fileList = Get-ChildItem -Path $atLogsLocation\*.txt, $atLogsLocation\*.log -Recurse | Where-Object { $_.LastWriteTime.Date -lt $date.Date } $fileList = Get-ChildItem -Path $atLogsLocation\*.txt, $atLogsLocation\*.log -Recurse | Where-Object { $_.LastWriteTime.Date -lt $date.Date }
# Write-Host $fileList -Separator "`n" # Write-Host $fileList -Separator "`n"
@@ -336,9 +348,9 @@ foreach ($srv in $servers) {
} }
Write-Host "Total: $($fileList.Count)" Write-Host "Total: $($fileList.Count)"
$fileList = Get-Item -Path $atDestDir\*.txt, $atDestDir\*.log | Where-Object { $_.LastWriteTime -lt $date.AddDays(-($daysAmount)) } $fileList = Get-Item -Path $atDestDir\*.txt, $atDestDir\*.log | Where-Object { $_.LastWriteTime -lt $date.AddDays( - ($daysAmount)) }
# Write-Host $fileList -Separator "`n" # Write-Host $fileList -Separator "`n"
Write-Host "Removing AdminTool's LOGs:" Write-Host "Removing AdminTool's LOGs:"
if ($noDelete) { if ($noDelete) {
If (!(Test-Path -PathType Container $destDelDir)) { If (!(Test-Path -PathType Container $destDelDir)) {
@@ -347,10 +359,11 @@ foreach ($srv in $servers) {
} }
foreach ($file in $fileList) { foreach ($file in $fileList) {
Move-Item -Path $file -Destination $destDelDir -Force Move-Item -Path $file -Destination $destDelDir -Force
Write-Host "Moved $($file) to $($destDelDir)" Write-Host "Moved $($file) to $($destDelDir)"
} }
} else { }
else {
foreach ($file in $fileList) { foreach ($file in $fileList) {
Remove-Item -Path $file Remove-Item -Path $file
Write-Host "Removed $($file)!" Write-Host "Removed $($file)!"
@@ -373,6 +386,8 @@ foreach ($srv in $servers) {
# Write-Host " startupMods: $($startupMods)" # Write-Host " startupMods: $($startupMods)"
# Write-Host " startupParams: $($startupParams)" # Write-Host " startupParams: $($startupParams)"
# Write-Host " additionalParams: $($additionalParams)" # Write-Host " additionalParams: $($additionalParams)"
# Write-Host " pathNamalskMission: $($pathNamalskMission)"
# Write-Host " namalskMission: $($namalskMission)"
# Write-Host # Write-Host
# Write-Host " dayz: $($dayz)" # Write-Host " dayz: $($dayz)"
# Write-Host " dayzArguments: $($dayzArguments)" # Write-Host " dayzArguments: $($dayzArguments)"
@@ -381,27 +396,33 @@ foreach ($srv in $servers) {
# Write-Host " bec: $($bec)" # Write-Host " bec: $($bec)"
# Write-Host " becArguments: $($becArguments)" # Write-Host " becArguments: $($becArguments)"
# Write-Host # Write-Host
# Write-Host " atFolderName: $($atFolderName)"
# Write-Host
# Write-Host " atLogsLocation: $($atLogsLocation)" # Write-Host " atLogsLocation: $($atLogsLocation)"
# Write-Host " becLogsLocation: $($becLogsLocation)" # Write-Host " becLogsLocation: $($becLogsLocation)"
# Write-Host # Write-Host
# Write-Host " rotateLogs: $($rotateLogs)" # Write-Host " rotateLogs: $($rotateLogs)"
# Write-Host " destDelDir: $($destDelDir)"
# Write-Host " becDestDir: $($becDestDir)"
# Write-Host " atDestDir: $($atDestDir)"
# Write-Host
# Write-Host "rotatedLogsFolderName: $($rotatedLogsFolderName)" # Write-Host "rotatedLogsFolderName: $($rotatedLogsFolderName)"
# Write-Host " rotatedLogsLocation: $($rotatedLogsLocation)" # Write-Host " rotatedLogsLocation: $($rotatedLogsLocation)"
# Write-Host " daysAmount: $($daysAmount)" # Write-Host " daysAmount: $($daysAmount)"
# Write-Host " noDelete: $($noDelete)" # Write-Host " noDelete: $($noDelete)"
# Starting servers # # Starting servers
Set-Location -Path "$($serverLocation)" # Set-Location -Path "$($serverLocation)"
$dayzProcess[$processID] = Start-Process -FilePath $dayz -ArgumentList $dayzArguments -PassThru # $dayzProcess[$processID] = Start-Process -FilePath $dayz -ArgumentList $dayzArguments -PassThru
$dayzProcess[$processID] # $dayzProcess[$processID]
if ($becLocation) { # if ($becLocation) {
Set-Location -Path "$($becLocation)" # Set-Location -Path "$($becLocation)"
$becProcess[$processID] = Start-Process -FilePath $bec -ArgumentList $becArguments -PassThru # $becProcess[$processID] = Start-Process -FilePath $bec -ArgumentList $becArguments -PassThru
$becProcess[$processID] # $becProcess[$processID]
} # }
$processID++ $processID++
} }
# Start-Sleep -Seconds 5
Write-Host "==========" Write-Host "=========="

16
wDayzManager.txt Normal file
View File

@@ -0,0 +1,16 @@
// wDayzManager.txt - Steam script
@NoPromptForPassword 1
@ShutdownOnFailedCommand 1
force_install_dir "D:\DayZ\Server"
login w0lf_2k
app_update 223350 validate
workshop_download_item 221100 2731398623 validate
workshop_download_item 221100 1559212036 validate
workshop_download_item 221100 1564026768 validate
workshop_download_item 221100 1828439124 validate
workshop_download_item 221100 1623711988 validate
workshop_download_item 221100 2288339650 validate
workshop_download_item 221100 2288336145 validate
workshop_download_item 221100 2561482171 validate
workshop_download_item 221100 1988925918 validate
quit