|
|
|
@@ -1,4 +1,4 @@
|
|
|
|
# wDayzManager v0.8
|
|
|
|
# wDayzManager v0.9
|
|
|
|
# Copyright (c) 2024 Vladislav Salikov aka W0LF aka 'dreamforce'
|
|
|
|
# Copyright (c) 2024 Vladislav Salikov aka W0LF aka 'dreamforce'
|
|
|
|
# https://github.com/dreamforceinc
|
|
|
|
# https://github.com/dreamforceinc
|
|
|
|
# Required module: PSIni
|
|
|
|
# Required module: PSIni
|
|
|
|
@@ -22,9 +22,10 @@ Param (
|
|
|
|
################################################################ [ !!! DON'T EDIT BELOW !!! ] #################################################################
|
|
|
|
################################################################ [ !!! DON'T EDIT BELOW !!! ] #################################################################
|
|
|
|
|
|
|
|
|
|
|
|
[string]$myName = "wDayzManager"
|
|
|
|
[string]$myName = "wDayzManager"
|
|
|
|
[string]$myVersion = "v0.8"
|
|
|
|
[string]$myVersion = "v0.9"
|
|
|
|
[string]$iniFile = $myName + ".ini"
|
|
|
|
[string]$iniFile = $myName + ".ini"
|
|
|
|
[string]$steamScript = $myName + ".txt"
|
|
|
|
[string]$steamScript = $myName + ".txt"
|
|
|
|
|
|
|
|
$Error.Clear()
|
|
|
|
|
|
|
|
|
|
|
|
if (($init -eq $true) -and ($update -eq $true)) {
|
|
|
|
if (($init -eq $true) -and ($update -eq $true)) {
|
|
|
|
Write-Error "Only one parameter is accepted - either 'Init' or 'Update'."
|
|
|
|
Write-Error "Only one parameter is accepted - either 'Init' or 'Update'."
|
|
|
|
@@ -106,7 +107,6 @@ $date = Get-Date
|
|
|
|
|
|
|
|
|
|
|
|
$date2 = Get-Date -Format 's' | ForEach-Object { $_ -replace 'T', ' ' }
|
|
|
|
$date2 = Get-Date -Format 's' | ForEach-Object { $_ -replace 'T', ' ' }
|
|
|
|
Write-Host "$($date2) Starting $($myName) $($myVersion) script"
|
|
|
|
Write-Host "$($date2) Starting $($myName) $($myVersion) script"
|
|
|
|
Write-Host "init = $($init), update = $($update), noDelete = $($noDelete)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ini = $config = $servers = $clientMods = $serverMods = $steamProcess = $null
|
|
|
|
$ini = $config = $servers = $clientMods = $serverMods = $steamProcess = $null
|
|
|
|
$modNI = $modNS = $namalskMission = $pathNamalskMission = $null
|
|
|
|
$modNI = $modNS = $namalskMission = $pathNamalskMission = $null
|
|
|
|
@@ -147,10 +147,6 @@ foreach ($mod in $ini.ServerMods.GetEnumerator()) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function Update {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch ($updatePeriod) {
|
|
|
|
switch ($updatePeriod) {
|
|
|
|
D { if ($currentHour -eq $updateHour) { $update = $true } }
|
|
|
|
D { if ($currentHour -eq $updateHour) { $update = $true } }
|
|
|
|
W { if (($currentDayOfWeek -eq $updateDay) -and ($currentHour -eq $updateHour)) { $update = $true } }
|
|
|
|
W { if (($currentDayOfWeek -eq $updateDay) -and ($currentHour -eq $updateHour)) { $update = $true } }
|
|
|
|
@@ -158,6 +154,8 @@ switch ($updatePeriod) {
|
|
|
|
default { $update = $false }
|
|
|
|
default { $update = $false }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Write-Host "Init = $($init), Update = $($update), noDelete = $($noDelete)"
|
|
|
|
|
|
|
|
|
|
|
|
if ($update) {
|
|
|
|
if ($update) {
|
|
|
|
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
|
|
|
|
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!"
|
|
|
|
Write-Warning "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!"
|
|
|
|
@@ -252,7 +250,7 @@ if ($rotateLogs) {
|
|
|
|
|
|
|
|
|
|
|
|
Write-Host "Removing old wDayzManager logs..."
|
|
|
|
Write-Host "Removing old wDayzManager logs..."
|
|
|
|
$fileList = $null
|
|
|
|
$fileList = $null
|
|
|
|
$fileList = Get-ChildItem -Path $currentPath\Logs\*.log -Recurse | Where-Object { $_.LastWriteTime.Date -lt $date.AddDays( -3) }
|
|
|
|
$fileList = Get-ChildItem -Path $currentPath\Logs\*.log -Recurse | Where-Object { $_.LastWriteTime.Date -lt $date.AddDays( -2) }
|
|
|
|
# Write-Host $fileList -Separator "`n"
|
|
|
|
# Write-Host $fileList -Separator "`n"
|
|
|
|
foreach ($file in $fileList) {
|
|
|
|
foreach ($file in $fileList) {
|
|
|
|
Remove-Item -Path $file
|
|
|
|
Remove-Item -Path $file
|
|
|
|
@@ -278,6 +276,7 @@ if (-not ([string]::IsNullOrEmpty($becLocation))) {
|
|
|
|
if (-not (Test-Path -Path "$($becLocation)\")) {
|
|
|
|
if (-not (Test-Path -Path "$($becLocation)\")) {
|
|
|
|
New-Item -ItemType Directory -Path "$($becLocation)\" | Out-Null
|
|
|
|
New-Item -ItemType Directory -Path "$($becLocation)\" | Out-Null
|
|
|
|
New-Item -ItemType Directory -Path "$($becLocation)\Config\" | Out-Null
|
|
|
|
New-Item -ItemType Directory -Path "$($becLocation)\Config\" | Out-Null
|
|
|
|
|
|
|
|
New-Item -ItemType Directory -Path "$($becLocation)\Log\" | Out-Null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -354,10 +353,26 @@ foreach ($srv in $servers) {
|
|
|
|
Exit
|
|
|
|
Exit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (-not (Test-Path -Path "$($serverProfile)\BattlEye\")) {
|
|
|
|
|
|
|
|
Write-Host "Creating new folder: `"$($serverProfile)\BattlEye\`""
|
|
|
|
|
|
|
|
New-Item -ItemType Directory -Path "$($serverProfile)\BattlEye\" | Out-Null
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (-not (Test-Path -Path "$($serverProfile)\BattlEye\bans.txt")) {
|
|
|
|
if (-not (Test-Path -Path "$($serverProfile)\BattlEye\bans.txt")) {
|
|
|
|
|
|
|
|
Write-Host "Copying file from `"$($serverLocation)\ban.txt`" to `"$($serverProfile)\BattlEye\bans.txt`""
|
|
|
|
Copy-Item -Path "$($serverLocation)\ban.txt" -Destination "$($serverProfile)\BattlEye\bans.txt" -ErrorAction Stop
|
|
|
|
Copy-Item -Path "$($serverLocation)\ban.txt" -Destination "$($serverProfile)\BattlEye\bans.txt" -ErrorAction Stop
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (-not (Test-Path -Path "$($serverProfile)\BattlEye\BEServer_x64*.cfg")) {
|
|
|
|
|
|
|
|
Write-Host "Creating new file: `"$($serverProfile)\BattlEye\BEServer_x64.cfg`""
|
|
|
|
|
|
|
|
New-Item -ItemType File -Path "$($serverProfile)\BattlEye\BEServer_x64.cfg" | Out-Null
|
|
|
|
|
|
|
|
if (!$?) { Exit }
|
|
|
|
|
|
|
|
[int]$rconPort = [int]$serverPort + 5
|
|
|
|
|
|
|
|
$content = "RConPassword ChangeMe123`r`nRConPort $($rconPort)`r`nRestrictRCon 0"
|
|
|
|
|
|
|
|
Add-Content -Path "$($serverProfile)\BattlEye\BEServer_x64.cfg" -Value $content -Encoding ASCII
|
|
|
|
|
|
|
|
$content = $null
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$bec = "`"$($becLocation)\bec.exe`""
|
|
|
|
$bec = "`"$($becLocation)\bec.exe`""
|
|
|
|
$becArguments = "-f `"$($instance).cfg`" --dsc"
|
|
|
|
$becArguments = "-f `"$($instance).cfg`" --dsc"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|