From e61a38bc5c6e21faba16949dcac7c1f3c406cf97 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Apr 2023 10:43:54 +0100 Subject: [PATCH 1/9] build(deps): bump webfactory/ssh-agent from 0.7.0 to 0.8.0 (#4151) * chore: auto add game server requests to gh project * build(deps): bump webfactory/ssh-agent from 0.7.0 to 0.8.0 Bumps [webfactory/ssh-agent](https://github.com/webfactory/ssh-agent) from 0.7.0 to 0.8.0. - [Release notes](https://github.com/webfactory/ssh-agent/releases) - [Changelog](https://github.com/webfactory/ssh-agent/blob/master/CHANGELOG.md) - [Commits](https://github.com/webfactory/ssh-agent/compare/v0.7.0...v0.8.0) --- updated-dependencies: - dependency-name: webfactory/ssh-agent dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: Daniel Gibbs Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/add-to-project.yml | 17 +++++++++++++++++ .github/workflows/git-sync.yml | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/add-to-project.yml diff --git a/.github/workflows/add-to-project.yml b/.github/workflows/add-to-project.yml new file mode 100644 index 000000000..56a42c729 --- /dev/null +++ b/.github/workflows/add-to-project.yml @@ -0,0 +1,17 @@ +name: Add to project +on: + issues: + types: + - opened + - labeled + +jobs: + add-to-project: + name: Add game server requests to project + runs-on: ubuntu-latest + steps: + - uses: actions/add-to-project@v0.4.0 + with: + project-url: https://github.com/orgs/GameServerManagers/projects/11 + github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} + labeled: "type: game server request" diff --git a/.github/workflows/git-sync.yml b/.github/workflows/git-sync.yml index f07d1f3b4..e013ae32d 100644 --- a/.github/workflows/git-sync.yml +++ b/.github/workflows/git-sync.yml @@ -10,8 +10,8 @@ jobs: GitHub-to-Bitbucket: runs-on: ubuntu-latest steps: - - name: webfactory/ssh-agent@v0.7.0 - uses: webfactory/ssh-agent@v0.7.0 + - name: webfactory/ssh-agent@v0.8.0 + uses: webfactory/ssh-agent@v0.8.0 with: ssh-private-key: ${{ secrets.BITBUCKET_SECRET }} From 5377762ef0cc4ab7556ac11dd44821296f668f7f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Apr 2023 10:45:28 +0100 Subject: [PATCH 2/9] build(deps): bump convictional/trigger-workflow-and-wait from 1.3.0 to 1.6.5 (#4100) * chore: auto add game server requests to gh project * build(deps): bump convictional/trigger-workflow-and-wait Bumps [convictional/trigger-workflow-and-wait](https://github.com/convictional/trigger-workflow-and-wait) from 1.3.0 to 1.6.5. - [Release notes](https://github.com/convictional/trigger-workflow-and-wait/releases) - [Commits](https://github.com/convictional/trigger-workflow-and-wait/compare/v1.3.0...v1.6.5) --- updated-dependencies: - dependency-name: convictional/trigger-workflow-and-wait dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: Daniel Gibbs Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/trigger-docker-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/trigger-docker-build.yml b/.github/workflows/trigger-docker-build.yml index adb43343f..dec3dd462 100644 --- a/.github/workflows/trigger-docker-build.yml +++ b/.github/workflows/trigger-docker-build.yml @@ -8,7 +8,7 @@ jobs: name: Trigger Build docker-linuxgsm runs-on: ubuntu-latest steps: - - uses: convictional/trigger-workflow-and-wait@v1.3.0 + - uses: convictional/trigger-workflow-and-wait@v1.6.5 with: owner: GameServerManagers repo: docker-linuxgsm @@ -19,7 +19,7 @@ jobs: name: Trigger Build docker-linuxgsm runs-on: ubuntu-latest steps: - - uses: convictional/trigger-workflow-and-wait@v1.3.0 + - uses: convictional/trigger-workflow-and-wait@v1.6.5 with: owner: GameServerManagers repo: docker-gameserver From 483498d5190e54fa669affa3a25d3ac639f44326 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Apr 2023 10:45:52 +0100 Subject: [PATCH 3/9] build(deps): bump actions/add-to-project from 0.4.0 to 0.4.1 (#4126) * chore: auto add game server requests to gh project * build(deps): bump actions/add-to-project from 0.4.0 to 0.4.1 Bumps [actions/add-to-project](https://github.com/actions/add-to-project) from 0.4.0 to 0.4.1. - [Release notes](https://github.com/actions/add-to-project/releases) - [Commits](https://github.com/actions/add-to-project/compare/v0.4.0...v0.4.1) --- updated-dependencies: - dependency-name: actions/add-to-project dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: Daniel Gibbs Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/add-to-project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add-to-project.yml b/.github/workflows/add-to-project.yml index 56a42c729..8e71d1cb5 100644 --- a/.github/workflows/add-to-project.yml +++ b/.github/workflows/add-to-project.yml @@ -10,7 +10,7 @@ jobs: name: Add game server requests to project runs-on: ubuntu-latest steps: - - uses: actions/add-to-project@v0.4.0 + - uses: actions/add-to-project@v0.4.1 with: project-url: https://github.com/orgs/GameServerManagers/projects/11 github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} From 52ed09c1bbd226d48711f6a77780ed5fa6020063 Mon Sep 17 00:00:00 2001 From: jusito <17811819+jusito@users.noreply.github.com> Date: Sat, 1 Apr 2023 16:44:27 +0200 Subject: [PATCH 4/9] fix(gamedig): default exitcode & var name (#4161) --- lgsm/functions/query_gamedig.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/query_gamedig.sh b/lgsm/functions/query_gamedig.sh index 43f748bcc..265607acd 100755 --- a/lgsm/functions/query_gamedig.sh +++ b/lgsm/functions/query_gamedig.sh @@ -7,7 +7,7 @@ # https://github.com/sonicsnes/node-gamedig functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" - +querystatus="2" # Check if gamedig and jq are installed. if [ "$(command -v gamedig 2> /dev/null)" ] && [ "$(command -v jq 2> /dev/null)" ]; then @@ -81,7 +81,7 @@ if [ "$(command -v gamedig 2> /dev/null)" ] && [ "$(command -v jq 2> /dev/null)" # server version. if [ "${querytype}" == "teamspeak3" ]; then - dversion=$(echo "${gamedigraw}" | jq -re '.raw.virtualserver_version') + gdversion=$(echo "${gamedigraw}" | jq -re '.raw.virtualserver_version') else gdversion=$(echo "${gamedigraw}" | jq -re '.raw.version') fi From 4c717c5b94e5c9e10abd7b03d7230fdadc3eb3bf Mon Sep 17 00:00:00 2001 From: jusito <17811819+jusito@users.noreply.github.com> Date: Sat, 1 Apr 2023 23:32:56 +0200 Subject: [PATCH 5/9] fix(details): port output with whitespaces (#4160) --- lgsm/functions/info_messages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/info_messages.sh b/lgsm/functions/info_messages.sh index 69123543a..5478987f1 100755 --- a/lgsm/functions/info_messages.sh +++ b/lgsm/functions/info_messages.sh @@ -773,7 +773,7 @@ fn_port() { portname="${1}" porttype="${2}" portprotocol="${3}" - echo -e "${portname}\t${!porttype}\t${portprotocol}\t$(echo "${ssinfo}" | grep ${portprotocol} | grep ${!porttype} | wc -l)" + echo -e "${portname}\t${!porttype}\t${portprotocol}\t$(echo "${ssinfo}" | grep "${portprotocol}" | grep -c "${!porttype}")" fi } From 75852abb42c842b60e61b5cf39d32f8d057b4312 Mon Sep 17 00:00:00 2001 From: jusito <17811819+jusito@users.noreply.github.com> Date: Sat, 1 Apr 2023 23:37:10 +0200 Subject: [PATCH 6/9] fix(core): unhandled curl fail (#4159) --- lgsm/functions/core_dl.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index d19425ac5..53a60cc1a 100755 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -383,17 +383,21 @@ fn_fetch_file() { fi # Trap will remove part downloaded files if canceled. trap fn_fetch_trap INT - # Larger files show a progress bar. - if [ "${local_filename##*.}" == "bz2" ] || [ "${local_filename##*.}" == "gz" ] || [ "${local_filename##*.}" == "zip" ] || [ "${local_filename##*.}" == "jar" ] || [ "${local_filename##*.}" == "xz" ]; then - echo -e "downloading ${local_filename}..." - fn_sleep_time - curlcmd=$(curl --connect-timeout 10 --progress-bar --fail -L -o "${local_filedir}/${local_filename}" "${fileurl}") - local exitcode=$? + curlcmd=(curl --connect-timeout 10 --fail -L -o "${local_filedir}/${local_filename}" --retry 2) + + # if is large file show progress, else be silent + local exitcode="" + large_files=("bz2" "gz" "zip" "jar" "xz") + if grep -qE "(^|\s)${local_filename##*.}(\s|$)" <<< "${large_files[@]}"; then echo -en "downloading ${local_filename}..." + fn_sleep_time + echo -en "\033[1K" + "${curlcmd[@]}" --progress-bar "${fileurl}" 2>&1 + exitcode="$?" else - curlcmd=$(curl --connect-timeout 10 -s --fail -L -o "${local_filedir}/${local_filename}" "${fileurl}") - local exitcode=$? echo -en "fetching ${fileurl_name} ${local_filename}...\c" + "${curlcmd[@]}" --silent --show-error "${fileurl}" 2>&1 + exitcode="$?" fi # Download will fail if downloads a html file. From 2fcc919d82434491697b2bd70731d479dc2734f8 Mon Sep 17 00:00:00 2001 From: jusito <17811819+jusito@users.noreply.github.com> Date: Sat, 1 Apr 2023 23:38:09 +0200 Subject: [PATCH 7/9] fix: check localhost ip first on fallback (#4158) --- lgsm/functions/check_ip.sh | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/lgsm/functions/check_ip.sh b/lgsm/functions/check_ip.sh index fc5d70f2c..bf301008f 100755 --- a/lgsm/functions/check_ip.sh +++ b/lgsm/functions/check_ip.sh @@ -26,32 +26,37 @@ for ethtool_command in "${ethtool_commands_array[@]}"; do fi done -getip=$(${ipcommand} -o -4 addr | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}' | sort -u | grep -v 127.0.0) -getipwc=$(${ipcommand} -o -4 addr | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}' | sort -u | grep -vc 127.0.0) +mapfile -t current_ips < <(${ipcommand} -o -4 addr | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}' | sort -u | grep -v 127.0.0) + +function fn_is_valid_ip() { + local ip="${1}" + # excluding 0.* ips also + grep -qEe '^[1-9]+[0-9]*\.[0-9]+\.[0-9]+\.[0-9]+$' <<< "${ip}" +} # Check if server has multiple IP addresses # If the IP variable has been set by user. -if [ -n "${ip}" ] && [ "${ip}" != "0.0.0.0" ]; then - queryips=("${ip}") - webadminip=("${ip}") - telnetip=("${ip}") +if fn_is_valid_ip "${ip}"; then + queryips=( "${ip}" ) + webadminip=( "${ip}" ) + telnetip=( "${ip}" ) # If game config does have an IP set. -elif [ -n "${configip}" ] && [ "${configip}" != "0.0.0.0" ]; then - queryips=("${configip}") +elif fn_is_valid_ip "${configip}";then + queryips=( "${configip}" ) ip="${configip}" webadminip=("${configip}") telnetip=("${configip}") # If there is only 1 server IP address. # Some IP details can automaticly use the one IP -elif [ "${getipwc}" == "1" ]; then - queryips=($(echo "${getip}")) +elif [ "${#current_ips[@]}" == "1" ]; then + queryips=( "127.0.0.1" "${current_ips[@]}" ) ip="0.0.0.0" - webadminip=("${getip}") - telnetip=("${getip}") + webadminip=("${current_ips[@]}") + telnetip=("${current_ips[@]}") # If no ip is set by the user and server has more than one IP. else - queryips=($(echo "${getip}")) + queryips=( "127.0.0.1" "${current_ips[@]}" ) ip="0.0.0.0" webadminip=("${ip}") telnetip=("${ip}") From 4fc6280ccad2ae0a57a051f71684e0386863b9b0 Mon Sep 17 00:00:00 2001 From: jusito <17811819+jusito@users.noreply.github.com> Date: Sat, 1 Apr 2023 23:44:34 +0200 Subject: [PATCH 8/9] refactor(fix.sh): removed error prone code (#4157) * refactor: removed error prone code * prettier --------- Co-authored-by: Daniel Gibbs --- lgsm/functions/fix.sh | 117 +++++++++++++----------------------------- 1 file changed, 37 insertions(+), 80 deletions(-) diff --git a/lgsm/functions/fix.sh b/lgsm/functions/fix.sh index 60a96059d..57f6a91fa 100755 --- a/lgsm/functions/fix.sh +++ b/lgsm/functions/fix.sh @@ -31,101 +31,58 @@ fn_fix_msg_end() { fi } +fn_exists_fix() { + local short="${1:?}" + + if [ "$(type -t "fix_${short}.sh")" == 'function' ]; then + return 0 + else + return 1 + fi +} + +fn_apply_fix() { + local phase_message="${1:?}" + local short="${2:?}" + + if fn_exists_fix "${short}"; then + "fix_${short}.sh" + else + fn_print_error_nl "${shortname} is marked to apply pre start fix but there is no fix registered" + fi +} + +apply_pre_start_fix=(arma3 armar ark av bt bo csgo cmw dst hw ins nmrih onset rust rw sdtd sfc sof2 squad st tf2 terraria ts3 mcb mta unt vh wurm zmr) +apply_post_install_fix=(av kf kf2 lo ro samp ut2k4 ut ut3) + +# validate registered fixes for safe development +for fix in "${apply_pre_start_fix[@]}" "${apply_post_install_fix[@]}"; do + if ! fn_exists_fix "${fix}"; then + fn_print_fail_nl "fix_${fix}.sh is registered but doesn't exist. Typo or did you miss to modify core_functions.sh?" + exitcode 1 + core_exit.sh + fi +done + # Fixes that are run on start. if [ "${commandname}" != "INSTALL" ] && [ -z "${fixbypass}" ]; then if [ "${appid}" ]; then fix_steamcmd.sh fi - if [ "${shortname}" == "arma3" ]; then - fix_arma3.sh - elif [ "${shortname}" == "armar" ]; then - fix_armar.sh - elif [ "${shortname}" == "ark" ]; then - fix_ark.sh - elif [ "${shortname}" == "av" ]; then - fix_av.sh - elif [ "${shortname}" == "bt" ]; then - fix_bt.sh - elif [ "${shortname}" == "bo" ]; then - fix_bo.sh - elif [ "${shortname}" == "csgo" ]; then - fix_csgo.sh - elif [ "${shortname}" == "cmw" ]; then - fix_cmw.sh - elif [ "${shortname}" == "dst" ]; then - fix_dst.sh - elif [ "${shortname}" == "hw" ]; then - fix_hw.sh - elif [ "${shortname}" == "ins" ]; then - fix_ins.sh - elif [ "${shortname}" == "nmrih" ]; then - fix_nmrih.sh - elif [ "${shortname}" == "onset" ]; then - fix_onset.sh - elif [ "${shortname}" == "rust" ]; then - fix_rust.sh - elif [ "${shortname}" == "rw" ]; then - fix_rw.sh - elif [ "${shortname}" == "sdtd" ]; then - fix_sdtd.sh - elif [ "${shortname}" == "sfc" ]; then - fix_sfc.sh - elif [ "${shortname}" == "sof2" ]; then - fix_sof2.sh - elif [ "${shortname}" == "squad" ]; then - fix_squad.sh - elif [ "${shortname}" == "st" ]; then - fix_st.sh - elif [ "${shortname}" == "tf2" ]; then - fix_tf2.sh - elif [ "${shortname}" == "terraria" ]; then - fix_terraria.sh - elif [ "${shortname}" == "ts3" ]; then - fix_ts3.sh - elif [ "${shortname}" == "mcb" ]; then - fix_mcb.sh - elif [ "${shortname}" == "mta" ]; then - fix_mta.sh - elif [ "${shortname}" == "unt" ]; then - fix_unt.sh - elif [ "${shortname}" == "vh" ]; then - fix_vh.sh - elif [ "${shortname}" == "wurm" ]; then - fix_wurm.sh - elif [ "${shortname}" == "zmr" ]; then - fix_zmr.sh + if grep -qEe "(^|\s)${shortname}(\s|$)" <<< "${apply_pre_start_fix[@]}"; then + fn_apply_fix "pre start" "${shortname}" fi fi # Fixes that are run on install only. if [ "${commandname}" == "INSTALL" ]; then - if [ "${shortname}" == "av" ] || [ "${shortname}" == "cmw" ] || [ "${shortname}" == "kf" ] || [ "${shortname}" == "kf2" ] || [ "${shortname}" == "lo" ] || [ "${shortname}" == "onset" ] || [ "${shortname}" == "ro" ] || [ "${shortname}" == "samp" ] || [ "${shortname}" == "ut2k4" ] || [ "${shortname}" == "ut" ] || [ "${shortname}" == "ut3" ]; then + if grep -qEe "(^|\s)${shortname}(\s|$)" <<< "${apply_post_install_fix[@]}"; then echo -e "" echo -e "${lightyellow}Applying Post-Install Fixes${default}" echo -e "=================================" fn_sleep_time postinstall=1 - if [ "${shortname}" == "av" ]; then - fix_av.sh - elif [ "${shortname}" == "kf" ]; then - fix_kf.sh - elif [ "${shortname}" == "kf2" ]; then - fix_kf2.sh - elif [ "${shortname}" == "lo" ]; then - fix_lo.sh - elif [ "${shortname}" == "ro" ]; then - fix_ro.sh - elif [ "${shortname}" == "samp" ]; then - fix_samp.sh - elif [ "${shortname}" == "ut2k4" ]; then - fix_ut2k4.sh - elif [ "${shortname}" == "ut" ]; then - fix_ut.sh - elif [ "${shortname}" == "ut3" ]; then - fix_ut3.sh - else - fn_print_information_nl "No fixes required." - fi + fn_apply_fix "post install" "${shortname}" fi fi From 6b7267bbf028e0a013c3f51a29330a8f60331e21 Mon Sep 17 00:00:00 2001 From: jusito <17811819+jusito@users.noreply.github.com> Date: Sat, 1 Apr 2023 23:56:43 +0200 Subject: [PATCH 9/9] fix: install successful without installation files (#4156) * fix: install successful without files * use fn_script_log_fatal --------- Co-authored-by: Daniel Gibbs --- lgsm/functions/install_server_files.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index 9316d6efd..e550e1455 100755 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -197,6 +197,9 @@ fn_install_server_files() { chmodx="nochmodx" run="norun" force="noforce" md5="0188ae86dbc9376f11ae3032dba2d665" + else + fn_print_fail_nl "Installing ${gamename} Server failed, missing default configuration" + fn_script_log_fatal "Installing ${gamename} Server failed, missing default configuration" fi fn_fetch_file "${remote_fileurl}" "" "" "" "${local_filedir}" "${local_filename}" "${chmodx}" "${run}" "${forcedl}" "${md5}" fn_dl_extract "${local_filedir}" "${local_filename}" "${serverfiles}"