Skip to content

Commit

Permalink
Merge branch 'master' into depots
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson authored Mar 9, 2024
2 parents ff0611f + 0812ed0 commit bdb7b49
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ ARMA_BINARY=./arma3server_x64
ARMA_CDLC=
ARMA_CONFIG=main.cfg
ARMA_LIMITFPS=100
ARMA_PARAMS=
ARMA_PROFILE=main
ARMA_WORLD=empty
HEADLESS_CLIENTS=0
HEADLESS_CLIENTS_PROFILE="$profile-hc-$i" # valid placeholders: $profile, $i, $ii
MODS_LOCAL=true
MODS_PRESET=
PORT=2302
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docker_github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.pkg.github.com
tag_with_ref: true
push: true
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ RUN apt-get update \
python3 \
lib32stdc++6 \
lib32gcc-s1 \
libcurl4 \
wget \
ca-certificates \
&& \
Expand All @@ -27,18 +28,20 @@ RUN apt-get update \

ENV ARMA_BINARY=./arma3server
ENV ARMA_CONFIG=main.cfg
ENV ARMA_PARAMS=
ENV ARMA_PROFILE=main
ENV ARMA_WORLD=empty
ENV ARMA_LIMITFPS=1000
ENV ARMA_PARAMS=
ENV ARMA_CDLC=
ENV HEADLESS_CLIENTS=0
ENV HEADLESS_CLIENTS_PROFILE="\$profile-hc-\$i"
ENV PORT=2302
ENV STEAM_BRANCH=public
ENV STEAM_BRANCH_PASSWORD=
ENV STEAM_ADDITIONAL_DEPOT=
ENV MODS_LOCAL=true
ENV MODS_PRESET=
ENV SKIP_INSTALL=false

EXPOSE 2302/udp
EXPOSE 2303/udp
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Arma 3 Dedicated Server

[![Docker Pulls](https://img.shields.io/docker/pulls/synixebrett/arma3server.svg?style=flat-square)](https://hub.docker.com/r/synixebrett/arma3server)

An Arma 3 Dedicated Server. Updates to the latest version every time it is restarted.

## Usage
Expand All @@ -23,7 +21,7 @@ An Arma 3 Dedicated Server. Updates to the latest version every time it is resta
-e ARMA_CONFIG=main.cfg \
-e STEAM_USER=myusername \
-e STEAM_PASSWORD=mypassword \
synixebrett/arma3server
ghcr.io/brettmayson/arma3server/arma3server:latest
```

### docker-compose
Expand Down Expand Up @@ -58,6 +56,7 @@ Profiles are saved in `/arma3/configs/profiles`
| `-e PORT` | Port used by the server, (uses PORT to PORT+3) | 2302 |
| `-e ARMA_BINARY` | Arma 3 server binary to use, `./arma3server_x64` for x64 | `./arma3server` |
| `-e ARMA_CONFIG` | Config file to load from `/arma3/configs` | `main.cfg` |
| `-e ARMA_PARAMS` | Additional Arma CLI parameters |
| `-e ARMA_PROFILE` | Profile name, stored in `/arma3/configs/profiles` | `main` |
| `-e ARMA_WORLD` | World to load on startup | `empty` |
| `-e ARMA_LIMITFPS` | Maximum FPS | `1000` |
Expand All @@ -67,8 +66,10 @@ Profiles are saved in `/arma3/configs/profiles`
| `-e STEAM_USER` | Steam username used to login to steamcmd |
| `-e STEAM_PASSWORD` | Steam password |
| `-e HEADLESS_CLIENTS` | Launch n number of headless clients | `0` |
| `-e HEADLESS_CLIENTS_PROFILE` | Headless client profile name (supports placeholders) | `$profile-hc-$i` |
| `-e MODS_LOCAL` | Should the mods folder be loaded | `true` |
| `-e MODS_PRESET` | An Arma 3 Launcher preset to load |
| `-e SKIP_INSTALL` | Skip Arma 3 installation | `false` |

The Steam account does not need to own Arma 3, but must have Steam Guard disabled.

Expand All @@ -84,10 +85,11 @@ To use a Creator DLC the `STEAM_BRANCH` must be set to `creatordlc`
| [Global Mobilization - Cold War Germany](https://store.steampowered.com/app/1042220/Arma_3_Creator_DLC_Global_Mobilization__Cold_War_Germany/) | GM |
| [S.O.G. Prairie Fire](https://store.steampowered.com/app/1227700/Arma_3_Creator_DLC_SOG_Prairie_Fire) | vn |
| [Western Sahara](https://store.steampowered.com/app/1681170/Arma_3_Creator_DLC_Western_Sahara/) | WS |
| [Spearhead 1944](https://store.steampowered.com/app/1175380/Arma_3_Creator_DLC_Spearhead_1944/) | spe |

### Example

`-e ARMA_CDLC="csla;gm;vn;ws"`
`-e ARMA_CDLC="csla;gm;vn;ws;spe"`

## Loading mods

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.8'
services:
arma3:
build: .
image: synixebrett/arma3server
image: ghcr.io/brettmayson/arma3server/arma3server:latest
platform: linux/amd64
container_name: arma3
network_mode: host
Expand Down
47 changes: 27 additions & 20 deletions launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
import subprocess
import shutil
from string import Template

import local
import workshop
Expand All @@ -23,24 +24,25 @@ def env_defined(key):
os.remove(KEYS)
os.makedirs(KEYS)

# Install Arma

steamcmd = ["/steamcmd/steamcmd.sh"]
steamcmd.extend(["+force_install_dir", "/arma3"])
steamcmd.extend(["+login", os.environ["STEAM_USER"], os.environ["STEAM_PASSWORD"]])
steamcmd.extend(["+app_update", "233780"])
if env_defined("STEAM_BRANCH"):
steamcmd.extend(["-beta", os.environ["STEAM_BRANCH"]])
if env_defined("STEAM_BRANCH_PASSWORD"):
steamcmd.extend(["-betapassword", os.environ["STEAM_BRANCH_PASSWORD"]])
steamcmd.extend(["validate"])
if env_defined("STEAM_ADDITIONAL_DEPOT"):
for depot in os.environ["STEAM_ADDITIONAL_DEPOT"].split("|"):
depot = depot.split(",")
steamcmd.extend(["+login", os.environ["STEAM_USER"], os.environ["STEAM_PASSWORD"]])
steamcmd.extend(["+download_depot", "233780", depot[0], depot[1]])
steamcmd.extend(["+quit"])
subprocess.call(steamcmd)
if os.environ["SKIP_INSTALL"] in ["", "false"]:
# Install Arma

steamcmd = ["/steamcmd/steamcmd.sh"]
steamcmd.extend(["+force_install_dir", "/arma3"])
steamcmd.extend(["+login", os.environ["STEAM_USER"], os.environ["STEAM_PASSWORD"]])
steamcmd.extend(["+app_update", "233780"])
if env_defined("STEAM_BRANCH"):
steamcmd.extend(["-beta", os.environ["STEAM_BRANCH"]])
if env_defined("STEAM_BRANCH_PASSWORD"):
steamcmd.extend(["-betapassword", os.environ["STEAM_BRANCH_PASSWORD"]])
steamcmd.extend(["validate"])
if env_defined("STEAM_ADDITIONAL_DEPOT"):
for depot in os.environ["STEAM_ADDITIONAL_DEPOT"].split("|"):
depot = depot.split(",")
steamcmd.extend(["+login", os.environ["STEAM_USER"], os.environ["STEAM_PASSWORD"]])
steamcmd.extend(["+download_depot", "233780", depot[0], depot[1]])
steamcmd.extend(["+quit"])
subprocess.call(steamcmd)

if env_defined("STEAM_ADDITIONAL_DEPOT"):
for depot in os.environ["STEAM_ADDITIONAL_DEPOT"].split("|"):
Expand Down Expand Up @@ -101,9 +103,14 @@ def env_defined(key):
client_launch += " -password={}".format(config_values["password"])

for i in range(0, clients):
hc_launch = client_launch + ' -name="{}-hc-{}"'.format(
os.environ["ARMA_PROFILE"], i
hc_template = Template(
os.environ["HEADLESS_CLIENTS_PROFILE"]
) # eg. '$profile-hc-$i'
hc_name = hc_template.substitute(
profile=os.environ["ARMA_PROFILE"], i=i, ii=i + 1
)

hc_launch = client_launch + ' -name="{}"'.format(hc_name)
print("LAUNCHING ARMA CLIENT {} WITH".format(i), hc_launch)
subprocess.Popen(hc_launch, shell=True)

Expand Down
14 changes: 9 additions & 5 deletions workshop.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36" # noqa: E501


def mod(id):
def download(mods):
steamcmd = ["/steamcmd/steamcmd.sh"]
steamcmd.extend(["+force_install_dir", "/arma3"])
steamcmd.extend(["+login", os.environ["STEAM_USER"], os.environ["STEAM_PASSWORD"]])
steamcmd.extend(["+workshop_download_item", "107410", id])
for id in mods:
steamcmd.extend(["+workshop_download_item", "107410", id])
steamcmd.extend(["+quit"])
subprocess.call(steamcmd)

Expand All @@ -29,13 +30,16 @@ def preset(mod_file):
f.write(remote.read())
mod_file = "preset.html"
mods = []
moddirs = []
with open(mod_file) as f:
html = f.read()
regex = r"filedetails\/\?id=(\d+)\""
matches = re.finditer(regex, html, re.MULTILINE)
for _, match in enumerate(matches, start=1):
mod(match.group(1))
mods.append(match.group(1))
moddir = WORKSHOP + match.group(1)
mods.append(moddir)
moddirs.append(moddir)
download(mods)
for moddir in moddirs:
keys.copy(moddir)
return mods
return moddirs

0 comments on commit bdb7b49

Please sign in to comment.