|
|
|
|
@@ -1,4 +1,4 @@
|
|
|
|
|
# wDayzManager v0.7
|
|
|
|
|
# wDayzManager v0.8
|
|
|
|
|
# Copyright (c) 2024 Vladislav Salikov aka W0LF aka 'dreamforce'
|
|
|
|
|
# https://github.com/dreamforceinc
|
|
|
|
|
# Required module: PSIni
|
|
|
|
|
@@ -22,12 +22,18 @@ Param (
|
|
|
|
|
################################################################ [ !!! DON'T EDIT BELOW !!! ] #################################################################
|
|
|
|
|
|
|
|
|
|
[string]$myName = "wDayzManager"
|
|
|
|
|
[string]$myVersion = "v0.7"
|
|
|
|
|
[string]$steamScript = $myName + ".txt"
|
|
|
|
|
[string]$myVersion = "v0.8"
|
|
|
|
|
[string]$iniFile = $myName + ".ini"
|
|
|
|
|
if (-not (Test-Path -Path $iniFile)) {
|
|
|
|
|
Write-Warning "Can't find file '$iniFile', creating new..."
|
|
|
|
|
[string]$steamScript = $myName + ".txt"
|
|
|
|
|
|
|
|
|
|
if (($init -eq $true) -and ($update -eq $true)) {
|
|
|
|
|
Write-Error "Only one parameter is accepted - either 'Init' or 'Update'."
|
|
|
|
|
Exit
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Init {
|
|
|
|
|
New-Item -ItemType File -Path $iniFile -Value "; $($iniFile)" | Out-Null
|
|
|
|
|
if (!$?) { Exit }
|
|
|
|
|
$content = "
|
|
|
|
|
[Config]
|
|
|
|
|
serverLocation=Z:\Servers\DayzServer
|
|
|
|
|
@@ -82,11 +88,17 @@ startupServerMods=
|
|
|
|
|
additionalParams= -name=Server -AdminLog -FilePatching
|
|
|
|
|
namalskMission=
|
|
|
|
|
"
|
|
|
|
|
Add-Content -Path $iniFile -Value $content -Encoding UTF8
|
|
|
|
|
Add-Content -Path $iniFile -Value $content -Encoding ASCII
|
|
|
|
|
$content = $null
|
|
|
|
|
Exit
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($init) { Init ; Exit }
|
|
|
|
|
if (-not (Test-Path -Path $iniFile)) {
|
|
|
|
|
Write-Warning "Can't find file '$iniFile'. You probably need to run the bat-script with the '/I' parameter."
|
|
|
|
|
Exit
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$date = Get-Date
|
|
|
|
|
[int]$currentDayOfWeek = ([datetime]$date).DayOfWeek
|
|
|
|
|
[int]$currentDay = ([datetime]$date).Day
|
|
|
|
|
@@ -121,14 +133,6 @@ $config = $ini.Config
|
|
|
|
|
[string]$updatePeriod = $config.updatePeriod
|
|
|
|
|
[bool]$rotateLogs = [int]$config.rotateLogs
|
|
|
|
|
|
|
|
|
|
function Init {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Update {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$clientMods = New-Object 'Collections.Generic.List[Tuple[string,string]]'
|
|
|
|
|
foreach ($mod in $ini.ClientMods.GetEnumerator()) {
|
|
|
|
|
if ($mod.Key -notlike "Comment*" ) {
|
|
|
|
|
@@ -143,15 +147,19 @@ foreach ($mod in $ini.ServerMods.GetEnumerator()) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Update {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch ($updatePeriod) {
|
|
|
|
|
D { if ($currentHour -eq $updateHour) { $update = $true } }
|
|
|
|
|
W { if (($currentDayOfWeek -eq $updateDay) -and ($currentHour -eq $updateHour)) { $update = $true } }
|
|
|
|
|
M { if (($currentDay -eq $updateDay) -and ($currentHour -eq $updateHour)) { $update = $true } }
|
|
|
|
|
Default { $update = $param }
|
|
|
|
|
default { $update = $false }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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!"
|
|
|
|
|
Exit
|
|
|
|
|
}
|
|
|
|
|
@@ -175,8 +183,8 @@ if ($update) {
|
|
|
|
|
$arr += "quit"
|
|
|
|
|
|
|
|
|
|
# Saving Steam script
|
|
|
|
|
"// $($steamScript) - Steam script" | Out-File -FilePath "$($currentPath)\$($steamScript)" -Encoding Ascii
|
|
|
|
|
$arr | Out-File -FilePath "$($currentPath)\$($steamScript)" -Encoding Ascii -Append
|
|
|
|
|
"// $($steamScript) - Steam script" | Out-File -FilePath "$($currentPath)\$($steamScript)" -Encoding ASCII
|
|
|
|
|
$arr | Out-File -FilePath "$($currentPath)\$($steamScript)" -Encoding ASCII -Append
|
|
|
|
|
|
|
|
|
|
# Run Steam script
|
|
|
|
|
Write-Host "Run Steam script from `"$($currentPath)\$($steamScript)`""
|
|
|
|
|
@@ -370,14 +378,14 @@ foreach ($srv in $servers) {
|
|
|
|
|
$atLogsLocation += '\' + $logsName
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
If (!(Test-Path -PathType Container $rotatedLogsLocation)) {
|
|
|
|
|
If (-not (Test-Path -PathType Container $rotatedLogsLocation)) {
|
|
|
|
|
New-Item -ItemType Directory -Path $rotatedLogsLocation | Out-Null
|
|
|
|
|
Write-Host "Created new folder: $($rotatedLogsLocation)"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($noDelete) {
|
|
|
|
|
$destDelDir = "$($rotatedLogsLocation)\DeletedLogs"
|
|
|
|
|
If (!(Test-Path -PathType Container $destDelDir)) {
|
|
|
|
|
If (-not (Test-Path -PathType Container $destDelDir)) {
|
|
|
|
|
New-Item -ItemType Directory -Path $destDelDir | Out-Null
|
|
|
|
|
Write-Host "Created new folder: $($destDelDir)"
|
|
|
|
|
}
|
|
|
|
|
@@ -418,7 +426,7 @@ foreach ($srv in $servers) {
|
|
|
|
|
if ($becLocation) {
|
|
|
|
|
$becDestDir = "$($rotatedLogsLocation)\$($becFolderName)"
|
|
|
|
|
|
|
|
|
|
If (!(Test-Path -PathType Container $becDestDir)) {
|
|
|
|
|
If (-not (Test-Path -PathType Container $becDestDir)) {
|
|
|
|
|
New-Item -ItemType Directory -Path $becDestDir | Out-Null
|
|
|
|
|
Write-Host "Created new folder: $($becDestDir)"
|
|
|
|
|
}
|
|
|
|
|
@@ -458,7 +466,7 @@ foreach ($srv in $servers) {
|
|
|
|
|
if ($atLogsLocation) {
|
|
|
|
|
$atDestDir = "$($rotatedLogsLocation)\$($atFolderName)"
|
|
|
|
|
|
|
|
|
|
If (!(Test-Path -PathType Container $atDestDir)) {
|
|
|
|
|
If (-not (Test-Path -PathType Container $atDestDir)) {
|
|
|
|
|
New-Item -ItemType Directory -Path $atDestDir | Out-Null
|
|
|
|
|
Write-Host "Created new folder: $($atDestDir)"
|
|
|
|
|
}
|
|
|
|
|
|