diff --git a/.env.example b/.env.example index 55e6cb9..949b7c7 100644 --- a/.env.example +++ b/.env.example @@ -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 diff --git a/.github/workflows/docker_github.yml b/.github/workflows/docker_github.yml index b566792..1ce690f 100644 --- a/.github/workflows/docker_github.yml +++ b/.github/workflows/docker_github.yml @@ -15,3 +15,4 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} registry: docker.pkg.github.com tag_with_ref: true + push: true diff --git a/Dockerfile b/Dockerfile index 798f0b2..04cdfc0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,7 @@ RUN apt-get update \ python3 \ lib32stdc++6 \ lib32gcc-s1 \ + libcurl4 \ wget \ ca-certificates \ && \ @@ -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 diff --git a/README.md b/README.md index c495463..e63e5a0 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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` | @@ -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. @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index d80de9e..bc4a537 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/launch.py b/launch.py index 19634d7..3d0b8d9 100644 --- a/launch.py +++ b/launch.py @@ -2,6 +2,7 @@ import re import subprocess import shutil +from string import Template import local import workshop @@ -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("|"): @@ -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) diff --git a/workshop.py b/workshop.py index 874d63e..9894335 100644 --- a/workshop.py +++ b/workshop.py @@ -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) @@ -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