Search the Community
Showing results for tags 'python'.
Found 3 results
-
a3update.py - A small lightweight python script for handling server and modpack updates
Freddo3000 posted a topic in ARMA 3 - SERVERS & ADMINISTRATION
Marceldev89s original script, from which I forked. Introduction: a3update.py is a simple, lightweight python script that handles: Updating the arma server Installing and updating mods Generating an importable preset.html ideal to accompany @Dahlgren's Arma Server Web Admin which as of yet does not provide those features. Here is an example modpack.html I setup for a friend using this script Download (Github Gist) Requirements: SteamCMD, Python3, Python3-urllib3, a Steam account with Arma 3 Installation (Ubuntu): Follow the initial server installation instructions on the BIWiki `sudo apt-get install steamcmd python3 python3-urllib3` `wget https://gist.githubusercontent.com/Freddo3000/a5cd0494f649db75e43611122c9c3f15/raw/4854ac4a78c7d347ade1e9ab9fcac147d7dbe3e9/a3update.py` Edit the following settings: STEAM_CMD - Point this at your steamcmd installation, alternatively simply enter "steamcmd" STEAM_USER - Your login username STEAM_PASS - Your login password A3_SERVER_DIR - Point this at your A3 server installation directory A3_MODS_DIR - Point this to where you want your mods to be symlinked. If you are using the suggested Arma Server Web Admin, make this the same as A3_SERVER_DIR A3_KEYS_DIR - Point this at the Keys folder in your installation directory MODPACK_NAME - Change this to what the title should be for the A3 launcher imported preset MODPACK_PATH - This will be the output preset.html file. Point this to wherever you wish for it to be stored, such as /var/www/html for the Apache web server MODS - Your list of mods in the format "@mod_folder" : "https://steamcommunity.com/sharedfiles/filedetails/?id=450814997". Avoid special and capital characters SERVER_MODS - List of server mods, only add folder names here. These also have to be present in the MODS list. Server keys will not be copied for these mods OPTIONAL_MODS - List of server mods, only add folder names here. These also have to be present in the `MODS` list. These mods will not get symlinks in your A3_MODS_DIR, but will have their server keys copied. DLC - List of CDLC in format "Name" : "https://store.steampowered.com/app/1042220/Arma_3_Creator_DLC_Global_Mobilization__Cold_War_Germany/" Optional: Install Arma Server Web Admin `chmod +x a3update.py` // Might be a good idea to limit access, as you have your password stored in plaintext Run it! `./a3update.py` Importing preset via URL: Open the A3 Launcher, go to mods, select "PRESET" at the top right and "IMPORT" Copy the link to the modpack.html (Example: https://somewebsite.com/modpack.html) Paste it into the "File name" field and press Open Notes: This has only been tested on Linux, though I wouldn't be surprised if it also works on Windows Known issues: Does currently not handle installation and updates of CDLC Doesn't work well with 2FA due to how steam stores login tokens Optional DLC is not kept when preset is imported With larger mod lists some data may fail to transfer to the launcher, therefore if you intend to keep the server public you'll want to run less than 15 mods. You can increase the amount of transferable data by shortening each mods mod.cpp file, making each mod take less space to transfer. Alternatively, you can use the ACE checkPBOs framework to make sure players are running the correct mods. License: MIT License Credits: @marceldev89 from who I forked this project -
Dedicated Windows Server Updater (Steam Workshop and Game)
tissue901 posted a topic in ARMA 3 - SERVERS & ADMINISTRATION
Hey Guys, I made a python script to automate updating my server and figured I'd share. I've only tested it on Python 3.6 but I think it would work for any version. Just update the directories and files section to where your stuff is located. The "Steam Workshop IDs.txt" file just contains the workshop item number and a human readable string which automatically gets changed to a lowercase name without spaces. It uses a symbolic link to add the mods to the server's addons folder instead of moving it so updating works without redownloading everything. I know theres a bunch of GUI server managers out there, but I don't like the complexity that adds and this way I can just SSH from any device to update/boot my server. Update.py import os import sys from subprocess import Popen, PIPE, CalledProcessError, DEVNULL, STDOUT, check_call import glob armaServerAppId = "233780" armaClientAppId = "107410" modsDirectory = "C:\\Users\\arma\\Desktop\\Arma\\Master\\addons\\" keysDirectory = "C:\\Users\\arma\\Desktop\\Arma\\Master\\keys\\" armaDirectory = "C:\\Users\\arma\\Desktop\\Arma\\Master" steamCMD = "C:\\Users\\arma\\Desktop\\steamcmd\\steamcmd.exe" steamContentDirectory = "C:\\Users\\arma\\Desktop\\steamcmd\\steamapps\\workshop\\content\\" + armaClientAppId + "\\" steamTempScript = "C:\\Users\\arma\\Desktop\\steamcmd\\tempUpdateScript.txt" steamAuth = "C:\\Users\\arma\\Desktop\\steamcmd\\auth.txt" workshopItems = "C:\\Users\\arma\\Desktop\\Arma\\Steam Workshop IDs.txt" userLogin = "" userPass = "" def updateServer(): print("Updating Server...") # Get the users login checkUserLogin() os.system(steamCMD + ' +login ' + userLogin + ' ' + userPass + ' +force_install_dir ' + armaDirectory + ' "+app_update ' + armaServerAppId + '" validate +quit') def checkUserLogin(): global userLogin global userPass if userLogin == "": userLogin = input("Steam> Username: ") if userPass == "": userPass = input("Steam> Password: ") def copyKeys(): for filename in glob.iglob(modsDirectory+'**\\*.bikey', recursive=True): os.system("xcopy " + filename + " " + keysDirectory + " /s /y") error = "" os.system('cls') try: with open(steamAuth) as f: for line in f: info = line.split(" ") if len(info) == 2: userLogin = info[0] userPass = info[1] except: pass while True: userInput = input("Main Menu \n1. Update Server\n2. Update Mods\n4. Update Keys\n4. Exit\n" + error + ">> ") error = "" if userInput == "1": updateServer() input("Press any key to continue...") os.system('cls') elif userInput == "2": # Get the users login checkUserLogin() # Clear the temp script file = open(steamTempScript, 'w') script = "@ShutdownOnFailedCommand 1\n" script += "@NoPromptForPassword 1\n" script += "login " + userLogin + " " + userPass + "\n" script += "force_install_dir " + armaDirectory + "\n" mods = {} # Loop through each item in the workshop file with open(workshopItems) as f: for line in f: modInfo = line.split(" ", 1) steamWorkshopId = modInfo[0].strip() modName = modInfo[1].strip() modFolder = "@"+modName.replace(" ", "_").lower() mods[steamWorkshopId] = {"name": modName, "folder": modFolder} script += 'workshop_download_item ' + armaClientAppId + ' ' + steamWorkshopId + ' validate\n' # Make a link to the downloaded content (way better than moving...) symLink = modsDirectory + modFolder if not os.path.exists(symLink): os.system('mklink /J ' + symLink + ' ' + steamContentDirectory + steamWorkshopId + '\n') script += "quit" file.write(script) file.close() # Run the script print("\n=====================================\nLogging into Steam...\n=====================================") with Popen(steamCMD + " +runscript " + steamTempScript, stdout=PIPE, bufsize=1, universal_newlines=True) as p: for line in p.stdout: line = line.strip() if line != "": if line.find("Downloading item") != -1: downloadingLine = line.split("Downloading item") if downloadingLine[0]: print(downloadingLine[0]) try: modIdLine = downloadingLine[1].strip().split(" ") steamWorkshopId = modIdLine[0] print("\n=====================================\nDownloading "+mods[steamWorkshopId]["name"] + " ["+str(steamWorkshopId)+"]...\n=====================================") except: pass else: print(line) # Automatically copy bikeys over print("\n=====================================\nCopying addon keys...\n=====================================") copyKeys() input("\nPress any key to continue...") os.system('cls') elif userInput == "3": # Search for any bikeys and copy them into keys folder copyKeys() input("Press any key to continue...") os.system('cls') elif userInput == "4": sys.exit(0) elif userInput == "": os.system('cls') else: error = "[ERROR] Unknown choice. Try again\n" Steam Workshop IDs.txt 450814997 CBA 463939057 ACE 708250744 ACEX 773131200 ACE Compat RHSAFRF 773125288 ACE Compat RHSUSAF 689845793 ACD 853743366 CUP Terrains CWA 583496184 CUP Terrains Core 583544987 CUP Terrains Maps 671539540 EM Buildings 753946944 Murshun Cigs 498740884 Shacktac 698078148 Spec4gear 696177964 VSM WARFIGHTERS ... and so on ... -
Just wanted to post this script in case it's helpful for people. For our Arma 3 Linux server (headless) we use: LinuxGSM - for Arma 3 server startup and updating Arma3Sync - for providing delta diffs of mods Apache - for serving up mod files Steam - for updating Arma 3 server and downloading mods from the workshop I wrote a little Python script that automates the updating of mods via Steam workshop, copies keys, updates mods via Arma3Sync and then restarts the server all via the command-line. No more manually downloading and extracting files! If you have suggestions or improvements, feel free to fork the file or post here.