feat(ci): game server update checker (#4298)

* refactor: shorten module update function names

The commit renames the update functions for several game modules to shorter names. The new names are more concise and easier to remember, which should improve code readability and maintainability.

* feat: Add Update Check workflow

This commit adds a new GitHub Actions workflow that checks if LinuxGSM is picking up game server config and parameter variables. The workflow runs on push and manual triggers, with concurrency settings to cancel in-progress jobs. It downloads linuxgsm.sh, installs dependencies, grabs the server, enables developer mode, installs the server, and updates it.

* feat: Add concurrency group names to workflows

The `details-check.yml` and `update-check.yml` workflows now have a concurrency group name that includes the branch or tag name. This will allow for better management of concurrent workflow runs.

* refactor: Update script names for Minecraft, Factorio, Jedi Knight 2 and Vintage Story

This commit updates the script names for Minecraft, Factorio, Jedi Knight 2 and Vintage Story. The update includes changes to command_check_update.sh, command_update.sh, core_functions.sh and install_server_files.sh. The new script names are update_mc.sh (formerly update_minecraft.sh), update_fctr.sh (formerly update_factorio.sh), update_jk2.sh (formerly update_jediknight2.sh) and update_vints.sh (formerly update_vintagestory.sh).

* feat: Add support for 32-bit architecture

This commit adds support for 32-bit architecture by running the command "sudo dpkg --add-architecture i386" instead of installing libxml2-utils and jq.

* feat: Add i386 architecture and install libstdc++6

This commit adds the installation of libstdc++6:i386 package to support 32-bit applications. It also includes adding the i386 architecture to dpkg.

* feat: Update dependencies for LinuxGSM

Changed the dependency from libstdc++6:i386 to libgcc-s1:i386 in the update-check.yml file. This change was made to ensure compatibility with newer versions of LinuxGSM.

* feat: Add update and force-update server functionality

This commit adds the ability to check for updates and force updates on a server. The update-check.yml file has been modified to include new jobs that run the LGSM_GITHUBBRANCH command with specific arguments.

* feat: Add dependencies for server installation

This commit adds the necessary dependencies to install a game server. The `update-check.yml` file has been updated to include the installation of `bsdmainutils`, `libsdl2-2.0-0:i386`, `libtinfo5:i386`, and `steamcmd`.

* steamcmd only

* steamcmd

* test

* test

* refactor: improve random password generation in install_config.sh

The code change refactors the random password generation in the `install_config.sh` file. Instead of using `tr -dc A-Za-z0-9_ < /dev/urandom | head -c 8 | xargs`, it now uses `tr -dc 'A-Za-z0-9_' < /dev/urandom 2>/dev/null | head -c 8 | xargs`. This change improves the reliability and security of generating random passwords.

* refactor: remove redundant code and set default branch

The commit refactors the code by removing redundant code that sets the branch to "public" if no custom branch is specified. This change simplifies the logic and improves readability.

* test

* fix: fix steamcmd build version retrieval

The code changes in this commit fix an issue with retrieving the build version from SteamCMD. The previous implementation was not correctly capturing the buildid. This has been resolved by adding additional echo statements for debugging purposes.

* test

fix: remove unnecessary app_info_print command

The commit removes the unnecessary `app_info_print` command from the code. This command was not needed to check the buildid.

* fix: GitHub Actions test failure

The code change fixes a failing GitHub Actions test by running SteamCMD twice. The first run is to update the app info, and the second run retrieves the build ID for the specified branch.

* Add steam user and password secret for jk2

* refactor: update steamuser and steampass paths in jk2server config

The code changes refactor the paths for `steamuser` and `steampass` in the configuration file of the `jk2server`. The previous paths were incorrect, so they have been updated to point to the correct location.

* refactor: update steamuser and steampass insertion in LGSM configuration

The code changes refactor the way steamuser and steampass are inserted into the LGSM configuration file. Instead of hardcoding the values, they are now dynamically inserted using environment variables. This improves flexibility and security when setting up the server.

* refactor: simplify steamuser and steampass insertion in update-check.yml

The code changes remove unnecessary sed commands and replace them with a single echo command to insert the values of STEAMCMD_USER and STEAMCMD_PASS into the common.cfg file. This simplifies the code and improves readability.

* feat: update steamuser and steampass in common.cfg

The commit updates the code to properly insert the `steamuser` and `steampass` values in the `common.cfg` file. The previous code was not correctly formatting the values, which caused issues with server installation. This change ensures that the values are properly formatted using double quotes for `steamuser` and single quotes for `steampass`.
This commit is contained in:
Daniel Gibbs 2023-09-07 23:12:53 +01:00 committed by GitHub
parent 16c4493d1d
commit 8f714822fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 93 additions and 43 deletions

View File

@ -5,7 +5,7 @@ on:
push:
concurrency:
group: ${{ github.ref_name }}
group: details-check-${{ github.ref_name }}
cancel-in-progress: true
jobs:

48
.github/workflows/update-check.yml vendored Normal file
View File

@ -0,0 +1,48 @@
name: Update Check
# This action will check that LinuxGSM is picking up game server config and parameter variables.
on:
workflow_dispatch:
push:
concurrency:
group: update-check-${{ github.ref_name }}
cancel-in-progress: true
jobs:
update-check:
continue-on-error: true
runs-on: ubuntu-latest
strategy:
matrix:
shortname: [css, fctr, jk2, mc, mcb, mta, pmc, ts3, ut99, vints]
steps:
- name: Download linuxgsm.sh
run: wget https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/${GITHUB_REF#refs/heads/}/linuxgsm.sh; chmod +x linuxgsm.sh
- name: Install dependencies
run: sudo dpkg --add-architecture i386; sudo apt-get update;
- name: Grab server
run: LGSM_GITHUBBRANCH="${GITHUB_REF#refs/heads/}" ./linuxgsm.sh ${{ matrix.shortname }}server
- name: Enable developer mode
run: LGSM_GITHUBBRANCH="${GITHUB_REF#refs/heads/}" ./${{ matrix.shortname }}server developer
- name: Insert steamuser
if: matrix.shortname == 'jk2'
run: echo -e "steamuser=\"${{ secrets.STEAMCMD_USER }}\"\nsteampass='${{ secrets.STEAMCMD_PASS }}'" > lgsm/config-lgsm/${{ matrix.shortname }}server/common.cfg
- name: Install server
run: LGSM_GITHUBBRANCH="${GITHUB_REF#refs/heads/}" ./${{ matrix.shortname }}server auto-install
- name: Check Update server
run: LGSM_GITHUBBRANCH="${GITHUB_REF#refs/heads/}" ./${{ matrix.shortname }}server check-update
- name: Update server
run: LGSM_GITHUBBRANCH="${GITHUB_REF#refs/heads/}" ./${{ matrix.shortname }}server update
- name: Force Update server
if: matrix.shortname == 'css'
run: LGSM_GITHUBBRANCH="${GITHUB_REF#refs/heads/}" ./${{ matrix.shortname }}server force-update

View File

@ -17,19 +17,19 @@ core_logs.sh
if [ "${shortname}" == "ts3" ]; then
update_ts3.sh
elif [ "${shortname}" == "mc" ]; then
update_minecraft.sh
update_mc.sh
elif [ "${shortname}" == "mcb" ]; then
update_minecraft_bedrock.sh
update_mcb.sh
elif [ "${shortname}" == "pmc" ] || [ "${shortname}" == "vpmc" ] || [ "${shortname}" == "wmc" ]; then
update_papermc.sh
update_pmc.sh
elif [ "${shortname}" == "fctr" ]; then
update_factorio.sh
update_fctr.sh
elif [ "${shortname}" == "mta" ]; then
update_mta.sh
elif [ "${shortname}" == "jk2" ]; then
update_jediknight2.sh
update_jk2.sh
elif [ "${shortname}" == "vints" ]; then
update_vintagestory.sh
update_vints.sh
elif [ "${shortname}" == "ut99" ]; then
update_ut99.sh
else

View File

@ -18,19 +18,19 @@ check_last_update.sh
if [ "${shortname}" == "ts3" ]; then
update_ts3.sh
elif [ "${shortname}" == "mc" ]; then
update_minecraft.sh
update_mc.sh
elif [ "${shortname}" == "mcb" ]; then
update_minecraft_bedrock.sh
update_mcb.sh
elif [ "${shortname}" == "pmc" ] || [ "${shortname}" == "vpmc" ] || [ "${shortname}" == "wmc" ]; then
update_papermc.sh
update_pmc.sh
elif [ "${shortname}" == "fctr" ]; then
update_factorio.sh
update_fctr.sh
elif [ "${shortname}" == "mta" ]; then
update_mta.sh
elif [ "${shortname}" == "jk2" ]; then
update_jediknight2.sh
update_jk2.sh
elif [ "${shortname}" == "vints" ]; then
update_vintagestory.sh
update_vints.sh
elif [ "${shortname}" == "ut99" ]; then
update_ut99.sh
else

View File

@ -640,17 +640,17 @@ update_ts3.sh() {
fn_fetch_function
}
update_minecraft.sh() {
update_mc.sh() {
functionfile="${FUNCNAME[0]}"
fn_fetch_function
}
update_minecraft_bedrock.sh() {
update_mcb.sh() {
functionfile="${FUNCNAME[0]}"
fn_fetch_function
}
update_papermc.sh() {
update_pmc.sh() {
functionfile="${FUNCNAME[0]}"
fn_fetch_function
}
@ -660,12 +660,12 @@ update_mta.sh() {
fn_fetch_function
}
update_factorio.sh() {
update_fctr.sh() {
functionfile="${FUNCNAME[0]}"
fn_fetch_function
}
update_jediknight2.sh() {
update_jk2.sh() {
functionfile="${FUNCNAME[0]}"
fn_fetch_function
}
@ -675,7 +675,7 @@ update_steamcmd.sh() {
fn_fetch_function
}
update_vintagestory.sh() {
update_vints.sh() {
functionfile="${FUNCNAME[0]}"
fn_fetch_function
}

View File

@ -645,17 +645,17 @@ update_ts3.sh() {
fn_fetch_module
}
update_minecraft.sh() {
update_mc.sh() {
modulefile="${FUNCNAME[0]}"
fn_fetch_module
}
update_minecraft_bedrock.sh() {
update_mcb.sh() {
modulefile="${FUNCNAME[0]}"
fn_fetch_module
}
update_papermc.sh() {
update_pmc.sh() {
modulefile="${FUNCNAME[0]}"
fn_fetch_module
}
@ -665,12 +665,12 @@ update_mta.sh() {
fn_fetch_module
}
update_factorio.sh() {
update_fctr.sh() {
modulefile="${FUNCNAME[0]}"
fn_fetch_module
}
update_jediknight2.sh() {
update_jk2.sh() {
modulefile="${FUNCNAME[0]}"
fn_fetch_module
}
@ -680,7 +680,7 @@ update_steamcmd.sh() {
fn_fetch_module
}
update_vintagestory.sh() {
update_vints.sh() {
modulefile="${FUNCNAME[0]}"
fn_fetch_module
}

View File

@ -151,11 +151,6 @@ fn_update_steamcmd_localbuild() {
# Uses appmanifest to find local build.
localbuild=$(grep buildid "${appmanifestfile}" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3)
# Set branch to public if no custom branch.
if [ -z "${branch}" ]; then
branch="public"
fi
# Checks if localbuild variable has been set.
if [ -z "${localbuild}" ]; then
fn_print_fail "Checking local build: ${remotelocation}: missing local build info"
@ -178,6 +173,13 @@ fn_update_steamcmd_remotebuild() {
find "${HOME}" -type f -name "appinfo.vdf" -exec rm -f {} \; 2> /dev/null
fi
# Set branch to public if no custom branch.
if [ -z "${branch}" ]; then
branch="public"
fi
# added as was failing GitHub Actions test. Running SteamCMD twice seems to fix it.
${steamcmdcommand} +login "${steamuser}" "${steampass}" +app_info_update 1 +quit 2> /dev/null
# password for branch not needed to check the buildid
remotebuildversion=$(${steamcmdcommand} +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +quit | sed -e '/"branches"/,/^}/!d' | sed -n "/\"${branch}\"/,/}/p" | grep -m 1 buildid | tr -cd '[:digit:]')

View File

@ -64,7 +64,7 @@ fn_default_config_local() {
# PASSWORD to random password
fn_set_config_vars() {
if [ -f "${servercfgfullpath}" ]; then
random=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 8 | xargs)
random=$(tr -dc 'A-Za-z0-9_' < /dev/urandom 2>/dev/null | head -c 8 | xargs)
servername="LinuxGSM"
rconpass="admin${random}"
echo -e "changing hostname."

View File

@ -221,23 +221,23 @@ if [ "${shortname}" == "ts3" ]; then
update_ts3.sh
elif [ "${shortname}" == "mc" ]; then
install_eula.sh
update_minecraft.sh
update_mc.sh
elif [ "${shortname}" == "mcb" ]; then
update_minecraft_bedrock.sh
update_mcb.sh
elif [ "${shortname}" == "pmc" ]; then
install_eula.sh
update_papermc.sh
update_pmc.sh
elif [ "${shortname}" == "wmc" ] || [ "${shortname}" == "vpmc" ]; then
update_papermc.sh
update_pmc.sh
elif [ "${shortname}" == "mta" ]; then
update_mta.sh
elif [ "${shortname}" == "fctr" ]; then
update_factorio.sh
update_fctr.sh
install_factorio_save.sh
elif [ "${shortname}" == "jk2" ]; then
update_jediknight2.sh
update_jk2.sh
elif [ "${shortname}" == "vints" ]; then
update_vintagestory.sh
update_vints.sh
elif [ "${shortname}" == "ut99" ]; then
fn_install_server_files
update_ut99.sh

View File

@ -1,5 +1,5 @@
#!/bin/bash
# LinuxGSM update_factorio.sh module
# LinuxGSM update_fctr.sh module
# Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com

View File

@ -1,5 +1,5 @@
#!/bin/bash
# LinuxGSM update_minecraft.sh module
# LinuxGSM update_mc.sh module
# Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com

View File

@ -1,5 +1,5 @@
#!/bin/bash
# LinuxGSM update_minecraft_bedrock.sh module
# LinuxGSM update_mcb.sh module
# Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com

View File

@ -1,5 +1,5 @@
#!/bin/bash
# LinuxGSM update_papermc.sh module
# LinuxGSM update_pmc.sh module
# Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com

View File

@ -1,5 +1,5 @@
#!/bin/bash
# LinuxGSM update_vintagestory.sh module
# LinuxGSM update_vints.sh module
# Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com