mirror of
https://github.com/dreamforceinc/wDayzLogRotation.git
synced 2025-12-12 19:22:37 +03:00
Updated scripts.
This commit is contained in:
100
Start-Test-Server.bat
Normal file
100
Start-Test-Server.bat
Normal file
@@ -0,0 +1,100 @@
|
||||
@echo off
|
||||
:: Start-Test-Server v0.3
|
||||
:: Copyright (c) 2024 Vladislav Salikov aka W0LF aka 'dreamforce'
|
||||
:: https://github.com/dreamforceinc
|
||||
|
||||
:: !!! Needs 'DAYZSERVER' envvar defined !!!
|
||||
:: !!! Example: SETX DAYZSERVER Z:\Servers\DayZServer
|
||||
|
||||
::Server name
|
||||
set serverName=RU11 Test Server
|
||||
::Server files location. Required!
|
||||
set serverLocation=%DAYZSERVER%
|
||||
::Server profile location
|
||||
set serverProfile=Instance_0
|
||||
::Server Port
|
||||
set serverPort=2302
|
||||
::Logical CPU cores to use (Equal or less than available)
|
||||
set serverCPU=2
|
||||
::Server config
|
||||
set serverConfig=serverDZ.cfg
|
||||
::Server mods
|
||||
set serverMods=
|
||||
::Client mods
|
||||
set clientMods=@CF;@VPPadminTools;@VanillaPlusPlusMap
|
||||
::Startup parameters
|
||||
set startupParams=-profiles=profiles\%serverProfile% -config=profiles\%serverProfile%\%serverConfig% -name=Server -port=%serverPort%
|
||||
::Additional Startup parameters
|
||||
set additionalParams=-cpuCount=%serverCPU% -adminLog
|
||||
::Path to log rotation script
|
||||
set scriptLocation=%serverLocation%\wDayzLogRotation.ps1
|
||||
::Path to store rotated logs. Required!
|
||||
set rotatedLogsLocation=%serverLocation%\.RotatedLogs\%serverProfile%
|
||||
::BEC location. Optional. Leave it blank if you don't use BEC.
|
||||
set becLocation=%serverLocation%\BEC
|
||||
::AdminTool's logs location. Optional. Leave it blank if you don't use any admin tool.
|
||||
set adminToolLogsLocation=%serverLocation%\profiles\%serverProfile%\VPPadminTools\Logging
|
||||
|
||||
|
||||
|
||||
::
|
||||
:: !!! (DON'T EDIT BELOW) !!!
|
||||
::
|
||||
if not defined serverLocation (
|
||||
echo.
|
||||
echo ERROR !!!
|
||||
echo Environment variable DAYZSERVER is not defined!
|
||||
echo You MUST define it before calling this batch script
|
||||
echo by command 'SETX DAYZSERVER "drive:\path\to\server"'
|
||||
goto _exit
|
||||
)
|
||||
if not defined rotatedLogsLocation (
|
||||
echo.
|
||||
echo ERROR !!!
|
||||
echo You MUST provide 'rotatedLogsLocation' variable!
|
||||
goto _exit
|
||||
)
|
||||
|
||||
::Sets title for terminal
|
||||
title %serverName% batch
|
||||
set CWD=%CD%
|
||||
cd /d "%serverLocation%"
|
||||
|
||||
::Prepare commandline
|
||||
if defined serverMods set tsm="-serverMod=%serverMods%"
|
||||
if defined clientMods set tcm="-mod=%clientMods%"
|
||||
set allMods=%tsm% %tcm%
|
||||
set cmdLine="DayZServer_x64.exe" %startupParams% %additionalParams% %allMods%
|
||||
|
||||
::BEC's logs location
|
||||
if defined becLocation (
|
||||
set becLogsLocation=%becLocation%\Log\%serverProfile%
|
||||
) else (
|
||||
set becLogsLocation=
|
||||
)
|
||||
|
||||
:: Debug output ::
|
||||
@REM echo serverLocation = '%serverLocation%'
|
||||
@REM echo rotatedLogsLocation = '%rotatedLogsLocation%'
|
||||
@REM echo becLocation = '%becLocation%'
|
||||
@REM echo adminToolLogsLocation = '%adminToolLogsLocation%'
|
||||
@REM echo.
|
||||
|
||||
::Start log rotation
|
||||
powershell.exe -File "%scriptLocation%" -Server "%serverLocation%" -Instance "%serverLocation%\%serverProfile%" -RotatedLogs "%rotatedLogsLocation%" -BecLogs "%becLogsLocation%" -ATLogs "%adminToolLogsLocation%"
|
||||
timeout 5 /nobreak >nul
|
||||
echo.
|
||||
|
||||
::Start DayZServer
|
||||
start "DayZ %serverProfile%" /high %cmdLine%
|
||||
echo.
|
||||
|
||||
::Start BEC
|
||||
if defined becLocation (
|
||||
cd /d "%becLocation%"
|
||||
start "BEC %serverProfile%" "%becLocation%\Bec.exe" -f %serverProfile%.cfg --dsc
|
||||
echo.
|
||||
)
|
||||
|
||||
:_exit
|
||||
cd /d "%CWD%"
|
||||
@@ -1,72 +0,0 @@
|
||||
@echo off
|
||||
:: !!! Needs 'DAYZSERVERSLOCATION' envvar defined !!!
|
||||
:: !!! setx DAYZSERVERSLOCATION Z:\Servers\DayZServer [/m]
|
||||
|
||||
::Server name
|
||||
set serverName=RU11 Test Server
|
||||
::Server files location
|
||||
set serverLocation=%DAYZSERVERSLOCATION%
|
||||
::Server profile location
|
||||
set serverProfile=Instance_4
|
||||
::Server Port
|
||||
set serverPort=35400
|
||||
::Logical CPU cores to use (Equal or less than available)
|
||||
set serverCPU=2
|
||||
::Server config
|
||||
set serverConfig=serverDZ.cfg
|
||||
::Server mods
|
||||
set serverMods=
|
||||
::Client mods
|
||||
set clientMods=@CF;@VPPadminTools;@VanillaPlusPlusMap;@KAMAZ
|
||||
::Startup parameters
|
||||
set startupParams=-profiles=%serverProfile% -config=%serverProfile%\%serverConfig% -name=Server -port=%serverPort%
|
||||
::Additional Startup parameters
|
||||
set additionalParams=-cpuCount=%serverCPU% -adminLog
|
||||
::Path to log rotation script
|
||||
set scriptLocation=D:\Sync\SRC\PowerShell\wDayzLogRotation\wDayzLogRotation.ps1
|
||||
@REM set scriptLocation=%serverLocation%\wDayzLogRotation.ps1
|
||||
::BEC location
|
||||
set becLocation=%serverLocation%\BEC
|
||||
@REM set becLocation=
|
||||
::AdminTool's logs location
|
||||
set adminToolLogsLocation=%serverLocation%\%serverProfile%\VPPadminTools\Logging
|
||||
@REM set adminToolLogsLocation=
|
||||
|
||||
|
||||
:: !!! (DON'T EDIT BELOW) !!!
|
||||
::Sets title for terminal
|
||||
title %serverName% batch
|
||||
set cwd=%CD%
|
||||
cd /d "%serverLocation%"
|
||||
|
||||
::Prepare commandline
|
||||
if defined serverMods set tsm="-serverMod=%serverMods%"
|
||||
if defined clientMods set tcm="-mod=%clientMods%"
|
||||
set allMods=%tsm% %tcm%
|
||||
set cmdLine="DayZServer_x64.exe" %startupParams% %additionalParams% %allMods%
|
||||
|
||||
::BEC's logs location
|
||||
if defined becLocation (
|
||||
set becLogsLocation=%becLocation%\Log\%serverProfile%
|
||||
) else (
|
||||
set becLogsLocation=
|
||||
)
|
||||
|
||||
::Start log rotation
|
||||
powershell.exe -File "%scriptLocation%" "%serverLocation%" "%serverLocation%\%serverProfile%" "%becLogsLocation%" "%adminToolLogsLocation%"
|
||||
|
||||
goto _exit
|
||||
|
||||
timeout 3 /nobreak >nul
|
||||
echo.
|
||||
|
||||
::Start DayZServer
|
||||
start "DayZ %serverProfile%" /high %cmdLine%
|
||||
|
||||
::Start BEC
|
||||
cd /d "%becLocation%"
|
||||
start "BEC %serverProfile%" "%becLocation%\Bec.exe" -f %serverProfile%.cfg --dsc
|
||||
|
||||
:_exit
|
||||
cd /d "%cwd%"
|
||||
echo END
|
||||
@@ -3,36 +3,67 @@
|
||||
# https://github.com/dreamforceinc
|
||||
#
|
||||
# Input parameters:
|
||||
# <Path to server location> : Absolute, fully qualified path to server's root folder.
|
||||
# <Path to instance> : Absolute, fully qualified path to server's instance folder.
|
||||
# [Path to BEC's logs location] : Optional. By default, BEC location inside the server's root folder.
|
||||
# [Path to Admin Tool's logs location]: Optional. By default, AT location inside the instance's folder.
|
||||
# -Server <Path to server location> : Absolute, fully qualified path to server's root folder.
|
||||
# -Instance <Path to instance> : Absolute, fully qualified path to server's instance folder.
|
||||
# -RotatedLogs <Path to store rotated logs> : Absolute, fully qualified path to rotated logs folder.
|
||||
# -BecLogs [Path to BEC's logs location] : Optional.
|
||||
# -ATLogs [Path to Admin Tool's logs location]: Optional.
|
||||
#
|
||||
# Example:
|
||||
# powershell.exe -File "wDayzLogRotation.ps1" "Z:\Servers\DayZServer" "Z:\Servers\DayZServer\profiles\Instance_1" "D:\server tools\BEC" "Z:\Servers\DayZServer\profiles\Instance_1\VPPadminTools"
|
||||
Param (
|
||||
[Alias("Server")]
|
||||
[Parameter (Position = 0)]
|
||||
[string]$ServerLocation = $(throw "ERROR!!! Required parameter '-Server' is missing!"),
|
||||
|
||||
[Alias("Instance")]
|
||||
[Parameter (Position = 1)]
|
||||
[string]$instanceDir = $(throw "ERROR!!! Required parameter '-Instance' is missing!"),
|
||||
|
||||
[Alias("RotatedLogs")]
|
||||
[Parameter (Position = 2)]
|
||||
[string]$destDir = $(throw "ERROR!!! Required parameter '-RotatedLogs' is missing!"),
|
||||
|
||||
[Alias("BecLogs")]
|
||||
[Parameter (Position = 3)]
|
||||
[string]$becLogDir = $null,
|
||||
|
||||
[Alias("ATLogs")]
|
||||
[Parameter (Position = 4)]
|
||||
[string]$adminToolLogDir = $null
|
||||
)
|
||||
|
||||
# ------------------------------[ Configuration ]------------------------------
|
||||
$daysAmount = 7 # Number of days to store logs
|
||||
$noDelete = $true # For tests - don't delete logs
|
||||
$daysAmount = 7 # Number of days to store logs
|
||||
$noDelete = $true # For tests - don't delete logs
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# -------------------------[ !!! DON'T EDIT BELOW !!! ]------------------------
|
||||
$serverLocation = $args[0]
|
||||
$instanceDir = $args[1]
|
||||
$becLogDir = $null
|
||||
$adminToolLogDir = $null
|
||||
if ($args[2]) { $becLogDir = $args[2] }
|
||||
if ($args[3]) { $adminToolLogDir = $args[3] }
|
||||
# -----------------------------------------------------------------------------
|
||||
if (!(Test-Path -Path "${ServerLocation}")) {
|
||||
Write-Error "The path '${ServerLocation}' does not exist!"
|
||||
Exit
|
||||
}
|
||||
if (!(Test-Path -Path "${instanceDir}")) {
|
||||
Write-Error "The path '${instanceDir}' does not exist!"
|
||||
Exit
|
||||
}
|
||||
if ($becLogDir -and !(Test-Path -Path "${becLogDir}")) {
|
||||
Write-Error "The path '${becLogDir}' does not exist!"
|
||||
Exit
|
||||
}
|
||||
if ($adminToolLogDir -and !(Test-Path -Path "${adminToolLogDir}")) {
|
||||
Write-Error "The path '${adminToolLogDir}' does not exist!"
|
||||
Exit
|
||||
}
|
||||
|
||||
$daysAmount = [Math]::Abs($daysAmount)
|
||||
$instance = Split-Path -Path "${instanceDir}" -Leaf
|
||||
$destDir = "${instanceDir}\RotatedLogs"
|
||||
$destDelDir = "${destDir}\DeletedLogs"
|
||||
if ($becLogDir) { $becDestDir = "${destDir}\BEC" }
|
||||
if ($adminToolLogDir) { $adminToolDestDir = "${destDir}\AdminTool" }
|
||||
$becDestDir = "${destDir}\BEC"
|
||||
$adminToolDestDir = "${destDir}\AdminTool"
|
||||
|
||||
### Debug output ###
|
||||
# Write-Host " serverLocation: '${serverLocation}'"
|
||||
# Write-Host " ServerLocation: '${ServerLocation}'"
|
||||
# Write-Host " instanceDir: '${instanceDir}'"
|
||||
# Write-Host " instance: '${instance}'"
|
||||
# Write-Host " destDir: '${destDir}'"
|
||||
@@ -45,7 +76,7 @@ if ($adminToolLogDir) { $adminToolDestDir = "${destDir}\AdminTool" }
|
||||
Write-Host "Start Log rotation powershell script"
|
||||
$date = Get-Date
|
||||
$fileList = $null
|
||||
|
||||
#<#
|
||||
#region ### DayZ Game ###
|
||||
Write-Host "Rotating DAYZ logs..."
|
||||
|
||||
@@ -176,5 +207,5 @@ if ($adminToolDestDir) {
|
||||
Write-Host ""
|
||||
}
|
||||
#endregion
|
||||
|
||||
#>
|
||||
Write-Host "End Log rotation powershell script"
|
||||
|
||||
Reference in New Issue
Block a user