Browse Source

ini improvements

pull/4200/head
Daniel Gibbs 3 years ago
parent
commit
04b0a1ab93
No known key found for this signature in database GPG Key ID: 7CA38B43F78F12FE
  1. 84
      lgsm/modules/command_dev_details.sh
  2. 9
      lgsm/modules/info_game.sh

84
lgsm/modules/command_dev_details.sh

@ -3,39 +3,69 @@
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib # Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com # Website: https://linuxgsm.com
# Description: Dev only: Displays all parsed details. # Description: Dev only: Enables debugging log to be saved to dev-debug.log.
info_game.sh
carriagereturn=$(file -b "${servercfgfullpath}" | grep -q CRLF && echo "${red}CRLF${default}" || echo "${lightgreen}LF${default}")
echo -e "" echo -e ""
echo -e "${lightgreen}Details List${default}" echo -e "${lightgreen}Server Details${default}"
echo -e "==================================================================" echo -e "=================================================================="
echo -e "" echo -e ""
echo -e "Game: ${gamename}" echo -e "Game: ${gamename}"
echo -e "Short Name: ${shortname}" echo -e "Config type: ${configtype}"
echo -e "Config: ${servercfgfullpath}" echo -e "Config file: ${servercfgfullpath}"
echo -e "Config Type: ${configtype}" echo -e "Carriage Return: ${carriagereturn}"
# Create an associative array of the server details.
declare -A server_details=(
['Admin Password']="${adminpassword}"
['Config IP']="${configip}"
['Default Map']="${defaultmap}"
['Game Mode']="${gamemode}"
['Game Type']="${gametype}"
['ip']="${ip}"
['Maxplayers']="${maxplayers}"
['Port']="${port}"
['Query Port']="${queryport}"
['RCON Enabled']="${rconenabled}"
['RCON Password']="${rconpassword}"
['RCON Port']="${rconport}"
['Reserved Slots']="${reservedslots}"
['Server Password']="${serverpassword}"
['Servername']="${servername}"
['Tickrate']="${tickrate}"
['Web Admin Enabled']="${webadminenabled}"
['Web Admin Password']="${webadminpassword}"
['Web Admin User']="${webadminuser}"
['World Name']="${worldname}"
['World Type']="${worldtype}"
)
# Initialize a variable to keep track of missing server details.
missing_details=""
# Loop through the server details and output them.
echo -e "" echo -e ""
echo -e "${lightgreen}Ports${default}" echo -e "${lightgreen}Available Server Details${default}"
echo -e "=================================" echo -e "================================="
echo -e "Port: ${port}" for key in "${!server_details[@]}"; do
echo -e "Query Port: ${queryport}" value=${server_details[$key]}
if [ -z "$value" ]; then
missing_details+="\n${key}"
else
echo -e "$key: $value "
fi
done
# Output the missing server details if there are any.
if [ -n "$missing_details" ]; then
echo -e "" echo -e ""
echo -e "${lightgreen}Server Details${default}" echo -e "${lightgreen}Missing Server Details${default}"
echo -e "=================================" echo -e "================================="
echo -e "Servername: ${servername} ${servernameorigin}" echo -e "${missing_details}"
echo -e "Server Password: ${serverpassword}" fi
echo -e "RCON Password: ${rconpassword}"
echo -e "Admin Password: ${adminpassword}" core_exit.sh
echo -e "Maxplayers: ${maxplayers}"
echo -e "Tickrate: ${tickrate}"
echo -e "Default Map: ${defaultmap}"
echo -e "Game Mode: ${gamemode}"
echo -e "Game Type: ${gametype}"
echo -e "RCON Enabled: ${rconenabled}"
echo -e "RCON Password: ${rconpassword}"
echo -e "Config IP: ${configip}"
echo -e "Web Admin Enabled: ${webadminenabled}"
echo -e "Web Admin User: ${webadminuser}"
echo -e "Web Admin Password: ${webadminpassword}"
echo -e "Reserved Slots: ${reservedslots}"
echo -e "World Name: ${worldname}"
echo -e "World Type: ${worldtype}"

9
lgsm/modules/info_game.sh

@ -6,7 +6,7 @@
# Description: Gathers various game server information. # Description: Gathers various game server information.
# shellcheck disable=SC2317 # shellcheck disable=SC2317
modulesselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
## Examples of filtering to get info from config files. ## Examples of filtering to get info from config files.
# sed 's/foo//g' - remove foo # sed 's/foo//g' - remove foo
@ -29,8 +29,7 @@ fn_info_game_ini() {
if [ -n "${3}" ]; then if [ -n "${3}" ]; then
servercfgfullpath="${3}" servercfgfullpath="${3}"
fi fi
eval "${1}"="$(sed -n "/^[[:space:]]*\<${2}\>/ { s/.*= *//p;q }" "${servercfgfullpath}")" eval "${1}"="\"$(sed -n "/^[[:space:]]*\<${2}\>/ { s/.*= *//p;q }" "${servercfgfullpath}" | tr -d "\r")\""
eval "${1}origin"="config"
configtype="ini" configtype="ini"
} }
@ -180,13 +179,11 @@ fn_info_game_btl() {
# Filetype: ini # Filetype: ini
fn_info_game_cmw() { fn_info_game_cmw() {
if [ -f "${servercfgfullpath}" ]; then if [ -f "${servercfgfullpath}" ]; then
fn_info_game_ini "adminpassword" "AdminPassword"
fn_info_game_ini "maxplayers" "MaxPlayers" fn_info_game_ini "maxplayers" "MaxPlayers"
fn_info_game_ini "rconport" "RConPort" "${servercfgdir}/DefaultGame.ini"
fn_info_game_ini "servername" "ServerName" fn_info_game_ini "servername" "ServerName"
fn_info_game_ini "serverpassword" "GamePassword" fn_info_game_ini "serverpassword" "GamePassword"
fn_info_game_ini "rconport" "RConPort" "${servercfgdir}/DefaultGame.ini"
fi fi
adminpassword="${adminpassword:-"NOT SET"}"
defaultmap="${defaultmap:-"NOT SET"}" defaultmap="${defaultmap:-"NOT SET"}"
maxplayers="${maxplayers:-"0"}" maxplayers="${maxplayers:-"0"}"
port="${port:-"0"}" port="${port:-"0"}"

Loading…
Cancel
Save