Auto Install SteamCMD & DayZ Standalone Server

Automating DayZ Server Setup with SteamCMD

This document explains the steps involved in automating the download and installation of SteamCMD, setting up the DayZ server repository, and populating the repository with the core server files.

1. Downloading and Installing SteamCMD​

The first step in the process is to download and install SteamCMD, the tool required to manage and update Steam-based game servers.

Code Block for Downloading and Installing SteamCMD:​

Bash:
@echo off

REM Step 1: Define directories
set "scriptsDir=%~dp0..\..\..\steamcmd"
set "zipFile=%scriptsDir%\steamcmd.zip"
set "steamCmdUrl=https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip"

REM Step 2: Create the /scripts/steamcmd directory if it does not exist
if not exist "%scriptsDir%" (
    echo Creating directory %scriptsDir%
    mkdir "%scriptsDir%"
)

REM Step 3: Download steamcmd.zip
echo Downloading steamcmd.zip...
powershell.exe -Command "Invoke-WebRequest -Uri '%steamCmdUrl%' -OutFile '%zipFile%'"

if not exist "%zipFile%" (
    echo Failed to download steamcmd.zip. Exiting...
    exit /b 1
)

REM Step 4: Extract steamcmd.zip to the /scripts/steamcmd directory
echo Extracting steamcmd.zip...
powershell.exe -Command "Add-Type -AssemblyName 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::ExtractToDirectory('%zipFile%', '%scriptsDir%')"

if not exist "%scriptsDir%\steamcmd.exe" (
    echo Failed to extract steamcmd.exe. Exiting...
    exit /b 1
)

REM Step 5: Clean up by deleting the zip file
echo Deleting steamcmd.zip...
del "%zipFile%"

  • Key Process:
    This script defines the SteamCMD directory and creates it if it doesn't exist. The `Invoke-WebRequest` command downloads the SteamCMD zip file. After downloading, the script extracts the zip file and checks if `steamcmd.exe` exists. If the download is successful, the zip file is deleted to clean up.

2. Creating the DayZ Server Repository​

After installing SteamCMD, the next step is to create a folder that will act as the DayZ server repository, where the server files will be stored.

Code Block for Creating the DayZ Server Repository:​

Bash:
REM Step 7: Create the /scripts/dayzserver directory (AGSR) if it does not exist
set "AGSR=%~dp0..\..\..\dayzserver"
if not exist "%AGSR%" (
    echo Creating directory %AGSR%
    mkdir "%AGSR%"
)

  • Key Process:
    The script sets up the Active Game Server Repository (AGSR) by creating a `dayzserver` folder within the `/scripts` directory. This folder will be used to store the core server files for DayZ.

3. Downloading and Populating the DayZ Server Files​

Once SteamCMD is installed and the DayZ server repository is created, the script uses SteamCMD to download and populate the repository with the DayZ server files.

Code Block for Downloading and Populating DayZ Server Files:​

Bash:
REM Step 8: Run steamcmd.exe to install DayZ server in /scripts/dayzserver
echo Installing DayZ server to %AGSR%...
"%scriptsDir%\steamcmd.exe" +force_install_dir "%AGSR%" +login "%STEAMUSERNAME%" +app_update 223350 validate +quit

  • Key Process:
    SteamCMD is executed to force the installation of DayZ server files into the `dayzserver` directory (`%AGSR%`). The Steam username (`%STEAMUSERNAME%`) is prompted from the user earlier in the script. The `app_update 223350 validate` command is used to download and validate the DayZ server files. The `+quit` flag ensures SteamCMD exits automatically when the process completes.

Putting It All Together​

The script automates the entire process of:
  1. Downloading SteamCMD: Downloading and setting up SteamCMD on your server.
  2. Creating a Server Repository: Setting up the directory structure for the DayZ server repository.
  3. Installing the DayZ Server: Using SteamCMD to download and validate the DayZ server files in the specified directory.

Additional Notes​

  • SteamCMD Login: The script prompts for the Steam username before running SteamCMD.
  • Customization: You can adjust the paths and settings in the script based on your specific directory structure and needs.

Example Workflow:​

  1. Run the Script: When you run the batch script, it automatically handles all the steps mentioned.
  2. Verify Installation: Once the script finishes, navigate to the `/scripts/dayzserver` directory to verify that the DayZ server files are installed.

This document provides a breakdown of the code used in each process of automating the DayZ server setup using SteamCMD.

Feel free to post a reply with any questions or thoughts re this process
 
Top