Skip to content

Commit

Permalink
feat(monitor): prepare for gamedig 5 (#4510)
Browse files Browse the repository at this point in the history
* feat: gamedig 5

* install gamedig in lgsm dir if node exists

* and

* use local gamedig version

* local

* palworld

* pw query port

* mbe

* fix ro

system

system

a

* public ip

* jc2m

* fix(ti): update default map

The default map in the tiserver configuration file has been updated from "/Game/TheIsle/Maps/Game/Isla_Spiro/Isla_Spiro" to "/Game/TheIsle/Maps/Game/Gateway/Gateway". This change ensures that the server starts with the correct default map.

* fix: _default.cfg NOT SET

* download package.json and run npm install

* update samp

* disable query for squad

* correct name

* feat: update querymode and querytype in server configs

Changed querymode to 3 and set querytype to "eco" for ecoserver.
Updated querymode to 2 and changed querytype to "protocol-valve" for sdtdserver.

* feat: add new port command for bfv game

Added a new port command for the "bfv" game in the info_messages script.

* queryport eco

* add eco rconport

* adding message

* if node 16 or above

* rename to check_gamedig
  • Loading branch information
dgibbs64 authored Feb 26, 2024
1 parent 476ed02 commit fce9f65
Show file tree
Hide file tree
Showing 23 changed files with 839 additions and 65 deletions.
4 changes: 2 additions & 2 deletions lgsm/config-default/config-lgsm/ecoserver/_default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ stopmode="2"
# 3: gamedig
# 4: gsquery
# 5: tcp
querymode="1"
querytype=""
querymode="3"
querytype="eco"

## Console type
consoleverbose="yes"
Expand Down
2 changes: 1 addition & 1 deletion lgsm/config-default/config-lgsm/jc2server/_default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ stopmode="2"
# 4: gsquery
# 5: tcp
querymode="2"
querytype="jc2mp"
querytype="jc2m"

## Console type
consoleverbose="yes"
Expand Down
2 changes: 1 addition & 1 deletion lgsm/config-default/config-lgsm/mcbserver/_default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ stopmode="5"
# 4: gsquery
# 5: tcp
querymode="2"
querytype="minecraftbe"
querytype="mbe"

## Console type
consoleverbose="yes"
Expand Down
4 changes: 2 additions & 2 deletions lgsm/config-default/config-lgsm/pwserver/_default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ stopmode="2"
# 3: gamedig
# 4: gsquery
# 5: tcp
querymode="1"
querytype="1"
querymode="3"
querytype="palworld"

## Console type
consoleverbose="yes"
Expand Down
2 changes: 1 addition & 1 deletion lgsm/config-default/config-lgsm/sampserver/_default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ stopmode="2"
# 4: gsquery
# 5: tcp
querymode="3"
querytype="samp"
querytype="gtasam"

## Console type
consoleverbose="no"
Expand Down
2 changes: 1 addition & 1 deletion lgsm/config-default/config-lgsm/sdtdserver/_default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ stopmode="8"
# 3: gamedig
# 4: gsquery
# 5: tcp
querymode="5"
querymode="2"
querytype="protocol-valve"

## Console type
Expand Down
4 changes: 2 additions & 2 deletions lgsm/config-default/config-lgsm/squadserver/_default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ stopmode="2"
# 3: gamedig
# 4: gsquery
# 5: tcp
querymode="2"
querytype="protocol-valve"
querymode="1"
querytype=""

## Console type
consoleverbose="yes"
Expand Down
7 changes: 7 additions & 0 deletions lgsm/modules/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,10 @@ for allowed_command in "${allowed_commands_array[@]}"; do
check_system_requirements.sh
fi
done

allowed_commands_array=(DETAILS MONITOR START STOP UPDATE VALIDATE POST-DETAILS)
for allowed_command in "${allowed_commands_array[@]}"; do
if [ "${allowed_command}" == "${commandname}" ]; then
check_gamedig.sh
fi
done
15 changes: 15 additions & 0 deletions lgsm/modules/check_gamedig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# LinuxGSM check_gamedig.sh module
# Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com
# Description: Installs nodejs and gamedig

if [ "$(command -v node)" ] && [ "$(node -v | cut -d 'v' -f 2 | cut -d '.' -f 1)" -ge 16 ] && [ ! -f "${lgsmdir}/node_modules/gamedig/bin/gamedig.js" ]; then
echo -e ""
echo -e "${bold}${lightyellow}Installing Gamedig${default}"
fn_script_log_info "Installing Gamedig"
cd "${lgsmdir}" || exit
wget -N --no-check-certificate "https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/${githubbranch}/package.json"
npm install
fi
8 changes: 4 additions & 4 deletions lgsm/modules/check_ip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,25 @@ function fn_is_valid_ip() {

# If the IP variable has been set by user.
if fn_is_valid_ip "${ip}"; then
queryips=("${ip}")
queryips=("${ip}" "${publicip}")
httpip=("${ip}")
telnetip=("${ip}")
# If the game config has an IP set.
elif fn_is_valid_ip "${configip}"; then
queryips=("${configip}")
queryips=("${configip}" "${publicip}")
ip="${configip}"
httpip=("${configip}")
telnetip=("${configip}")
# If there is only 1 server IP address.
# Some IP details can automatically use the one IP.
elif [ "${#current_ips[@]}" == "1" ]; then
queryips=("127.0.0.1" "${current_ips[@]}")
queryips=("127.0.0.1" "${current_ips[@]}" "${publicip}")
ip="0.0.0.0"
httpip=("${current_ips[@]}")
telnetip=("${current_ips[@]}")
# If no ip is set by the user and server has more than one IP.
else
queryips=("127.0.0.1" "${current_ips[@]}")
queryips=("127.0.0.1" "${current_ips[@]}" "${publicip}")
ip="0.0.0.0"
httpip=("${ip}")
telnetip=("${ip}")
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/command_dev_query_raw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ echo -e ""
echo -e "${lightgreen}Gamedig Raw Output${default}"
fn_messages_separator
echo -e ""
if [ ! "$(command -v gamedig 2> /dev/null)" ]; then
if [ ! "$(command -v gamedig 2> /dev/null)" ] || [ ! -f "${lgsmdir}/node_modules/gamedig/bin/gamedig.js" ]; then
fn_print_failure_nl "gamedig not installed"
fi
if [ ! "$(command -v jq 2> /dev/null)" ]; then
Expand Down
3 changes: 3 additions & 0 deletions lgsm/modules/command_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ else
install_server_files.sh
fi

# Install gamedig
check_gamedig.sh

# Configuration.
install_config.sh
if [ -v gslt ]; then
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/command_monitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ fn_monitor_loop() {
for querymethod in "${query_methods_array[@]}"; do
# Will check if gamedig is installed and bypass if not.
if [ "${querymethod}" == "gamedig" ]; then
if [ "$(command -v gamedig 2> /dev/null)" ] && [ "$(command -v jq 2> /dev/null)" ]; then
if [ "$(command -v gamedig 2> /dev/null)" ] || [ -f "${lgsmdir}/node_modules/gamedig/bin/gamedig.js" ] && [ "$(command -v jq 2> /dev/null)" ]; then
if [ -z "${monitorpass}" ]; then
fn_monitor_query
fi
Expand Down
1 change: 1 addition & 0 deletions lgsm/modules/command_update_linuxgsm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ fn_firstcommand_set
fn_print_dots ""
check.sh
info_distro.sh
info_game.sh

fn_script_log_info "Updating LinuxGSM"

Expand Down
5 changes: 5 additions & 0 deletions lgsm/modules/core_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,11 @@ install_factorio_save.sh() {
fn_fetch_module
}

check_gamedig.sh() {
modulefile="${FUNCNAME[0]}"
fn_fetch_module
}

install_dst_token.sh() {
modulefile="${FUNCNAME[0]}"
fn_fetch_module
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/fix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn_apply_fix() {
fi
}

apply_pre_start_fix=(arma3 armar ark av bt bo csgo cmw dst hw ins kf nmrih onset pvr rust rw samp sdtd sfc sof2 squad st tf2 terraria ts3 mcb mta unt vh wurm zmr)
apply_pre_start_fix=(arma3 armar ark av bt bo csgo cmw dst hw ins kf nmrih onset pvr ro rust rw samp sdtd sfc sof2 squad st tf2 terraria ts3 mcb mta unt vh wurm zmr)
apply_post_install_fix=(av kf kf2 ro ut2k4 ut ut3)

# validate registered fixes for safe development
Expand Down
134 changes: 106 additions & 28 deletions lgsm/modules/fix_ro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,115 @@
# Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com
# Description: Resolves issues with Red Orchestra.
# Description: Resolves issues with Red Orchestra: Ostfront 41-45.

moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"

echo -e "applying webinterface ROOst.css fix."
echo -e "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13"
# echo -e "applying WebAdmin ROOst.css fix."
# echo -e "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13"
sed -i 's/none}/none;/g' "${serverfiles}/Web/ServerAdmin/ROOst.css"
sed -i 's/underline}/underline;/g' "${serverfiles}/Web/ServerAdmin/ROOst.css"
fn_sleep_time
echo -e "applying webinterface CharSet fix."
echo -e "http://forums.tripwireinteractive.com/showpost.php?p=442340&postcount=1"
# echo -e "applying WebAdmin CharSet fix."
# echo -e "http://forums.tripwireinteractive.com/showpost.php?p=442340&postcount=1"
sed -i 's/CharSet="iso-8859-1"/CharSet="utf-8"/g' "${systemdir}/uweb.int"
fn_sleep_time
echo -e "applying Steam AppID fix."
sed -i 's/1210/1200/g' "${systemdir}/steam_appid.txt"
fn_sleep_time
echo -e "applying server name fix."
fn_sleep_time
echo -e "forcing server restart..."
fn_sleep_time
exitbypass=1
command_start.sh
fn_firstcommand_reset
fn_sleep_time_5
exitbypass=1
command_stop.sh
fn_firstcommand_reset
exitbypass=1
command_start.sh
fn_firstcommand_reset
fn_sleep_time_5
exitbypass=1
command_stop.sh
fn_firstcommand_reset

# get md5sum of steamclient.so
if [ -f "${serverfiles}/system/steamclient.so" ]; then
steamclientmd5=$(md5sum "${serverfiles}/system/steamclient.so" | awk '{print $1;}')
fi
#get md5sum of libtier0_s.so
if [ -f "${serverfiles}/system/libtier0_s.so" ]; then
libtier0_smd5=$(md5sum "${serverfiles}/system/libtier0_s.so" | awk '{print $1;}')
fi
#get md5sum of libvstdlib_s.so
if [ -f "${serverfiles}/system/libvstdlib_s.so" ]; then
libvstdlib_smd5=$(md5sum "${serverfiles}/system/libvstdlib_s.so" | awk '{print $1;}')
fi

# get md5sum of steamclient.so from steamcmd
if [ -f "${HOME}/.steam/steamcmd/linux32/steamclient.so" ]; then
steamcmdsteamclientmd5=$(md5sum "${HOME}/.steam/steamcmd/linux32/steamclient.so" | awk '{print $1;}')
elif [ -f "${steamcmddir}/linux32/steamclient.so" ]; then
steamcmdsteamclientmd5=$(md5sum "${steamcmddir}/linux32/steamclient.so" | awk '{print $1;}')
elif [ -f "${HOME}/.local/share/Steam/steamcmd/linux32/steamclient.so" ]; then
steamcmdsteamclientmd5=$(md5sum "${HOME}/.local/share/Steam/steamcmd/linux32/steamclient.so" | awk '{print $1;}')
fi

# get md5sum of libtier0_s.so from steamcmd
if [ -f "${HOME}/.steam/steamcmd/linux32/libtier0_s.so" ]; then
steamcmdlibtier0_smd5=$(md5sum "${HOME}/.steam/steamcmd/linux32/libtier0_s.so" | awk '{print $1;}')
elif [ -f "${steamcmddir}/linux32/libtier0_s.so" ]; then
steamcmdlibtier0_smd5=$(md5sum "${steamcmddir}/linux32/libtier0_s.so" | awk '{print $1;}')
elif [ -f "${HOME}/.local/share/Steam/steamcmd/linux32/libtier0_s.so" ]; then
steamcmdlibtier0_smd5=$(md5sum "${HOME}/.local/share/Steam/steamcmd/linux32/libtier0_s.so" | awk '{print $1;}')
fi

# get md5sum of libvstdlib_s.so from steamcmd
if [ -f "${HOME}/.steam/steamcmd/linux32/libvstdlib_s.so" ]; then
steamcmdlibvstdlib_smd5=$(md5sum "${HOME}/.steam/steamcmd/linux32/libvstdlib_s.so" | awk '{print $1;}')
elif [ -f "${steamcmddir}/linux32/libvstdlib_s.so" ]; then
steamcmdlibvstdlib_smd5=$(md5sum "${steamcmddir}/linux32/libvstdlib_s.so" | awk '{print $1;}')
elif [ -f "${HOME}/.local/share/Steam/steamcmd/linux32/libvstdlib_s.so" ]; then
steamcmdlibvstdlib_smd5=$(md5sum "${HOME}/.local/share/Steam/steamcmd/linux32/libvstdlib_s.so" | awk '{print $1;}')
fi

if [ ! -f "${serverfiles}/system/steamclient.so" ] || [ "${steamcmdsteamclientmd5}" != "${steamclientmd5}" ]; then
fixname="steamclient.so x86"
fn_fix_msg_start
if [ -f "${HOME}/.steam/steamcmd/linux32/steamclient.so" ]; then
cp "${HOME}/.steam/steamcmd/linux32/steamclient.so" "${serverfiles}/system/steamclient.so"
elif [ -f "${steamcmddir}/linux32/steamclient.so" ]; then
cp "${steamcmddir}/linux32/steamclient.so" "${serverfiles}/system/steamclient.so"
elif [ -f "${HOME}/.local/share/Steam/steamcmd/linux32/steamclient.so" ]; then
cp "${HOME}/.local/share/Steam/steamcmd/linux32/steamclient.so" "${serverfiles}/system/steamclient.so"
fi
fn_fix_msg_end
fi

if [ ! -f "${serverfiles}/system/libtier0_s.so" ] || [ "${steamcmdlibtier0_smd5}" != "${libtier0_smd5}" ]; then
fixname="libtier0_s.so"
fn_fix_msg_start
if [ -f "${HOME}/.steam/steamcmd/linux32/libtier0_s.so" ]; then
cp "${HOME}/.steam/steamcmd/linux32/libtier0_s.so" "${serverfiles}/system/libtier0_s.so"
elif [ -f "${steamcmddir}/linux32/libtier0_s.so" ]; then
cp "${steamcmddir}/linux32/libtier0_s.so" "${serverfiles}/system/libtier0_s.so"
elif [ -f "${HOME}/.local/share/Steam/steamcmd/linux32/libtier0_s.so" ]; then
cp "${HOME}/.local/share/Steam/steamcmd/linux32/libtier0_s.so" "${serverfiles}/system/libtier0_s.so"
fi
fn_fix_msg_end
fi

if [ ! -f "${serverfiles}/system/libvstdlib_s.so" ] || [ "${steamcmdlibvstdlib_smd5}" != "${libvstdlib_smd5}" ]; then
fixname="libvstdlib_s.so"
fn_fix_msg_start
if [ -f "${HOME}/.steam/steamcmd/linux32/libvstdlib_s.so" ]; then
cp "${HOME}/.steam/steamcmd/linux32/libvstdlib_s.so" "${serverfiles}/system/libvstdlib_s.so"
elif [ -f "${steamcmddir}/linux32/libvstdlib_s.so" ]; then
cp "${steamcmddir}/linux32/libvstdlib_s.so" "${serverfiles}/system/libvstdlib_s.so"
elif [ -f "${HOME}/.local/share/Steam/steamcmd/linux32/libvstdlib_s.so" ]; then
cp "${HOME}/.local/share/Steam/steamcmd/linux32/libvstdlib_s.so" "${serverfiles}/system/libvstdlib_s.so"
fi
fn_fix_msg_end
fi

# if running install command
if [ "${commandname}" == "INSTALL" ]; then
echo -e "applying server name fix."
fn_sleep_time
echo -e "forcing server restart..."
fn_sleep_time
exitbypass=1
command_start.sh
fn_firstcommand_reset
fn_sleep_time_5
exitbypass=1
command_stop.sh
fn_firstcommand_reset
exitbypass=1
command_start.sh
fn_firstcommand_reset
fn_sleep_time_5
exitbypass=1
command_stop.sh
fn_firstcommand_reset
fi
4 changes: 4 additions & 0 deletions lgsm/modules/info_game.sh
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ fn_info_game_pvr() {
fn_info_game_pw() {
servername="${servername:-"NOT SET"}"
port="${port:-"0"}"
queryport="${port:-"0"}"
steamport="${steamport:-"0"}"
unknownport="1985"
}
Expand Down Expand Up @@ -1242,6 +1243,7 @@ fn_info_game_eco() {
fn_info_game_json "httpport" ".WebServerPort"
fn_info_game_json "maxplayers" ".MaxConnections"
fn_info_game_json "port" ".GameServerPort"
fn_info_game_json "rconport" ".RconServerPort"
fn_info_game_json "servername" ".Description"
fn_info_game_json "serverpassword" ".Password"
fn_info_game_json "tickrate" ".Rate"
Expand All @@ -1250,6 +1252,8 @@ fn_info_game_eco() {
httpport="${httpport:-"0"}"
maxplayers="${maxplayers:-"0"}"
port="${port:-"0"}"
queryport="${port:-"0"}"
rconport="${rconport:-"0"}"
servername="${servername:-"NOT SET"}"
serverpassword="${serverpassword:-"NOT SET"}"
tickrate="${tickrate:-"0"}"
Expand Down
4 changes: 4 additions & 0 deletions lgsm/modules/info_messages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,8 @@ fn_info_messages_ports() {
portcommand="ss -tuplwn | grep AvorionServer"
elif [ "${shortname}" == "bf1942" ]; then
portcommand="ss -tuplwn | grep bf1942_lnxded"
elif [ "${shortname}" == "bfv" ]; then
portcommand="ss -tuplwn | grep bfv_linded"
elif [ "${shortname}" == "dayz" ]; then
portcommand="ss -tuplwn | grep enfMain"
elif [ "${shortname}" == "q4" ]; then
Expand Down Expand Up @@ -1015,7 +1017,9 @@ fn_info_messages_eco() {
{
fn_port "header"
fn_port "Game" port udp
fn_port "Query" queryport udp
fn_port "Web Interface" httpport tcp
fn_port "RCON" rconport tcp
} | column -s $'\t' -t
}

Expand Down
13 changes: 10 additions & 3 deletions lgsm/modules/query_gamedig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
# Default query status to failure. Will be changed to 0 if query is successful.
querystatus="2"
# Check if gamedig and jq are installed.
if [ "$(command -v gamedig 2> /dev/null)" ] && [ "$(command -v jq 2> /dev/null)" ]; then

if [ -f "${lgsmdir}/node_modules/gamedig/bin/gamedig.js" ]; then
gamedigbinary="${lgsmdir}/node_modules/gamedig/bin/gamedig.js"
else
gamedigbinary="gamedig"
fi

if [ "$(command -v "${gamedigbinary}" 2> /dev/null)" ] && [ "$(command -v jq 2> /dev/null)" ]; then

# will bypass query if server offline.
check_status.sh
Expand All @@ -20,8 +27,8 @@ if [ "$(command -v gamedig 2> /dev/null)" ] && [ "$(command -v jq 2> /dev/null)"
queryport="${port}"
fi
# checks if query is working null = pass.
gamedigcmd=$(echo -e "gamedig --type \"${querytype}\" \"${queryip}:${queryport}\"|jq")
gamedigraw=$(gamedig --type "${querytype}" "${queryip}:${queryport}")
gamedigcmd=$(echo -e "${gamedigbinary} --type \"${querytype}\" \"${queryip}:${queryport}\"|jq")
gamedigraw=$(${gamedigbinary} --type "${querytype}" "${queryip}:${queryport}")
querystatus=$(echo "${gamedigraw}" | jq '.error|length')

if [ "${querytype}" == "teamspeak3" ]; then
Expand Down
Loading

0 comments on commit fce9f65

Please sign in to comment.