Jump to content

DayZ All-In-One Restart and clean up batch


Recommended Posts

Hi guys Kumari here I am the developer of for the aCw community many of you may not have heard of us because we are No-CD.Now we do use a legit copy of the game for hosting but I digress.I have made this quite interesting I think batch file that I call the All-In-One It takes several functions from all over different forums and combines them in to one batch file.Well a batch file and a vb script but this is still mostly all in one really.Now what this dose is you run it from the BEC or any other program you use for restarts ect.

I have tried my best to make this as user friendly as possible so its really simple to use.I probly will redo this tho to have all config in one section now this has not been used yet but has been tested a lot so you can consider this a 1.0 beta if you will if you guys find this useful I will improve it add more to it ect.

 

Once this file is activated by the BEC what it dose is it will start by shutting down the server and the BEC now the BEC normally shuts its self down but in the event that it dose not this will do that for you.

Then it dose a check to see if you have debug set to 1 this will tell you step by step what its doing and allow you to walk thew it to find errors.Then it shuts down the server and BEC.The BEC almost allays shuts its self down but in the event it dose not this will make sure its down so that way you don't end up with two BECs running at once.Then you come to the clean up this uses the log rotation but may change there are configs for this and I will show you soon.What it dose it makes a back up of the ArmA II logs and removes the original to keep it clean and running smooth it allso backs up and removes infiSTAR anti-hack logs don't worry if you don't have this because the batch also looks to see if you have it installed of you dont it just continues on to the next part.Now here comes the fun part the vb script if you want this you can use it if not you can remove it.What this dose it takes the Hiveext.ini and randomizes day/night.I implemented this because we have players from all over any they say "Every time I play its night" now this was because I use local time so that it marches that of real life I could have set it to be day all the time but what fun is that so this is ware the vb caomes in.Next it will boot up the server and BEC the cool thing it dose this all in a few seconds.Now I will show the code and how to configure this now like I said I make make this more simple to config at a later date.

 

 

 

 

 

 

All-In-One.bat

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::: DayZ all-in-one batch by Kumari Ashamaki ::::::::::::::::::::::::
::::::::::::::::: Rotate logs by r4z0r49 and Sykotix :::::::::::::::::::::::::::
::::::::::::::::::: Rotate infiSTAR logs by Kumari :::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@Echo OFF

TITLE DayZ all-in-one batch by Kumari Ashamaki

:: Debug Mode Settings
set debug=0
if %debug% == 1 (
echo Booting in debug mode.
)

:: Welcome Text
if %debug% == 1 (
echo To use this for restarts this batch shuld be called from BEC or 
echo whatever program you use for restarts.
echo If you use something else for restarts just comment out or remove 
echo The taskkill for BEC and the server EXEs.
echo leaveing the code wont hurt but you will see "task missing" errors
pause
)

:: Shuts down the server and BEC
if %debug% == 1 (
echo Shuttingdown The Instence
)
taskkill /f /im ACWEPRESCHER.exe
timeout /t 1 > nul

if %debug% == 1 (
echo Shuttingdown The BEC
pause
)
taskkill /im BEC_Chernarus.exe
timeout /t 1 > nul

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::  LOG ROTATION START :::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Info and starting messages for debug
:: Back up logs and remove them

:: Message
if %debug% == 1 (
echo Starting Rotation
pause
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::: CONFIG :::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Message
if %debug% == 1 (
echo loading configs
pause
)

:: Set The path to your server.
set arma2srvpath=C:\ACWEPRESCHER

:: Set the Instence name EX instance_11_chernarus or dzcfg or what ever you call it
set srvname=instance_11_chernarus

:: Delete Original log files after they have been backed up? This keeps your server from being boged down with old logs.
set deloriglogs=1

:: Set path to infiSTAR Dlls if you do not have infiSTAR comment this out do not remove it
set infiSTARDllPath=C:\ACWEPRESCHER

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::: ADVANCED CONFIG CONFIG :::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Message
if %debug% == 1 (
echo loading advanced configs
pause
)

:: Setting Server Profile to Use
IF "%1"=="" (
set servername=%srvname%
) else (
set servername=%1
)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::: END OF CONFIG RUNNING SCRIPTS ::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Messages
if %debug% == 1 (
echo Running scripts
pause
)

SET HOUR=%time:~0,2%
SET dtStamp9=%date:~-4%%date:~4,2%%date:~7,2%_0%time:~1,1%%time:~3,2%_%time:~6,2%
SET dtStamp24=%date:~-4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%_%time:~6,2%
::Make Date Stamp
if "%HOUR:~0,1%" == " " (SET dtStamp=%dtStamp9%) else (SET dtStamp=%dtStamp24%)
ECHO Todays Date and time (%date%)(%time%) / %dtStamp%

:: Message
if %debug% == 1 (
echo Createing Directories
pause
)

:: Make the Rotated Log Directorys
if exist "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs" goto maketsdir
mkdir "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs"
:maketsdir
if exist "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%" goto makebedir
mkdir "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%"
:makebedir
if exist "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\BattlEye" goto makebedir
mkdir "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\BattlEye"

:: Checks for infiSTAR Log DLLs
:makebedir
IF EXIST "%arma2srvpath%\AdminLog.dll" (
echo infiSTAR Log Dlls found
if exist "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\infiSTAR_Logs" goto rotatelogs
mkdir "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\infiSTAR_Logs"
) ELSE (
echo infiSTAR log Dlls not found!
)

:rotatelogs
:: Starting Log Rotation. If there are any other logs, just follow the format below, and make sure to NOT touch any of the varibles.
copy "%arma2srvpath%\%servername%\ACWEPRESCHER.RPT" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\ACWEPRESCHER.RPT"
copy "%arma2srvpath%\%servername%\ACWEPRESCHER.mdmp" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\ACWEPRESCHER.mdmp"
copy "%arma2srvpath%\%servername%\ACWEPRESCHER.bidmp" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\ACWEPRESCHER.bidmp"
copy "%arma2srvpath%\%servername%\server_log.txt" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\server_log.txt"
copy "%arma2srvpath%\%servername%\HiveExt.log" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\HiveExt.log"
copy "%arma2srvpath%\%servername%\BattlEye\scripts.log" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\BattlEye\scripts.log"
copy "%arma2srvpath%\%servername%\BattlEye\createvehicle.log" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\BattlEye\createvehicle.log"
copy "%arma2srvpath%\%servername%\BattlEye\mpeventhandler.log" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\BattlEye\mpeventhandler.log"
copy "%arma2srvpath%\%servername%\BattlEye\publicvariable.log" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\BattlEye\publicvariable.log"
copy "%arma2srvpath%\%servername%\BattlEye\publicvariableval.log" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\BattlEye\publicvariableval.log"
copy "%arma2srvpath%\%servername%\BattlEye\remoteexec.log" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\BattlEye\remoteexec.log"
copy "%arma2srvpath%\%servername%\BattlEye\setdamage.log" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\BattlEye\setdamage.log"
copy "%arma2srvpath%\%servername%\BattlEye\setpos.log" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\BattlEye\setpos.log"
copy "%arma2srvpath%\%servername%\BattlEye\setvariable.log" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\BattlEye\setvariable.log"
copy "%arma2srvpath%\%servername%\BattlEye\addmagazinecargo.log" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\BattlEye\addmagazinecargo.log"

:: infiSTAR Copy logs
IF EXIST "%arma2srvpath%\SurveillanceLog.txt" (
echo infiSTAR Logs found!
copy "%infiSTARDllPath%\AdminLog.txt" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\infiSTAR_Logs\AdminLog.txt"
copy "%infiSTARDllPath%\HackLog.txt" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\infiSTAR_Logs\HackLog.txt"
copy "%infiSTARDllPath%\ban.txt" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\infiSTAR_Logs\ban.txt"
copy "%infiSTARDllPath%\SurveillanceLog.txt" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\infiSTAR_Logs\SurveillanceLog.txt"
copy "%infiSTARDllPath%\logUnlockLock.txt" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\infiSTAR_Logs\logUnlockLock.txt"
copy "%infiSTARDllPath%\SafeZone.txt" "%arma2srvpath%\%servername%\ServerManagement\RotatedLogs\%dtStamp%\infiSTAR_Logs\SafeZone.txt"
) ELSE (
echo infiSTAR logs not found!
)

echo (%date%) (%time%) Logs are backed up now...
echo (%date%) (%time%) Removing original log files.
del /Q /F "%arma2srvpath%\%servername%\ACWEPRESCHER.RPT"
del /Q /F "%arma2srvpath%\%servername%\ACWEPRESCHER.mdmp"
del /Q /F "%arma2srvpath%\%servername%\ACWEPRESCHER.bidmp"
del /Q /F "%arma2srvpath%\%servername%\server_log.txt"
del /Q /F "%arma2srvpath%\%servername%\HiveExt.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\scripts.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\createvehicle.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\mpeventhandler.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\publicvariable.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\publicvariableval.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\remoteexec.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\setdamage.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\setpos.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\setvariable.log"
del /Q /F "%arma2srvpath%\%servername%\BattlEye\addmagazinecargo.log"

:: infiSTAR Remove Logs
IF EXIST "%infiSTARDllPath%\SurveillanceLog.txt" (
echo Removeing infiSTAR logs!
del /Q /F "%infiSTARDllPath%\infiSTAR_Logs\AdminLog.txt"
del /Q /F "%infiSTARDllPath%\infiSTAR_Logs\HackLog.txt"
del /Q /F "%infiSTARDllPath%\infiSTAR_Logs\ban.txt"
del /Q /F "%infiSTARDllPath%\infiSTAR_Logs\SurveillanceLog.txt"
del /Q /F "%infiSTARDllPath%\infiSTAR_Logs\logUnlockLock.txt"
del /Q /F "%infiSTARDllPath%\infiSTAR_Logs\SafeZone.txt"
) ELSE (
echo No infiSTAR logs to remove!
)

if %debug% == 1 (
echo Logs rotated?
pause
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::: LOG ROTATION END :::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Randomize day/night
if %debug% == 1 (
echo Randomizing day/night
pause
)

pushd %~dp0
start /b "" cscript TimeChange.vbs
timeout /t 1 > nul

:: Start server
if %debug% == 1 (
echo Starting server.
pause
)
cd "C:\ACWEPRESCHER"
start /high .\Expansion\beta\ACWEPRESCHER.exe -port=2302 "-config=instance_11_Chernarus\config.cfg" "-cfg=instance_11_Chernarus\basic.cfg" "-profiles=instance_11_Chernarus" -name=instance_11_Chernarus "-mod=@DayZ_Epoch;@DayZ_Epoch_Server;" "-world=Chernarus" "-noPause" "-noSound" "-cpuCount=4" "-maxMem=4096" "-bandwidthAlg=2" "-exThreads=7" "-noCB"

:: Start BEC
if %debug% == 1 (
echo Starting BEC
pause
)
cd "C:\ACWEPRESCHER\instance_11_Chernarus\ServerManagement\Bec"
start /MIN C:\ACWEPRESCHER\instance_11_Chernarus\ServerManagement\Bec\BEC_Chernarus.exe -f Config.cfg

:: Check if is in debug mode
if %debug% == 1 (
echo you are in debug mode this stops the code before exit
echo and waits so that you can see whats happening.
pause
)

Exit

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::: Credits :::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::: Script ::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::: Kumari Ashamaki :::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::: Rotate Logs :::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::: r4z0r49 :::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::: Sykotix :::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::: antiHACK Logs ::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::: infiSTAR.de :::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

                                                                                                                                                  TimeChange.vbs

'All-In-One time change by Geryon
Option Explicit
'Create an instance of the FileSystemObject object
Dim objFSO
Dim objTextStream
Dim objString
Dim objNum
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextStream = objFSO.OpenTextFile("C:\ACWEPRESCHER\instance_11_Chernarus\HiveExt.ini", 1)
 
objString = objTextStream.ReadAll
objTextStream.Close
 
Randomize 
objNum = Int(3 * Rnd + 1)
 
'Don't repeat night time
if objNum = 1 and instr(objString, "Hour = 22") = 0 then
objString = Replace(objString,"Hour = 12", "Hour = 22")
wscript.echo "Night Time!"
else
objString = Replace(objString,"Hour = 22", "Hour = 12")
wscript.echo "Day Time!"
end if
 
Set objTextStream = objFSO.OpenTextFile("C:\ACWEPRESCHER\instance_11_Chernarus\HiveExt.ini", 2)
objTextStream.WriteLine objString
objTextStream.Close

Now this is just to show what I am using I will also attach the files that are ready to be configed

 

Now how do we make all this work for us?

 

Lets start with the shutdown as you can see I use custom names because we run two servers on one system so I only want this to run on on server at a time you can do the same if you have two in one server.

 

Now for the log rotation.

Here you need to set your server path server insistence if you want the original logs removed and if you have infiSTAR ware your Dlls are located now I use default for this because I can never get the AHconfig to use the path I give it to the Dlls.

 

Now unlike the original code you can see I have the logs back up to ServerManagement\RotatedLogs you can change this if you like but I like it that way to be neat.

 

now this next bit will look for the infiSTAR Dlls.

Then it dose the rotation.

 

Next it dose the Day/Night now for this to work you need to right click the vb and edit it and give it the path to your hive ini and set under time Type static and the hour to 12 or 22 I tried to make this work in a way that you don't need to change that and the code dose it on its own but failed this may be fixed if I can figure it out now it needs to look like this.

[Time]
;Possible values: Local, Custom, Static
;You cannot use Static on OFFICIAL Hive, it will just revert to Local
Type = Static
;If using Custom type, offset from UTC in hours (can be negative as well)
;Offset = -8
;If using Static type (Hour value always the same on every server start), the value (0-24) to set the Hour to
Hour = 22

Now back to the batch file It will then run your server and BEC this works the same what way ever batch you are useing you need to set your port config path ect.Thats really basic stuff so I am not going over that.

 

Then it will start BEC same rules apply.

 

and thats about it really I have as you can see given credit ware do ect "I hope" and added lots of comments to help out the Epoch community has helped me alot and I hope you guys will accept this as a thank you I wanted to give back to those who have helped me rather you know it or not.I really dont even know if this will be any good to you geniuses lol but maybe it will

 

I have packed them in a .Zip you may need 7z or win rar but I dont know.Bat_Files.ZIP

 

HAVE FUN!!

Link to comment
Share on other sites

  • 1 month later...

Hey big thank you for this, I looooove it :D

Thank you I may be doing a new one but I have dropped out of DayZ for a bit  but as for the log rotation I seem to have an issue with it as well seems to work sometimes but not all ways I think I may have made some changes to the one I use but I cant remember I will be sure to update this once I start modding Epoch again

Link to comment
Share on other sites

Thank you I may be doing a new one but I have dropped out of DayZ for a bit  but as for the log rotation I seem to have an issue with it as well seems to work sometimes but not all ways I think I may have made some changes to the one I use but I cant remember I will be sure to update this once I start modding Epoch again

I edited the roto problem out as I got it working for the most part.

I had put a space before the drive in "set arma2srvpath= C:\ACWEPRESCHER"

Thanks again !!!!! ^_^

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...