Skip to content

Commit

Permalink
Merge pull request #14 from Elyviere/master
Browse files Browse the repository at this point in the history
Add ability to update game server from confconsole ui
  • Loading branch information
JedMeister authored Oct 10, 2024
2 parents 6eaa15c + 50435a4 commit 5126e4f
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 4 deletions.
25 changes: 21 additions & 4 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ Method 1:

#. SSH into the appliance and run the command ``confconsole``.

#. Select ``Advanced`` menu or press the ``A`` key.
#. Select ``Advanced`` menu or press the ``A`` key and then <Enter>.

#. Select ``Gameserver`` or press the ``G`` key.
#. Select ``Gameserver`` or press the ``G`` key and then <Enter>.

#. Select ``Update`` or press the ``U`` key.
#. Select ``Update list`` or press the ``U`` key and then <Enter>.

#. Done!

Expand All @@ -101,8 +101,25 @@ Done!

Update game server version
----------------------------
If there is an update to the game after deploying your server, you may need to update the server to allow clients with the newer version to connect. Currently, the GUI does not support updating the server version. Instead, follow the following procedure:
If there is an update to the game after deploying your server, you may need to update the server to allow clients with the newer version to connect. Like with updating the game server list, this can either be done through the GUI or manually. Here are instructions for the two methods:

Method 1:
^^^^^^^^^^^

#. SSH into the appliance and run the command ``confconsole``.

#. Select ``Advanced`` menu or press the ``A`` key and then <Enter>.

#. Select ``Gameserver`` or press the ``G`` key and then <Enter>.

#. Select ``Update server`` or press the ``U`` key **twice** and then <Enter>.

#. Be patient, the update can take a few minutes.

#. Done!

Method 2:
^^^^^^^^^^^

#. Find your installed game server on the `supported games <https://github.com/jesinmat/linux-gameservers/tree/master#supported-games>`_ list. You will need the "Code" shown in this list.

Expand Down
53 changes: 53 additions & 0 deletions overlay/usr/lib/confconsole/plugins.d/Game_Server/update_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'''Update game server version'''
import os
import subprocess

GAME_REPO_DIR="/root/gameservers"
SERVER_NAME_FILE = "/etc/gameserver/gameserver"

def get_game_code():
try:
with open(SERVER_NAME_FILE, 'r') as file:
for line in file:
if line.startswith("GAME="):
game_code = line.split('=')[1].strip().strip('"')
return game_code
except FileNotFoundError:
return ('error', f'File not found: {SERVER_NAME_FILE}')
except Exception as e:
return ('error', str(e))

def run():
if not os.path.exists('/etc/gameserver/installation.done'):
console.msgbox('Info', 'No game server is installed')
return

console.msgbox('Info', 'The game server will be redownloaded and installed, even if no update is available.')

curdir = os.getcwd()
os.chdir(GAME_REPO_DIR)

game_code = get_game_code()

console.infobox('Stopping the game server')
ret = subprocess.run(['systemctl', 'stop', 'gameserver'], capture_output=True, text=True)
if ret.returncode != 0:
console.msgbox('Error', 'An error occurred while stopping the game server:\n' + ret.stderr)
os.chdir(curdir)
return

console.infobox('Attemting to update game server. Be patient, this takes at least a few minutes...')
ret = subprocess.run(
['./auto_install.sh', '-g', game_code, '-u', 'gameuser', '-p', '/home/gameuser/gameserver'],
capture_output=True, text=True)
if ret.returncode != 0:
console.msgbox('Error', 'An error occurred during the update (will attempt to restart the server regardless):\n' + ret.stderr)

console.infobox('Restarting the game server')
ret = subprocess.run(['systemctl', 'start', 'gameserver'], capture_output=True, text=True)
if ret.returncode != 0:
console.msgbox('Error', 'An error occurred while starting the game server:\n' + ret.stderr)
else:
console.msgbox('Update', 'Update success')

os.chdir(curdir)

0 comments on commit 5126e4f

Please sign in to comment.