Skip to content

Commit

Permalink
Revert steam api key, does not work (#1)
Browse files Browse the repository at this point in the history
* Revert "fix | python syntax"

This reverts commit 2dfac1d.

* Revert "feature | Add ability to use steam API key"

This reverts commit ccf1414.
  • Loading branch information
Dzuelu authored Oct 30, 2023
1 parent 2dfac1d commit 40d1afc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 40 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Docker Arma3 Server

A KISS Arma3 Dedicated Server that can update Arma3 and mods.
An Arma3 Dedicated Server that can update Arma3 and mods on startup.
Allows for caching steam, Arma3, and mods install OR downloading any (or all) on startup.


Expand All @@ -20,21 +19,23 @@ Allows for caching steam, Arma3, and mods install OR downloading any (or all) on
| PORT | N | 2302 | Port used by the server, (uses PORT to PORT+3)
| STEAM_BRANCH | N | public | Steam branch code to download. [See](https://community.bistudio.com/wiki/Arma_3:_Steam_Branches)
| STEAM_BRANCH_PASSWORD | N | | Password for Steam branch code
| STEAM_API_KEY | Y/N | | Uses your [steam managed game server api key](https://steamcommunity.com/dev/managegameservers). Replaces user/pass requirement.
| STEAM_PASSWORD | Y/N | | Steam user password
| STEAM_USERNAME | Y/N | | Steam user used to login to steamcmd. Must own Arma3 and can't be used on multiple instances.
| STEAM_PASSWORD | Y | | Steam user password
| STEAM_USERNAME | Y | | Steam user used to login to steamcmd
| STEAM_VALIDATE | N | 1 | Validates files after Steam download
| WORKSHOP_MODS | N | | URL or file path to load mods

The Steam account needs to own Arma3 to be able to download Steam workshop mods.
TODO: Look into and possibly use instead [steam managegameservers](https://steamcommunity.com/dev/managegameservers).


### Important directories
### Docker directory parameters
| Directory | Description
| --- | ---
| /steamcmd | Steam cmd executable (not steam install)
| /arma3 | Entire Steam install, Arma3 server install, and workshop mods
| /arma3/mpmissions |
| /arma3/configs |
| /arma3/mods | Non workshop mods
| /arma3/mods |
| /arma3/servermods | Server only mods
| /arma3/steamapps/workshop/content/107410 | Steam workshop mods

Expand Down
35 changes: 12 additions & 23 deletions a3update.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@
def env_defined(key: str):
return key in os.environ and len(os.environ[key]) > 0

def envOrDefault(key: str, default = ''):
if env_defined(key):
return os.environ[key]
else:
return default

def debug(message: str):
if env_defined('DEBUG') and os.environ['DEBUG'] == '1':
print(message)
Expand All @@ -48,13 +42,12 @@ def debug(message: str):
debug(os.environ)


# Load ENV Configuration
#region Configuration
STEAM_CMD_DOWNLOAD = 'https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz'
STEAM_CMD_FOLDER = '/steamcmd'
STEAM_CMD = "{}/steamcmd.sh".format(STEAM_CMD_FOLDER)
STEAM_USER = envOrDefault("STEAM_USERNAME")
STEAM_PASS = envOrDefault("STEAM_PASSWORD")
STEAM_API_KEY = envOrDefault("STEAM_API_KEY")
STEAM_USER = os.environ["STEAM_USERNAME"]
STEAM_PASS = os.environ["STEAM_PASSWORD"]

A3_SERVER_DIR = "/arma3"
A3_SERVER_ID = "233780"
Expand All @@ -73,6 +66,7 @@ def debug(message: str):
LAST_UPDATED_REGEX = re.compile(r"workshopAnnouncement.*?<p id=\"(\d+)\">", re.DOTALL)
MOD_NAME_REGEX = re.compile(r"workshopItemTitle\">(.*?)<\/div", re.DOTALL)
WORKSHOP_CHANGELOG_URL = "https://steamcommunity.com/sharedfiles/filedetails/changelog"
#endregion


def log(msg: str):
Expand All @@ -83,16 +77,8 @@ def log(msg: str):


def call_steamcmd(params: str):
steam_cmd_params = " +force_install_dir {}".format(A3_SERVER_DIR)
if STEAM_API_KEY != "":
steam_cmd_params += " +sv_setsteamaccount {}".format(STEAM_API_KEY)
elif STEAM_USER != "" and STEAM_PASS != "":
steam_cmd_params += " +login {} {}".format(STEAM_USER, STEAM_PASS)
else:
raise Exception("Unable to login to steam with given params!")
steam_cmd_params += params
debug('steamcmd {}'.format(steam_cmd_params))
os.system("{} {}".format(STEAM_CMD, steam_cmd_params))
debug('steamcmd {}'.format(params))
os.system("{} {}".format(STEAM_CMD, params))
print("")


Expand All @@ -107,7 +93,9 @@ def read_config_values(config_path):


def update_server():
steam_cmd_params = " +app_update {}".format(A3_SERVER_ID)
steam_cmd_params = " +force_install_dir {}".format(A3_SERVER_DIR)
steam_cmd_params += " +login {} {}".format(STEAM_USER, STEAM_PASS)
steam_cmd_params += " +app_update {}".format(A3_SERVER_ID)
if env_defined("STEAM_BRANCH"):
steam_cmd_params += " -beta {}".format(os.environ["STEAM_BRANCH"])
if env_defined("STEAM_BRANCH_PASSWORD"):
Expand Down Expand Up @@ -162,7 +150,8 @@ def download_updated_workshop_mods():
debug("No workshop mods needed to be downloaded!")
return
debug("Starting download of updated workshop mods...")
steam_cmd_params = ""
steam_cmd_params = " +force_install_dir {}".format(A3_SERVER_DIR)
steam_cmd_params += " +login {} {}".format(STEAM_USER, STEAM_PASS)
for mod_id in WORKSHOP_UPDATE_MODS:
steam_cmd_params += " +workshop_download_item {} {}".format(
A3_WORKSHOP_ID,
Expand Down Expand Up @@ -214,7 +203,7 @@ def load_mods_from_dir(directory: str, copyKeys: bool, mod_type = 'mod'): # Load
if copyKeys:
copy_mod_keys(mod_folder)
return load_mods_paths

#endregion

# Startup checks
if not os.path.isfile(STEAM_CMD):
Expand Down
16 changes: 6 additions & 10 deletions example/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
network_mode: host
volumes:
# I've created a folder called shared that I use to contain all of my data
# Cache the steamcmd. Not required but if you don't you will need to download this each time
# Cache the steamcmd. Not required but if you do you will need to download this before
- '/shared/arma3/cache:/steamcmd'

# Cache entire arma 3 install (contains steam install, arma3 server, and mods)
Expand All @@ -22,13 +22,9 @@ services:
# Add exported mods list to base arma3 directory
# - '/shared/arma3/mods.html:/arma3/mods.html'
environment:
- ARMA_BINARY=./arma3server_x64
- ARMA_CDLC=ws
- ARMA_PARAMS='-cfg="/arma3/configs/basic.cfg"'
- DEBUG=1
- STEAM_BRANCH=creatordlc
- STEAM_PASSWORD=$STEAM_PASSWORD
- STEAM_USERNAME=$STEAM_USERNAME
- STEAM_VALIDATE=1
- WORKSHOP_MODS=mods.html
restart: on-failure:3
- ARMA_CDLC=gm;ws
- STEAM_BRANCH=creatordlc
- STEAM_USERNAME=*********************
- STEAM_PASSWORD=*********************
restart: unless-stopped

0 comments on commit 40d1afc

Please sign in to comment.