From 447c30c3185f5d0ea998d25383637ce19b84e38d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 19 Aug 2017 22:46:37 +0100 Subject: [PATCH] improvements to squad details --- lgsm/functions/info_config.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lgsm/functions/info_config.sh b/lgsm/functions/info_config.sh index 75ef93384..5e0c47694 100644 --- a/lgsm/functions/info_config.sh +++ b/lgsm/functions/info_config.sh @@ -753,20 +753,25 @@ fn_info_config_squad(){ servername="${unavailable}" maxplayers="${unavailable}" else - servername="$(cat ${servercfgfullpath} | grep "ServerName=" | cut -c13- | rev | cut -c3- | rev)" - maxplayers="$(cat ${servercfgfullpath} | grep "MaxPlayers=" | cut -c12- | tr -cd '[:digit:]')" + servername="$(cat ${servercfgfullpath} | grep "ServerName=" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/ServerName//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')" + maxplayers="$(cat ${servercfgfullpath} | grep "MaxPlayers=" | tr -cd '[:digit:]')" fi if [ ! -f "${servercfgdir}/Rcon.cfg" ]; then rconport=${unavailable} rconpassword=${unavailable} else - rconport=$(cat ${servercfgdir}/Rcon.cfg | grep "Port=" | cut -c6- | tr -cd '[:digit:]') - rconpassword=$(cat ${servercfgdir}/Rcon.cfg | grep "Password=" | cut -c10-) - if [ -z "${rconpassword}" ]||[ ${#rconpassword} == 1 ]; then - rconpassword="${yellow}DISABLED${default}" - fi + rconport=$(cat ${servercfgdir}/Rcon.cfg | grep "Port=" | tr -cd '[:digit:]') + rconpassword=$(cat ${servercfgdir}/Rcon.cfg | grep "Password=" | sed -e 's/^[ \t]*//g' -e '/^\//d' -e 's/Password//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') + fi + + rconport=${rconport:-"0"} + if [ -z "${rconpassword}" ]||[ ${#rconpassword} == 1 ]; then + rconpassword="NOT SET" fi + servername=${servername:-"NOT SET"} + serverpassword=${serverpassword:-"NOT SET"} + maxplayers=${maxplayers:-"0"} } # Just Cause 2