Browse Source

Improved config details

pull/1011/head
Marvin Lehmann 9 years ago
parent
commit
acb9546bfd
  1. 19
      lgsm/functions/info_config.sh

19
lgsm/functions/info_config.sh

@ -10,7 +10,7 @@ local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
## Examples of filtering to get info from config files
# sed 's/foo//g' - remove foo
# tr -cd '[:digit:]' leave only digits
# tr -d '=\"; ' remove selected charectors =\";
# tr -d '=\"; ' remove selected characters =\";
# grep -v "foo" filter out lines that contain foo
unavailable="${red}UNAVAILABLE${default}"
@ -71,22 +71,31 @@ fn_info_config_dontstarve(){
fn_info_config_minecraft(){
if [ ! -f "${servercfgfullpath}" ]; then
rconpassword="${unavailable}"
rconport="${zero}"
slots="${zero}"
port="${zero}"
gamemode="${zero}"
gameworld="${unavailable}"
else
# check if the ip exists in the config file. Failing this will fall back to the default.
ipconfigcheck=$(grep "server-ip=" "${servercfgfullpath}" | sed 's/server-ip=//g')
if [ -n "${ipconfigcheck}" ]; then
ip="${ipconfigcheck}"
fi
rconpassword=$(grep "rcon.password=" "${servercfgfullpath}" | sed 's/rcon.password=//g' | tr -d '\')
rconpassword=$(grep "rcon.password=" "${servercfgfullpath}" | sed 's/rcon.password=//g' | tr -d '=\"; ')
rconport=$(grep "rcon.port=" "${servercfgfullpath}" | tr -cd '[:digit:]')
slots=$(grep "max-players=" "${servercfgfullpath}" | tr -cd '[:digit:]')
port=$(grep "server-port=" "${servercfgfullpath}" | tr -cd '[:digit:]')
gamemode=$(grep "gamemode=" "${servercfgfullpath}" | tr -cd '[:digit:]')
gameworld=$(grep "level-name=" "${servercfgfullpath}" | sed 's/level-name=//g' | tr -d '=\"; ')
# Not Set
rconpassword=${rconpassword:-"NOT SET"}
rconport=${rconport:-"NOT SET"}
slots=${slots:-"NOT SET"}
port=${port:-"NOT SET"}
gamemode=${gamemode:-"NOT SET"}
gameworld=${gameworld:-"NOT SET"}
fi
}
@ -99,9 +108,9 @@ fn_info_config_projectzomboid(){
port="${zero}"
gameworld="${unavailable}"
else
servername=$(grep "PublicName=" "${servercfgfullpath}" | sed 's/PublicName=//g' | tr -d '\')
serverpassword=$(grep "^Password=$" "${servercfgfullpath}" | sed 's/Password=//g' | tr -d '\')
rconpassword=$(grep "RCONPassword=" "${servercfgfullpath}" | sed 's/RCONPassword=//g' | tr -d '\')
servername=$(grep "PublicName=" "${servercfgfullpath}" | sed 's/PublicName=//g' | tr -d '=\";\n')
serverpassword=$(grep "^Password=$" "${servercfgfullpath}" | sed 's/Password=//g' | tr -d '=\"; ')
rconpassword=$(grep "RCONPassword=" "${servercfgfullpath}" | sed 's/RCONPassword=//g' | tr -d '=\"; ')
slots=$(grep "MaxPlayers=" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]')
port=$(grep "DefaultPort=" "${servercfgfullpath}" | tr -cd '[:digit:]')
gameworld=$(grep "Map=" "${servercfgfullpath}" | sed 's/Map=//g' | tr -d '\n')

Loading…
Cancel
Save