Jump to content
ArcticRevrus

Way to check for updates with an external script

Recommended Posts

Hello,

 

I am trying to write an auto-update script for my server that checks if an update is available, and if so uses BERcon to gracefully shut down the server, apply the update with steamcmd, and then restarts the server. I'm having trouble trying to find a reliable source of information for the script to check for updates from. Originally i was using the output of app_info_print in steamcmd to get the current buildid of the game, however no matter what i did, trying to pipe that output in windows always seemed to be incomplete output. Currently the script hits http://api.steampowered.com/ISteamUserStats/GetSchemaForGame/v2/?key=readacted for gameVersion, however it did not appear to be updated with the patch last week.

 

Is there an endpoint that I can reliably get current server version from a python script?

Edited by ArcticRevrus

Share this post


Link to post
Share on other sites
26 minutes ago, SmashT said:

Have a look at this, might be what you are after or atleast give you some idea of how to do it yourself. 

https://old.reddit.com/r/dayz/comments/afad51/automatically_update_and_sync_your_steam_workshop/

Not quite, I am looking for a constantly up to date endpoint that shows what the current server application version  is available. The link you provided is only relevant to workshop synchronization using built-in functions. The Steam API is usually the way to go about this for other games, either through the ISteamUserStats/GetSchemaForGame function or with ISteamApps/UpToDateCheck, however the GetSchemaForGame values dont appear to be mantained and ISteamApps/UpToDateCheck does not appear to exist for DayZ.

 

Here is an example of a game that supports the UpToDateCheck function with the steam API

https://api.steampowered.com/ISteamApps/UpToDateCheck/v1/?appid=377610&version=

While DayZ responds with {"response":{"success":false,"error":"Couldn't get app info for the app specified."}}

https://api.steampowered.com/ISteamApps/UpToDateCheck/v1/?appid=223350&version=

 

For GetSchemaForGame, the api replies with a GameVersion, which was updated from '4' to '5' in a previous update, but was not updated to '6' or higher with last wednesday's update.

 

{"game":{"gameName":"DayZ Server","gameVersion":"5","availableGameStats":{}}}

 

 

 

For context, below is the python script I have written to handle this. It functions properly when manually setting the value in version.txt to something other than what the API is providing, however if the API does not update, the script is not useful.

 

import os, subprocess, psutil, time, requests, json


def getVer():
	r = requests.get("http://api.steampowered.com/ISteamUserStats/GetSchemaForGame/v2/?key=REDACTED&appid=223350")
	version = r.json()['game']['gameVersion']
	return version
				
def verCompare():
	verdiff = False
	os.chdir('E:\\steamcmd')
	with open('version.txt', "r") as f:
		if getVer() != f.readlines()[0]:
			verdiff = True	
	if verdiff == True:		
		with open('version.txt', "w") as f:
			f.write(getVer())
		return True
	else:
		return False
			
			
def checkServer():
	running = "DayZServer_x64.exe" in (p.name() for p in psutil.process_iter())
	if running == True:
		return True
		
def openServer():
	if not checkServer():
		print('Game Server not running, launching server.')
		os.chdir('E:\\dayzserver')
		subprocess.Popen(['E:\dayzserver\DayZServer_x64.exe', '-config=serverDZ.cfg', '-port 2302', '-dologs', '-adminlog', '-freezecheck', '-BEPath=E:\\dayzserver\\battleye'])
		
def gracefulUpdate():
	subprocess.call(['E:\\battleeye\BERcon', '-host', '127.0.0.1' ,'-port', '2302', '-pw', 'REDACTED', '-cmd', 'say -1 Update Found, Server restarting in 5 minutes.', '-cmd', 'exit'])
	time.sleep(270)
	subprocess.call(['E:\\battleeye\BERcon', '-host', '127.0.0.1' ,'-port', '2302', '-pw', 'REDACTED', '-cmd', 'say -1 Update Found, Server restarting in 30 seconds.', '-cmd', 'exit'])
	time.sleep(30)
	subprocess.call(['E:\\battleeye\BERcon', '-host', '127.0.0.1' ,'-port', '2302', '-pw', 'REDACTED', '-cmd', '#shutdown', '-cmd', 'exit'])
	subprocess.call(['E:\\steamcmd\steamcmd', '+login', 'REDACTED', '+force_install_dir E:\dayzserver', '+app_update', '223350', '+exit'])

		
def doUpdate():
	if verCompare() == True:
		print ("Update Detected")
		if checkServer():
			gracefulUpdate()
		else:
			subprocess.call(['E:\\steamcmd\steamcmd', '+login', 'REDACTED', '+force_install_dir E:\dayzserver', '+app_update', '223350', '+exit'])

print(getVer())
doUpdate()
oldtime = time.time()
while True:
	if time.time() - oldtime > 3599:
		doUpdate()
		oldtime = time.time()
	openServer()
	time.sleep(10)

 

Edited by ArcticRevrus

Share this post


Link to post
Share on other sites
ISteamUserStats/GetSchemaForGame

Is not an endpoint to retrieve the app version, build id or manifest id for any game, it returns the user stats schema for the game. This functionality isnt being used by DayZ and since the DayZ server has no user interaction, the server app won't have it either.

If you want a version check you can do HTML scraping (which will be easier for you) or make a connection to the Steam CM network and retrieve the app info that way. 

( I would strongly recommend having a look at this: https://www.python.org/dev/peps/pep-0008/ )

An already existing software would be this: https://www.reddit.com/r/CFTools/comments/a9orll/omegamanager/
 

 

  • Beans 1

Share this post


Link to post
Share on other sites

I use OmegaManger. It updates all mods and the game itself automatically.

 

Share this post


Link to post
Share on other sites

When I wrote my backup app, I wanted a way to see if Dayz SA had been updated or not while I was at work.

So I set my Dayz Server instance to always keep itself up to date in steam, using the steam options for the game (DayzServer)

 

And I never RAN the server from its default installation path c:\program files (x86)\steam\steamapps\common\dayzserver
instead I used it as a reference point for checking the version...

I installed my actual server at C:\DayzServer
and in the back  up program I checked the file version of the DayzServer_x64.exe in c:\program files (x86\steam\steamapps\common\dayzserver folder  
and compared it to the DayzServer_x64.exe version  in my c:\dayzserver folder....

If they didn't match then the server has been updated and my local copy is older...

This would only apply to locally hosted servers, not remote server...

Maybe that can help you resolve your issue?

 

 

Share this post


Link to post
Share on other sites
On 3/11/2019 at 10:00 AM, DrZeddy said:

When I wrote my backup app, I wanted a way to see if Dayz SA had been updated or not while I was at work.

So I set my Dayz Server instance to always keep itself up to date in steam, using the steam options for the game (DayzServer)

 

And I never RAN the server from its default installation path c:\program files (x86)\steam\steamapps\common\dayzserver
instead I used it as a reference point for checking the version...

I installed my actual server at C:\DayzServer
and in the back  up program I checked the file version of the DayzServer_x64.exe in c:\program files (x86\steam\steamapps\common\dayzserver folder  
and compared it to the DayzServer_x64.exe version  in my c:\dayzserver folder....

If they didn't match then the server has been updated and my local copy is older...

This would only apply to locally hosted servers, not remote server...

Maybe that can help you resolve your issue?

 

 

Both a terribly awful yet wonderfully simple solution. Will go with it.

Share this post


Link to post
Share on other sites
On 3/14/2019 at 5:45 AM, ArcticRevrus said:

Both a terribly awful yet wonderfully simple solution. Will go with it.

Yes its awful and simple hahaha...

It may not be the best solution,
but its still allows you to update your server automatically, until you find a better solution.

Glad it helped 🙂

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×