Skip to content

Instantly share code, notes, and snippets.

@dhkatz
Forked from firefly2442/SteamUpdateMods.py
Created July 6, 2020 03:07
Show Gist options
  • Save dhkatz/d5bca6208b39bf34920821c82aead43d to your computer and use it in GitHub Desktop.
Save dhkatz/d5bca6208b39bf34920821c82aead43d to your computer and use it in GitHub Desktop.
AlphaSquad Arma3 Server Update via Steam Workshop
#!/usr/bin/env python
import subprocess, sys, os
STEAM_USERNAME = "steamusername"
STEAM_PASSWORD = "steampassword"
WORKSHOP_IDS = [["843425103", "@rhsafrf"],
["843593391", "@rhsgref"],
["843577117", "@rhsusaf"],
["843632231", "@rhssaf"],
["450814997", "@CBA_A3"],
["620260972", "@ALiVE"],
["751965892", "@acre2"],
["463939057", "@ace3"],
["642457233", "@asr_ai3"]]
#stop the server temporarily
subprocess.call("~/arma3server/arma3server stop", shell=True)
os.chdir("/home/as/arma3server/steamcmd/")
for item in WORKSHOP_IDS:
#download mod from Steam Workshop
print("\n------ Downloading: " + item[1] + " ------\n")
subprocess.call("./steamcmd.sh +login \'"+STEAM_USERNAME+"\' \'"+STEAM_PASSWORD+"\' +force_install_dir '../serverfiles/' +app_update 233780 +workshop_download_item 107410 "+item[0]+" validate +quit", shell=True)
#copy and overwrite mod folder
subprocess.call("rsync -rtua --delete ~/arma3server/serverfiles/steamapps/workshop/content/107410/"+item[0]+"/ ~/arma3server/serverfiles/servermods/"+item[1]+"/", shell=True)
#copy .bikey files
if os.path.isdir(os.path.join("~/arma3server/serverfiles/steamapps/workshop/content/107410", item[0], "keys")):
subprocess.call("cp ~/arma3server/serverfiles/steamapps/workshop/content/107410/"+item[0]+"/keys/*.bikey ~/arma3server/serverfiles/keys/", shell=True)
if os.path.isdir(os.path.join("~/arma3server/serverfiles/steamapps/workshop/content/107410", item[0], "key")):
subprocess.call("cp ~/arma3server/serverfiles/steamapps/workshop/content/107410/"+item[0]+"/key/*.bikey ~/arma3server/serverfiles/keys/", shell=True)
#Mod specific operations
#copy compatibility addons for Ace3 and RHS to play nice
subprocess.call("cp -rf ~/arma3server/serverfiles/servermods/@ace3/optionals/ace_compat_rhs_afrf3.pbo ~/arma3server/serverfiles/servermods/@ace3/addons/ace_compat_rhs_afrf3.pbo", shell=True)
subprocess.call("cp -rf ~/arma3server/serverfiles/servermods/@ace3/optionals/ace_compat_rhs_usf3.pbo ~/arma3server/serverfiles/servermods/@ace3/addons/ace_compat_rhs_usf3.pbo", shell=True)
subprocess.call("cp -f ~/arma3server/serverfiles/servermods/@ace3/optionals/ace_compat_rhs_afrf3.pbo.ace*.bisign ~/arma3server/serverfiles/servermods/@ace3/addons/", shell=True)
subprocess.call("cp -f ~/arma3server/serverfiles/servermods/@ace3/optionals/ace_compat_rhs_usf3.pbo.ace*.bisign ~/arma3server/serverfiles/servermods/@ace3/addons/", shell=True)
#Create backup of missions folder
print("\n Creating backup of mpmissions folder")
subprocess.call("tar -cvzf ~/mpmissions-backup-autogenerated.tar.gz ~/arma3server/serverfiles/mpmissions/", shell=True)
#Copy over files for serving via Arma3Sync
os.chdir("/home/as/arma3server/serverfiles/servermods/")
subprocess.call("chmod -R 755 *", shell=True)
os.chdir("/home/as/ArmA3Sync/")
subprocess.call("java -jar ArmA3Sync.jar -BUILD AlphaSquad", shell=True)
subprocess.call("rsync -rtua --delete ~/arma3server/serverfiles/servermods/ /var/www/html/servermods/", shell=True)
#start the server back up
subprocess.call("~/arma3server/arma3server start", shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment