Browse Source

Merge branch 'develop' into feature/data-refactor

pull/2217/head
Daniel Gibbs 7 years ago
parent
commit
fff01aa22c
  1. 3
      .travis.yml
  2. 2
      lgsm/config-default/config-lgsm/inssserver/_default.cfg
  3. 2
      lgsm/config-default/config-lgsm/ts3server/_default.cfg
  4. 27
      lgsm/functions/command_monitor.sh
  5. 1
      lgsm/functions/info_parms.sh
  6. 2
      lgsm/functions/query_gamedig.sh
  7. 2
      lgsm/functions/query_gsquery.py
  8. 78
      lgsm/functions/update_factorio.sh
  9. 89
      lgsm/functions/update_ts3.sh

3
.travis.yml

@ -1,7 +1,6 @@
language: bash
language: bash node_js
dist: xenial
sudo: required
language: node_js
node_js:
- 10
before_script:

2
lgsm/config-default/config-lgsm/inssserver/_default.cfg

@ -23,7 +23,7 @@ maxplayers="28"
fn_parms(){
# Allows serverpassword to work with parameters
if [ "${serverpassword}" != "NOT SET" ]; then
parms="${defaultmap}?Scenario=${defaultscenario}?MaxPlayers=${maxplayers}?Port=${port}?QueryPort=${queryport}?password="${serverpassword}" -hostname="${servername}" -log"
parms="${defaultmap}?Scenario=${defaultscenario}?MaxPlayers=${maxplayers}?Port=${port}?QueryPort=${queryport}?password="${serverpassword}" -hostname='${servername}' -log"
else
parms="${defaultmap}?Scenario=${defaultscenario}?MaxPlayers=${maxplayers}?Port=${port}?QueryPort=${queryport} -hostname='${servername}' -log"
fi

2
lgsm/config-default/config-lgsm/ts3server/_default.cfg

@ -7,7 +7,7 @@
# [instance].cfg - applies settings to a specific instance
## Server Start Settings | https://docs.linuxgsm.com/configuration/start-parameters
# Edit serverfiles/ts3-server.ini after installation
# Edit serverfiles/ts3server.ini after installation
#### LinuxGSM Settings ####

27
lgsm/functions/command_monitor.sh

@ -3,7 +3,7 @@
# Author: Daniel Gibbs
# Contributor: UltimateByte
# Website: https://linuxgsm.com
# Description: Monitors server by checking for running processes.
# Description: Monitors server by checking for running processes
# then passes to gamedig and gsquery.
local commandname="MONITOR"
@ -11,7 +11,7 @@ local commandaction="Monitor"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_monitor_loop(){
# Will query up to 5 times every 15 seconds.
# Monitor will query up to 5 times every 15 seconds.
# Query will wait up to 60 seconds to confirm server is down giving server time if changing map.
totalseconds=0
for queryattempt in {1..5}; do
@ -33,7 +33,7 @@ for queryattempt in {1..5}; do
fi
if [ "${querystatus}" == "0" ]; then
# Server query OK
# Server query OK.
sleep 0.5
fn_print_ok "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: "
fn_print_ok_eol_nl
@ -42,21 +42,21 @@ for queryattempt in {1..5}; do
monitorpass=1
core_exit.sh
else
# Server query FAIL
# Server query FAIL.
fn_script_log_info "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt}: FAIL"
fn_print_fail "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: "
fn_print_fail_eol
sleep 0.5
# monitor try gamedig first then gsquery before restarting
# Monitor try gamedig first then gsquery before restarting.
if [ "${querymethod}" == "gsquery" ]; then
if [ "${totalseconds}" -ge "59" ]; then
# Server query FAIL for over 59 seconds reboot server
# Server query FAIL for over 59 seconds reboot server.
fn_print_fail "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: "
fn_print_fail_eol_nl
fn_script_log_error "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt}: FAIL"
sleep 0.5
# Send alert if enabled
# Send alert if enabled.
alert="restartquery"
alert.sh
command_restart.sh
@ -68,7 +68,7 @@ for queryattempt in {1..5}; do
fi
fi
# Seconds counter
# Seconds counter.
for seconds in {1..15}; do
fn_print_fail "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: WAIT"
totalseconds=$((totalseconds + 1))
@ -82,7 +82,7 @@ done
}
fn_monitor_check_lockfile(){
# Monitor does not run it lockfile is not found
# Monitor does not run it lockfile is not found.
if [ ! -f "${rootdir}/${lockselfname}" ]; then
fn_print_error_nl "Disabled: No lockfile found"
fn_script_log_error "Disabled: No lockfile found"
@ -131,8 +131,8 @@ fn_monitor_check_session(){
fn_monitor_query(){
fn_script_log_info "Querying port: query enabled"
# engines that work with query
local allowed_engines_array=( avalanche2.0 avalanche3.0 goldsource idtech2 idtech3 idtech3_ql iw2.0 iw3.0 lwjgl2 madness quake refractor realvirtuality source spark starbound unity3d unreal unreal2 unreal4 wurm )
# Engines that work with query.
local allowed_engines_array=( avalanche2.0 avalanche3.0 goldsource idtech2 idtech3 idtech3_ql ioquake3 iw2.0 iw3.0 lwjgl2 madness quake refractor realvirtuality source spark starbound unity3d unreal unreal2 unreal4 wurm )
for allowed_engine in "${allowed_engines_array[@]}"
do
if [ "${allowed_engine}" == "${engine}" ]; then
@ -142,7 +142,7 @@ fn_monitor_query(){
local engine="unreal4"
fi
# will first attempt to use gamedig then gsquery
# Will first attempt to use gamedig then gsquery.
totalseconds=0
if [ "${shortname}" == "wurm" ]; then
local query_methods_array=( gsquery )
@ -152,7 +152,7 @@ fn_monitor_query(){
for query_method in "${query_methods_array[@]}"
do
if [ "${query_method}" == "gamedig" ]; then
# will bypass gamedig if not installed
# Will bypass gamedig if not installed.
if [ "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ]; then
if [ -z "${monitorpass}" ]; then
querymethod="${query_method}"
@ -196,5 +196,4 @@ elif [ "${shortname}" == "ts3" ]||[ "${shortname}" == "eco" ]||[ "${shortname}"
else
fn_monitor_query
fi
core_exit.sh

1
lgsm/functions/info_parms.sh

@ -95,6 +95,7 @@ fn_info_parms_risingworld(){
fn_info_parms_rtcw(){
port=${port:-"0"}
queryport="${port}"
defaultmap=${defaultmap:-"NOT SET"}
}

2
lgsm/functions/query_gamedig.sh

@ -46,7 +46,7 @@ if [ "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ];
fi
done
local engine_query_array=( idtech3 iw3.0 )
local engine_query_array=( idtech3 iw3.0 ioquake3 )
for engine_query in "${engine_query_array[@]}"
do
if [ "${engine_query}" == "${engine}" ]; then

2
lgsm/functions/query_gsquery.py

@ -18,7 +18,7 @@ class gsquery:
self.default_buffer_length = 1024
#
sourcequery=[ 'avalanche3.0','madness','quakelive','realvirtuality','refractor','source','goldsource','spark','starbound','unity3d', 'unreal4', 'wurm' ]
idtech3query=['idtech3','iw3.0']
idtech3query=['idtech3','iw3.0','ioquake3']
idtech2query=['idtech2','quake','iw2.0']
minecraftquery=['minecraft','lwjgl2']
if self.option.engine in sourcequery:

78
lgsm/functions/update_factorio.sh

@ -10,11 +10,6 @@ local commandaction="Update"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_update_factorio_dl(){
if [ "${branch}" == "stable" ]; then
downloadbranch="stable"
elif [ "${branch}" == "experimental" ]; then
downloadbranch="latest"
fi
fn_fetch_file "https://factorio.com/get-download/${downloadbranch}/headless/${factorioarch}" "${tmpdir}" "factorio_headless_${factorioarch}-${availablebuild}.tar.xz"
fn_dl_extract "${tmpdir}" "factorio_headless_${factorioarch}-${availablebuild}.tar.xz" "${tmpdir}"
echo -e "copying to ${serverfiles}...\c"
@ -29,13 +24,23 @@ fn_update_factorio_dl(){
}
fn_update_factorio_currentbuild(){
# Gets current build info
# Checks if current build info is available. If it fails, then a server restart will be forced to generate logs.
if [ ! -f "${serverfiles}/factorio-current.log" ]; then
# Get current build info.
# If log file is missing, the server will restart to generate logs.
if [ -f "${serverfiles}/factorio-current.log" ]; then
currentbuild=$(grep "Loading mod base" "${serverfiles}/factorio-current.log" 2> /dev/null | awk '{print $5}' | tail -1)
fi
if [ -z "${currentbuild}" ]; then
fn_print_error "Checking for update: factorio.com"
sleep 0.5
fn_print_error_nl "Checking for update: factorio.com: No logs with server version found"
fn_script_log_error "Checking for update: factorio.com: No logs with server version found"
if [ ! -f "${serverfiles}/factorio-current.log" ]; then
fn_print_error_nl "Checking for update: factorio.com: No logs with server version found"
fn_script_log_error "Checking for update: factorio.com: No logs with server version found"
elif [ -z "${currentbuild}" ]; then
fn_print_error_nl "Checking for update: factorio.com: Current build version not found"
fn_script_log_error "Checking for update: factorio.com: Current build version not found"
fi
sleep 0.5
fn_print_info_nl "Checking for update: factorio.com: Forcing server restart"
fn_script_log_info "Checking for update: factorio.com: Forcing server restart"
@ -45,28 +50,17 @@ fn_update_factorio_currentbuild(){
exitbypass=1
command_start.sh
sleep 0.5
# Check again and exit on failure.
# Check again and exit if failure.
if [ -f "${serverfiles}/factorio-current.log" ]; then
currentbuild=$(grep "Loading mod base" "${serverfiles}/factorio-current.log" 2> /dev/null | awk '{print $5}' | tail -1)
fi
if [ ! -f "${serverfiles}/factorio-current.log" ]; then
fn_print_fail_nl "Checking for update: factorio.com: Still No logs with server version found"
fn_script_log_fatal "Checking for update: factorio.com: Still No logs with server version found"
core_exit.sh
fi
fi
# Get current build from logs
currentbuild=$(grep "Loading mod base" "${serverfiles}/factorio-current.log" 2> /dev/null | awk '{print $5}' | tail -1)
if [ -z "${currentbuild}" ]; then
fn_print_error_nl "Checking for update: factorio.com: Current build version not found"
fn_script_log_error "Checking for update: factorio.com: Current build version not found"
sleep 0.5
fn_print_info_nl "Checking for update: factorio.com: Forcing server restart"
fn_script_log_info "Checking for update: factorio.com: Forcing server restart"
exitbypass=1
command_stop.sh
exitbypass=1
command_start.sh
currentbuild=$(grep "Loading mod base" "${serverfiles}/factorio-current.log" 2> /dev/null | awk '{print $5}' | tail -1)
if [ -z "${currentbuild}" ]; then
elif [ -z "${currentbuild}" ]; then
fn_print_fail_nl "Checking for update: factorio.com: Current build version still not found"
fn_script_log_fatal "Checking for update: factorio.com: Current build version still not found"
core_exit.sh
@ -74,20 +68,12 @@ fn_update_factorio_currentbuild(){
fi
}
fn_update_factorio_arch(){
# Factorio is linux64 only for now
factorioarch="linux64"
}
fn_update_factorio_availablebuild(){
# Gets latest build info.
if [ "${branch}" != "stable" ]; then
availablebuild=$(${curlpath} -s https://factorio.com/get-download/stable/headless/linux64 | grep -o '[0-9]\.[0-9]\{2\}\.[0-9]\{2\}' | head -1)
else
availablebuild=$(${curlpath} -s https://factorio.com/get-download/latest/headless/linux64 | grep -o '[0-9]\.[0-9]\{2\}\.[0-9]\{2\}' | head -1)
fi
# Checks if availablebuild variable has been set
if [ -z "${availablebuild}" ]; then
availablebuild=$(${curlpath} -s https://factorio.com/get-download/${downloadbranch}/headless/${factorioarch} | grep -o '[0-9]\.[0-9]\{1,\}\.[0-9]\{1,\}' | head -1)
# Checks if availablebuild variable has been set.
if [ -v "${availablebuild}" ]; then
fn_print_fail "Checking for update: factorio.com"
sleep 0.5
fn_print_fail "Checking for update: factorio.com: Not returning version info"
@ -103,7 +89,7 @@ fn_update_factorio_availablebuild(){
}
fn_update_factorio_compare(){
# Removes dots so if can compare version numbers
# Removes dots so if statement can compare version numbers.
currentbuilddigit=$(echo "${currentbuild}" | tr -cd '[:digit:]')
availablebuilddigit=$(echo "${availablebuild}" | tr -cd '[:digit:]')
@ -157,7 +143,15 @@ fn_update_factorio_compare(){
fi
}
fn_update_factorio_arch
# Factorio is linux64 only for now.
factorioarch="linux64"
if [ "${branch}" == "stable" ]; then
downloadbranch="stable"
elif [ "${branch}" == "experimental" ]; then
downloadbranch="latest"
fi
if [ "${installer}" == "1" ]; then
fn_update_factorio_availablebuild
fn_update_factorio_dl

89
lgsm/functions/update_ts3.sh

@ -8,22 +8,13 @@ local commandname="UPDATE"
local commandaction="Update"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_update_ts3_dl_legacy(){
fn_fetch_file "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${tmpdir}" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
fn_dl_extract "${tmpdir}" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${tmpdir}"
echo -e "copying to ${serverfiles}...\c"
fn_script_log "Copying to ${serverfiles}"
cp -R "${tmpdir}/teamspeak3-server_linux_${ts3arch}/"* "${serverfiles}"
local exitcode=$?
if [ "${exitcode}" == "0" ]; then
fn_print_ok_eol_nl
else
fn_print_fail_eol_nl
fi
}
fn_update_ts3_dl(){
latestts3releaselink=$(${curlpath} -s 'https://www.teamspeak.com/versions/server.json' | jq -r '.linux.x86_64.mirrors."teamspeak.com"')
info_distro.sh
if [ "${ts3arch}" == "amd64" ]; then
latestts3releaselink=$(${curlpath} -s 'https://www.teamspeak.com/versions/server.json' | jq -r '.linux.x86_64.mirrors."teamspeak.com"')
elif [ "${ts3arch}" == "x86" ]; then
latestts3releaselink=$(${curlpath} -s 'https://www.teamspeak.com/versions/server.json' | jq -r '.linux.x86.mirrors."teamspeak.com"')
fi
fn_fetch_file "${latestts3releaselink}" "${tmpdir}" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
fn_dl_extract "${tmpdir}" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${tmpdir}"
echo -e "copying to ${serverfiles}...\c"
@ -40,7 +31,7 @@ fn_update_ts3_dl(){
fn_update_ts3_currentbuild(){
# Gets current build info
# Checks if current build info is available. If it fails, then a server restart will be forced to generate logs.
if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then
if [ ! -d "${serverfiles}/logs" ]||[ -z "$(find "${serverfiles}/logs/"* -name 'ts3server*_0.log' 2> /dev/null)" ]; then
fn_print_error "Checking for update: teamspeak.com"
sleep 0.5
fn_print_error_nl "Checking for update: teamspeak.com: No logs with server version found"
@ -55,7 +46,7 @@ fn_update_ts3_currentbuild(){
command_start.sh
sleep 0.5
# Check again and exit on failure.
if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then
if [ ! -d "${serverfiles}/logs" ]||[ -z "$(find "${serverfiles}/logs/"* -name 'ts3server*_0.log')" ]; then
fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found"
fn_script_log_fatal "Checking for update: teamspeak.com: Still No logs with server version found"
core_exit.sh
@ -63,7 +54,7 @@ fn_update_ts3_currentbuild(){
fi
# Get current build from logs
currentbuild=$(cat $(find ./* -name "ts3server*_0.log" 2> /dev/null | sort | grep -Ev "${rootdir}/.ts3version" | tail -1) | grep -Eo "TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | grep -Eo "((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | sort -V | tail -1)
currentbuild="$(cat "$(find "${serverfiles}/logs/"* -name "ts3server*_0.log" 2> /dev/null | sort | tail -1)" | grep -Eo "TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | grep -Eo "((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | sort -V)"
if [ -z "${currentbuild}" ]; then
fn_print_error_nl "Checking for update: teamspeak.com: Current build version not found"
fn_script_log_error "Checking for update: teamspeak.com: Current build version not found"
@ -74,7 +65,7 @@ fn_update_ts3_currentbuild(){
command_stop.sh
exitbypass=1
command_start.sh
currentbuild=$(cat $(find ./* -name "ts3server*_0.log" 2> /dev/null | sort | grep -Ev "${rootdir}/.ts3version" | tail -1) | grep -Eo "TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | grep -Eo "((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}")
currentbuild="$(cat "$(find "${serverfiles}/logs/"* -name "ts3server*_0.log" 2> /dev/null | sort | tail -1)" | grep -Eo "TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | grep -Eo "((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | sort -V)"
if [ -z "${currentbuild}" ]; then
fn_print_fail_nl "Checking for update: teamspeak.com: Current build version still not found"
fn_script_log_fatal "Checking for update: teamspeak.com: Current build version still not found"
@ -98,7 +89,6 @@ else
fi
}
fn_update_ts3_availablebuild(){
# Gets latest build info.
if [ "${arch}" == "x86_64" ]; then
@ -108,11 +98,11 @@ fn_update_ts3_availablebuild(){
fi
ts3_version_number="${availablebuild}"
# Checks if availablebuild variable has been set
if [ -z "${availablebuild}" ]||[ "${availablebuild}" == "null" ]; then
if [ -v "${availablebuild}" ]||[ "${availablebuild}" == "null" ]; then
fn_print_fail "Checking for update: teamspeak.com"
sleep 0.5
fn_print_fail "Checking for update: teamspeak.com: Not returning version info"
fn_script_log_fatal "Failure! Checking for update: teamspeak.com: Not returning version info"
fn_script_log_fatal "Checking for update: teamspeak.com: Not returning version info"
core_exit.sh
elif [ "${installer}" == "1" ]; then
:
@ -123,45 +113,6 @@ fn_update_ts3_availablebuild(){
fi
}
fn_update_ts3_availablebuild_legacy(){
# Gets latest build info.
# Grabs all version numbers but not in correct order.
wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O - | grep -i dir | grep -Eo '<a href=\".*\/\">.*\/<\/a>' | grep -Eo '[0-9\.?]+' | uniq > "${tmpdir}/.ts3_version_numbers_unsorted.tmp"
# Sort version numbers
cat "${tmpdir}/.ts3_version_numbers_unsorted.tmp" | sort -r --version-sort -o "${tmpdir}/.ts3_version_numbers_sorted.tmp"
# Finds directory with most recent server version.
while read -r ts3_version_number; do
wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
if [ $? -eq 0 ]; then
availablebuild="${ts3_version_number}"
# Break while-loop, if the latest release could be found.
break
fi
done < "${tmpdir}/.ts3_version_numbers_sorted.tmp"
# Tidy up
rm -f "${tmpdir}/.ts3_version_numbers_unsorted.tmp"
rm -f "${tmpdir}/.ts3_version_numbers_sorted.tmp"
# Checks availablebuild info is available
if [ -z "${availablebuild}" ]; then
fn_print_fail "Checking for update: teamspeak.com"
sleep 0.5
fn_print_fail "Checking for update: teamspeak.com: Not returning version info"
fn_script_log_fatal "Failure! Checking for update: teamspeak.com: Not returning version info"
core_exit.sh
elif [ "${installer}" == "1" ]; then
:
else
fn_print_ok "Checking for update: teamspeak.com"
fn_script_log_pass "Checking for update: teamspeak.com"
sleep 0.5
fi
}
fn_update_ts3_compare(){
# Removes dots so if can compare version numbers
currentbuilddigit=$(echo "${currentbuild}" | tr -cd '[:digit:]')
@ -219,24 +170,14 @@ fn_update_ts3_compare(){
fn_update_ts3_arch
if [ "${installer}" == "1" ]; then
# if jq available uses json update checker
if [ "$(command -v jq >/dev/null 2>&1)" ]; then
fn_update_ts3_availablebuild
fn_update_ts3_dl
else
fn_update_ts3_availablebuild_legacy
fn_update_ts3_dl_legacy
fi
fn_update_ts3_availablebuild
fn_update_ts3_dl
else
# Checks for server update from teamspeak.com using a mirror dl.4players.de.
fn_print_dots "Checking for update: teamspeak.com"
fn_script_log_info "Checking for update: teamspeak.com"
sleep 0.5
fn_update_ts3_currentbuild
if [ "$(command -v jq >/dev/null 2>&1)" ]; then
fn_update_ts3_availablebuild
else
fn_update_ts3_availablebuild_legacy
fi
fn_update_ts3_availablebuild
fn_update_ts3_compare
fi

Loading…
Cancel
Save