Browse Source

Merge branch 'develop' into fix/monitor-exitcode

pull/4155/head
Daniel Gibbs 2 years ago
parent
commit
b84bce4228
  1. 17
      .github/workflows/add-to-project.yml
  2. 4
      .github/workflows/git-sync.yml
  3. 4
      .github/workflows/trigger-docker-build.yml
  4. 23
      lgsm/functions/check_ip.sh
  5. 20
      lgsm/functions/core_dl.sh
  6. 117
      lgsm/functions/fix.sh
  7. 2
      lgsm/functions/info_messages.sh
  8. 3
      lgsm/functions/install_server_files.sh
  9. 4
      lgsm/functions/query_gamedig.sh

17
.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.1
with:
project-url: https://github.com/orgs/GameServerManagers/projects/11
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
labeled: "type: game server request"

4
.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 }}

4
.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

23
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
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
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}")

20
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.

117
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

2
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
}

3
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}"

4
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

Loading…
Cancel
Save