Arma 3 Windows Server Automation

Discussion Related to the ARMA 3 Server and ARMA 3 in General.
User avatar
omon
Site Admin
Posts: 444
Joined: Sun Jan 12, 2014 5:12 pm
Location: Renton, WA

Arma 3 Windows Server Automation

Postby omon » Fri Mar 11, 2016 3:22 pm

Made this scrip to run the ARMA 3 Windows 2012 Server in full automatic mode!
It will check for game updates, check for workshop updates!
It will automatically pull the mission from github, unzip it and pbo pack it!
Then it will start services!


All you have to do is restart the server or restart the start the service.
We use NSSM for creating services for Arma 3 Server and Arma 3 Headless client's


This powershell script can be lunched via Batch

Code: Select all

@echo off
PowerShell.exe -Command "& 'c:/steam/update.ps1'"
exit



Code: Select all

# Asking Steam if there is any updates to Workshops and also to the Arma 3 Game
Start-Process -FilePath "c:/steam/steamcmd.exe" -ArgumentList "+login useremail password +force_install_dir c:/steam/steamapps/ +workshop_download_item 107410 642000944 +workshop_download_item 107410 497660133 +workshop_download_item 107410 497661914 +workshop_download_item 107410 541888371 +workshop_download_item 107410 450814997 +app_update 233780 validate +quit" -NoNewWindow -Wait

# We want to copy all the Addon Keys to the server keys folder if there is an updated version
copy-item C:\Steam\steamapps\workshop\content\107410\450814997\keys\*.bikey C:\Steam\steamapps\keys\ -force -recurse
copy-item C:\Steam\steamapps\workshop\content\107410\497660133\keys\*.bikey C:\Steam\steamapps\keys\ -force -recurse
copy-item C:\Steam\steamapps\workshop\content\107410\497661914\keys\*.bikey C:\Steam\steamapps\keys\ -force -recurse
copy-item C:\Steam\steamapps\workshop\content\107410\541888371\keys\*.bikey C:\Steam\steamapps\keys\ -force -recurse
copy-item C:\Steam\steamapps\workshop\content\107410\642000944\keys\*.bikey C:\Steam\steamapps\keys\ -force -recurse

# We want to clear up old RPT logs from taking to much space
Remove-Item C:\Steam\steamapps\startup\*.rpt
Remove-Item C:\Steam\steamapps\startup\*.log

# Lets delete old missions from mpmissions folder
Remove-Item C:\Steam\steamapps\mpmissions\*.*

Start-Sleep -s 1

# Downloading New Mission From GitHub
$source = "https://github.com/Liveandletdie/becti_zerty_OFPS_Extended.Altis/archive/Live.zip"
$destination = "C:/Steam/steamapps/mpmissions/Live.zip"
Invoke-WebRequest $source -OutFile $destination

Start-Sleep -s 20

# Unzipping GitHubs Live File
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
{
    param([string]$zipfile, [string]$outpath)

    [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}

Unzip "C:\Steam\steamapps\mpmissions\Live.zip" "C:\Steam\steamapps\mpmissions\Live"

Start-Sleep -s 10

# Packing Mission into PBO
Start-Process -FilePath "C:\steam\pbo\pboconsole.exe" -ArgumentList "-pack C:\Steam\steamapps\mpmissions\Live C:\Steam\steamapps\mpmissions\becti_zerty_OFPS_Extended.Altis.pbo"

Start-Sleep -s 10

#Lets Delete the zip file and unzipped folder
Remove-Item C:\Steam\steamapps\mpmissions\Live.zip -force -recurse
Remove-Item C:\Steam\steamapps\mpmissions\Live -force -recurse

Start-Sleep -s 1

start-service "Arma3 Server"
start-service "Arma3 HC2"
start-service "Arma3 HC3"

Exit


Loading mods with -param=file.txt

Code: Select all

-serverMod=startup\monitor
-mod=workshop\content\107410\450814997;workshop\content\107410\497660133;workshop\content\107410\497661914;workshop\content\107410\541888371;workshop\content\107410\642000944;workshop\content\107410\583496184;workshop\content\107410\583544987

User avatar
SpanishSurfer
Site Admin
Posts: 945
Joined: Sun Jan 12, 2014 7:49 pm
Location: Fort Lauderdale, FL

Re: Arma 3 Windows Server Automation

Postby SpanishSurfer » Sat Mar 12, 2016 6:05 am

Um....the auto download of the mission and install . ...that part we dont need! Sometimes changes are pushed so other devs can see it but it's not mission ready.

The rest is awesome though!

Jeffzig
Posts: 9
Joined: Sat Jan 31, 2015 10:31 pm

Re: Arma 3 Windows Server Automation

Postby Jeffzig » Sun Mar 13, 2016 1:31 pm

Powershell is awesome, I've been trying to learn more of it for my job. I don't know much about the .bikey process you guys have to go through but you could probably make that a for-each loop that looks for a *.bikey in any subfolder of 107410\ and copies it.

User avatar
omon
Site Admin
Posts: 444
Joined: Sun Jan 12, 2014 5:12 pm
Location: Renton, WA

Re: Arma 3 Windows Server Automation

Postby omon » Sun Mar 20, 2016 11:15 am

SpanishSurfer wrote:Um....the auto download of the mission and install . ...that part we dont need! Sometimes changes are pushed so other devs can see it but it's not mission ready.

The rest is awesome though!


thats why u have Live branch and Testing branch.

Lunchbox
Posts: 1
Joined: Tue Dec 13, 2016 10:08 am

Re: Arma 3 Windows Server Automation

Postby Lunchbox » Tue Dec 13, 2016 10:10 am

omon wrote:
SpanishSurfer wrote:Um....the auto download of the mission and install . ...that part we dont need! Sometimes changes are pushed so other devs can see it but it's not mission ready.

The rest is awesome though!


thats why u have Live branch and Testing branch.



Love this script, but is there a way to download these files to the already in place mod folders on a server? Like in the root or our server folder we have @MOD1 and @MOD2.

Mach2Infinity
Posts: 2
Joined: Sat Sep 05, 2015 5:14 pm

Re: Arma 3 Windows Server Automation

Postby Mach2Infinity » Thu Feb 09, 2017 10:49 am

Lunchbox wrote:
omon wrote:
SpanishSurfer wrote:Um....the auto download of the mission and install . ...that part we dont need! Sometimes changes are pushed so other devs can see it but it's not mission ready.

The rest is awesome though!


thats why u have Live branch and Testing branch.



Love this script, but is there a way to download these files to the already in place mod folders on a server? Like in the root or our server folder we have @MOD1 and @MOD2.


Hi Lunchbox,

I'd suggest reading tinboye's post on the BI forums here.

CrabNipples
Posts: 1
Joined: Sun May 07, 2017 5:06 am

Re: Arma 3 Windows Server Automation

Postby CrabNipples » Sun May 07, 2017 5:10 am

I've been messing around with this a little to get it to work on my server.

i'll post my little readme (not up to date) and the powershell script wich is adapted to be more efficient and easier to use.

Powershell code

Code: Select all

#For the private server.

#Define directory
$steamCMDdir = "E:\Apps\Steam\steamcmd.exe"
$serverName = "Private1"
$installDir = "E:\Automated_Arma3_servers\"+$serverName
$installDirSteamapps = $installDir+"\steamapps"
$installDirArmadirectory = $installDirSteamapps+"\common\arma3"
$installDirWorkshop = $installDirSteamapps+"\workshop\content\107410"

# Define array with all workshop publishID's. Simply add a new ID for aditional mods.
$workshopPublishIdList = @(708250744, 583544987, 583496184, 621650475, 549676314, 875254284, 620019431, 463939057, 541888371, 497661914, 497660133, 450814997)
echo $workshopPublishIdList

#Adding the first part to the arguments list variable. This will login and define the install dir for the workshop mods.
$argumentListArray = "+login USERNAME PASSWORD +force_install_dir "+$installDir+" "

#A loop to add all the workshop download to the arguments list
foreach($item in $workshopPublishIdList)
{
   $argumentListArray += "+workshop_download_item 107410 $item "
}   
#Addint the last part to the arguments list for updating arma 3 and exiting SteamCMD
$argumentListArray += "+force_install_dir $installDirArmadirectory +app_update 233780 validate +quit"
echo $argumentListArray

#Running SteamCMD with argumentlist generated. Will download all workshop mods from array and update arma3
Start-Process -FilePath $steamCMDdir -ArgumentList $argumentListArray -NoNewWindow -Wait
echo Start-Process -FilePath $steamCMDdir -ArgumentList $argumentListArray -NoNewWindow -Wait

# We want to copy all the Addon Keys to the server keys folder if there is an updated version
# Also do this for they "Key" folder, because some mod makers don't like to keep to a standard. YAY
foreach($item in $workshopPublishIdList)
{
   copy-item $installDirWorkshop$item\keys\*.bikey $installDirArmadirectory\keys\ -force -recurse
   echo copy-item $installDirWorkshop$item\keys\*.bikey $installDirArmadirectory\keys\ -force -recurse
   copy-item $installDirWorkshop$item\key\*.bikey $installDirArmadirectory\keys\ -force -recurse
   echo copy-item $installDirWorkshop$item\key\*.bikey $installDirArmadirectory\keys\ -force -recurse
}

# Copy over the Arma3server_x64 executable and rename it to keep running tasks sorted and not interfere with steam
copy-item $installDirArmadirectory\arma3server_x64.exe $installDirArmadirectory\$serverName.exe -force -recurse
echo copy-item $installDirArmadirectory\arma3server_x64.exe $installDirArmadirectory\$serverName.exe -force -recurse

# We want to clear up old RPT logs from taking to much space
Remove-Item $installDirArmadirectory\*.rpt
Remove-Item $installDirArmadirectory\*.log
echo Remove-Item $installDirArmadirectory\*.rpt
echo Remove-Item $installDirArmadirectory\*.log

#start-service "Arma3 Server"
cmd.exe /c "C:\Users\Administrator\Desktop\Automated_Arma3_Server\"$serverName"\Autostart Arma3.bat"
echo cmd.exe /c "C:\Users\Administrator\Desktop\Automated_Arma3_Server\"$serverName"\Autostart Arma3.bat"


Readme

Code: Select all

Hello!

Welcome to the readme of the Automatic Update script for arma3
What this script (made in PowerShell) does is the following:

-Download/updates workshop mods for arma3
-Validates/updates arma3
-removes all old .bikeys from the arma 3 directory
-copies over all new .bikeys to the arma 3 directory
-removes all old .rtp log files to keep it clean
-copies and renames the arma3server_x64.exe and renames it inside the arma 3 directory (because the original conflics with steam thinking its playing arma3)
-Start the server with a batch script that will recognizes if the server crashed.

-If the server crashed it will return to the update script and will do all of the above again so its a loop.

If nothing is running start the folling batch file in order to start the loop:
'start AutomaticPS.bat'

If the server is running but not the batch file (window with black background and text):
Stop the server, and run the batch file 'start AutomaticPS.bat' this will start the server again and the batch file will remain running watching the server

if the batch file is running but the server is not:
Stop the batch file and run the batch file 'start AutomaticPS.bat'


To add mods to the server and keep them updated open the 'AutomaticPS.ps1' file with a text edittor (notepad++)
and add the workshop ID for the mod to the follow array; $workshopPublishIdList
For example:
$workshopPublishIdList = @(450814997, 583496184, 660460283, 918383807, 823581498, 825222328, 756352410, xxxxxxxxx)
enter ID where the x's are.
You can find the workshop ID when you go to the page of the workshop mod you're adding and look at the URL. For example
http://steamcommunity.com/sharedfiles/filedetails/?id=xxxxxxxxx

To add mods to the starting up of the server you need to change the "Modlist.txt" located in the arma 3 directory.
There is a shortcut inside the Automatic Update script for Arma 3 directory where this readme is located too.
Add the following behind the -mod line all the way on the end after the last ";" symbol.
E:\steam\steamapps\workshop\content\107410\xxxxxxxxx;


For any questions please send an email to:
Dutchlionscommunity@gmail.com


Autostart Arma3.bat

Code: Select all

@echo off
color 0a
title IFA3 Liberation Public
C:\Windows\System32\mode con cols=200 lines=25 >nul
set /a var=0
:start
echo Running Private on port 2312
start "public1" /min /wait E:\steam\steamapps\common\arma3\public1.exe -par=Params.txt
set /a var+=1
cls
echo Server has shutdown %var% times, restarting
call "Start AutomaticPS.bat"


params.txt

Code: Select all

-port=2312
-mod=E:\Automated_Arma3_servers\Private1\steamapps\workshop\content\107410\450814997;E:\Automated_Arma3_servers\Private1\steamapps\workshop\content\107410\708250744;E:\Automated_Arma3_servers\Private1\steamapps\workshop\content\107410\583544987;E:\Automated_Arma3_servers\Private1\steamapps\workshop\content\107410\583496184;E:\Automated_Arma3_servers\Private1\steamapps\workshop\content\107410\621650475;E:\Automated_Arma3_servers\Private1\steamapps\workshop\content\107410\549676314;E:\Automated_Arma3_servers\Private1\steamapps\workshop\content\107410\875254284;E:\Automated_Arma3_servers\Private1\steamapps\workshop\content\107410\620019431;E:\Automated_Arma3_servers\Private1\steamapps\workshop\content\107410\463939057;E:\Automated_Arma3_servers\Private1\steamapps\workshop\content\107410\541888371;E:\Automated_Arma3_servers\Private1\steamapps\workshop\content\107410\497661914;E:\Automated_Arma3_servers\Private1\steamapps\workshop\content\107410\497660133;E:\Automated_Arma3_servers\Private1\steamapps\workshop\content\107410\450814997;
-config=E:\Automated_Arma3_servers\Private1\steamapps\common\arma3\TADST\default\TADST_config.cfg
-cfg=E:\Automated_Arma3_servers\Private1\steamapps\common\arma3\TADST\default\TADST_basic.cfg
-profiles=E:\Automated_Arma3_servers\Private1\steamapps\common\arma3\TADST\default
-name=default
-filePatching
-pid=pid.log
-ranking=ranking.log
-autoInit
/wait
/realtime
/affinity FF

vegbruiser
Posts: 2
Joined: Wed Jun 14, 2017 1:18 am

Re: Arma 3 Windows Server Automation

Postby vegbruiser » Wed Jun 14, 2017 1:23 am

Hi CrabNipples,

I just downloaded and edited your script with a username/password and at first it works flawlessly.

However, all of the workshop content fails to download on my Windows 10 system.

Is this because I am only using an account I registered in order to install the Arma Tools and Dedicated server?

It would seem to be the case, but if you can confirm, that would save me some head scratching.

Thanks,

Alex.

vegbruiser
Posts: 2
Joined: Wed Jun 14, 2017 1:18 am

Re: Arma 3 Windows Server Automation

Postby vegbruiser » Fri Jun 16, 2017 4:48 am

So it turns out I answered my own question; it does indeed seem that steamcmd will fail to download Workshop content for Arma 3 if you don't have a licensed copy of it on your account. I suppose it makes sense in some way.


Return to “ARMA 3”

Who is online

Users browsing this forum: No registered users and 3 guests