From a176649c3413a581532b7b4e7acc8750c14dfebc Mon Sep 17 00:00:00 2001 From: Nicolas Date: Tue, 26 Jul 2016 13:05:12 +0200 Subject: [PATCH 01/16] Add support to 7 days to die to info_config.sh --- lgsm/functions/info_config.sh | 53 ++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/info_config.sh b/lgsm/functions/info_config.sh index 00c9b40b5..cdc6e5785 100644 --- a/lgsm/functions/info_config.sh +++ b/lgsm/functions/info_config.sh @@ -293,7 +293,55 @@ fn_info_config_unreal(){ webadminpass=${webadminpass:-"NOT SET"} fi } + +fn_info_config_sdtd(){ + if [ ! -f "${servercfgfullpath}" ]; then + servername="${unavailable}" + serverpassword="${unavailable}" + port="${zero}" + queryport="${zero}" + webadminenabled="${unavailable}" + webadminport="${zero}" + webadminpass="${unavailable}" + telnetenabled="${unavailable}" + telnetport="${zero}" + telnetpass="${unavailable}" + slots="${unavailable}" + gamemode="${unavailable}" + gameworld="${unavailable}" + else + servername=$(grep "ServerName" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"") + serverpassword=$(grep "ServerPassword" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"") + port=$(grep "ServerPort" "${servercfgfullpath}" | tr -cd '[:digit:]') + queryport=$((port + 1)) + + webadminenabled=$(grep "ControlPanelEnabled" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"") + webadminport=$(grep "ControlPanelPort" "${servercfgfullpath}" | tr -cd '[:digit:]') + webadminpass=$(grep "ControlPanelPassword" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"") + telnetenabled=$(grep "TelnetEnabled" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"") + telnetport=$(grep "TelnetPort" "${servercfgfullpath}" | tr -cd '[:digit:]') + telnetpass=$(grep "TelnetPassword" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"") + + slots=$(grep "ServerMaxPlayerCount" "${servercfgfullpath}" | tr -cd '[:digit:]') + gamemode=$(grep "GameMode" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"") + gameworld=$(grep "GameWorld" "${servercfgfullpath}" | sed 's/^.*value="//' | cut -f1 -d"\"") + # Not Set + servername=${servername:-"NOT SET"} + serverpassword=${serverpassword:-"NOT SET"} + port=${port:-"0"} + queryport=${queryport:-"0"} + webadminenabled=${webadminenabled:-"NOT SET"} + webadminport=${webadminport:-"0"} + webadminpass=${webadminpass:-"NOT SET"} + telnetenabled=${telnetenabled:-"NOT SET"} + telnetport=${telnetport:-"0"} + telnetpass=${telnetpass:-"NOT SET"} + slots=${slots:-"NOT SET"} + gamemode=${gamemode:-"NOT SET"} + gameworld=${gameworld:-"NOT SET"} + fi +} ## Just Cause 2 if [ "${engine}" == "avalanche" ]; then fn_info_config_avalanche @@ -329,4 +377,7 @@ elif [ "${engine}" == "terraria" ]; then # Unreal/Unreal 2 engine elif [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then fn_info_config_unreal -fi \ No newline at end of file +# 7 Day To Die (unity3d) +elif [ "${gamename}" == "7 Days To Die" ]; then + fn_info_config_sdtd +fi From c47626a82d93e49b57d012063e16461f9df2971b Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 26 Jul 2016 17:23:36 +0200 Subject: [PATCH 02/16] Added cached memory varible Will cause no error if "cached:" doesn't exist --- lgsm/functions/info_distro.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/info_distro.sh b/lgsm/functions/info_distro.sh index b75499f3d..7c5c261c7 100644 --- a/lgsm/functions/info_distro.sh +++ b/lgsm/functions/info_distro.sh @@ -63,6 +63,7 @@ fi physmemtotal=$(free ${humanreadable} | awk '/Mem:/ {print $2}') physmemused=$(free ${humanreadable} | awk '/Mem:/ {print $3}') physmemfree=$(free ${humanreadable} | awk '/Mem:/ {print $4}') +pysmemcached=$(free ${humanreadable} | awk '/cache:/ {print $4}') swaptotal=$(free ${humanreadable} | awk '/Swap:/ {print $2}') swapused=$(free ${humanreadable} | awk '/Swap:/ {print $3}') swapfree=$(free ${humanreadable} | awk '/Swap:/ {print $4}') @@ -111,4 +112,4 @@ if [ -d "${backupdir}" ]; then # size of most recent backup. lastbackupsize=$(du -h "${lastbackup}" | awk '{print $1}') -fi \ No newline at end of file +fi From 05d68774deddea23f3d870a80a02df2dd09f0291 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 26 Jul 2016 17:42:03 +0200 Subject: [PATCH 03/16] typo --- lgsm/functions/info_distro.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/info_distro.sh b/lgsm/functions/info_distro.sh index 7c5c261c7..9b4ba5886 100644 --- a/lgsm/functions/info_distro.sh +++ b/lgsm/functions/info_distro.sh @@ -63,7 +63,7 @@ fi physmemtotal=$(free ${humanreadable} | awk '/Mem:/ {print $2}') physmemused=$(free ${humanreadable} | awk '/Mem:/ {print $3}') physmemfree=$(free ${humanreadable} | awk '/Mem:/ {print $4}') -pysmemcached=$(free ${humanreadable} | awk '/cache:/ {print $4}') +physmemcached=$(free ${humanreadable} | awk '/cache:/ {print $4}') swaptotal=$(free ${humanreadable} | awk '/Swap:/ {print $2}') swapused=$(free ${humanreadable} | awk '/Swap:/ {print $3}') swapfree=$(free ${humanreadable} | awk '/Swap:/ {print $4}') From 34ab71036db575de264edcaf957f32d88924ddd2 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 26 Jul 2016 17:55:43 +0200 Subject: [PATCH 04/16] Added physical cached memory info --- lgsm/functions/command_details.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lgsm/functions/command_details.sh b/lgsm/functions/command_details.sh index 2072835be..7eb9f9933 100644 --- a/lgsm/functions/command_details.sh +++ b/lgsm/functions/command_details.sh @@ -42,8 +42,8 @@ fn_details_performance(){ # Uptime: 55d, 3h, 38m # Avg Load: 1.00, 1.01, 0.78 # - # Mem: total used free - # Physical: 741M 656M 85M + # Mem: total used free cached + # Physical: 741M 656M 85M 256M # Swap: 0B 0B 0B echo -e "" @@ -55,8 +55,8 @@ fn_details_performance(){ } | column -s $'\t' -t echo -e "" { - echo -e "${blue}Mem:\t${blue}total\t used\t free${default}" - echo -e "${blue}Physical:\t${default}${physmemtotal}\t${physmemused}\t${physmemfree}${default}" + echo -e "${blue}Mem:\t${blue}total\t used\t free\t cached${default}" + echo -e "${blue}Physical:\t${default}${physmemtotal}\t${physmemused}\t${physmemfree}\t${physmemcached}${default}" echo -e "${blue}Swap:\t${default}${swaptotal}\t${swapused}\t${swapfree}${default}" } | column -s $'\t' -t } @@ -615,4 +615,4 @@ else fi fn_details_statusbottom -core_exit.sh \ No newline at end of file +core_exit.sh From 002c7a99e4d0dc3e46366f94c7b0c39e39681bfe Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 26 Jul 2016 19:02:10 +0200 Subject: [PATCH 05/16] RCON password check for Rust If no RCON password is set, it completely messes up with Rust. If the default password is set, the admin should be warned as it's quite dangerous. Tested working as expected. --- lgsm/functions/check_config.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/check_config.sh b/lgsm/functions/check_config.sh index b42c47d9d..88a298f50 100644 --- a/lgsm/functions/check_config.sh +++ b/lgsm/functions/check_config.sh @@ -17,4 +17,21 @@ if [ ! -e "${servercfgfullpath}" ]; then fn_script_log_warn "${servercfgfullpath}" sleep 2 fi -fi \ No newline at end of file +fi +if [ "${gamename}" == "Rust" ]; then + if [ -z "${rconpassword}" ]; then + fn_print_dots "" + sleep 0.5 + fn_print_warn_nl "RCON password not set!" + echo "This would lead to unexpected behavior. Aborting." + fn_script_log_warn "No RCON Password set, exitting!" + exit 1 + elif [ "${rconpassword}" == "CHANGE_ME" ]; then + fn_print_dots "" + sleep 0.5 + fn_print_warn_nl "Default RCON Password detected!" + echo "Having CHANGE_ME as a passowrd is not very safe." + fn_script_log_warn "RCON Password is the default one!" + sleep 2 + fi +fi From c89500cbacaafda094a40d0a8d553018936f1a61 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 26 Jul 2016 19:56:44 +0200 Subject: [PATCH 06/16] Init RAM requirement check --- lgsm/functions/check_system_requirements.sh | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lgsm/functions/check_system_requirements.sh diff --git a/lgsm/functions/check_system_requirements.sh b/lgsm/functions/check_system_requirements.sh new file mode 100644 index 000000000..dde47efb0 --- /dev/null +++ b/lgsm/functions/check_system_requirements.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# LGSM check_system_requirements.sh +# Author: Daniel Gibbs +# Contributor: UltimateByte +# Website: https://gameservermanagers.com +# Description: Checks RAM requirement + +mbphysmem=$(free -m | awk '/Mem:/ {print $2}') + +# RAM requirement in MegaBytes for each game or engine +if [ "${gamename} == "Rust" ]; then + ramrequirement="4000" +fi + +# If the game or engine has a minimum RAM Requirement, compare it to system's available RAM +if [ -n "${ramrequirement}" ]; then + if [ "${mbphysmem}" -lt "${ramrequirement} ]; then + # Warn the user + fn_print_warn "Insufficient physical RAM: ${mbphysmem}MB available for ${ramrequirement}MB required." + echo "You may encounter issues such as server lagging or shutting down unexpectedly." + fn_script_log_warn "Insufficient physical RAM: ${mbphysmem}MB available for ${ramrequirement}MB required." + fi +fi From 18d94278f1338dfd953ff44c933f758c6c36dbb4 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 26 Jul 2016 20:08:50 +0200 Subject: [PATCH 07/16] Check system requirements --- lgsm/functions/check.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lgsm/functions/check.sh b/lgsm/functions/check.sh index 95e1a92ba..ac5fb9bc8 100644 --- a/lgsm/functions/check.sh +++ b/lgsm/functions/check.sh @@ -83,3 +83,11 @@ do check_status.sh fi done + +local allowed_commands_array=( command_install.sh command_start.sh command_debug.sh ) +for allowed_command in "${allowed_commands_array[@]}" +do + if [ "${allowed_command}" == "${function_selfname}" ]; then + check_system_requirements.sh + fi +done From 3e77fc24f699805c2d0be04721a6ccfbff872e57 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 26 Jul 2016 20:10:58 +0200 Subject: [PATCH 08/16] added sleeps --- lgsm/functions/check_system_requirements.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lgsm/functions/check_system_requirements.sh b/lgsm/functions/check_system_requirements.sh index dde47efb0..cf8e40d00 100644 --- a/lgsm/functions/check_system_requirements.sh +++ b/lgsm/functions/check_system_requirements.sh @@ -17,7 +17,9 @@ if [ -n "${ramrequirement}" ]; then if [ "${mbphysmem}" -lt "${ramrequirement} ]; then # Warn the user fn_print_warn "Insufficient physical RAM: ${mbphysmem}MB available for ${ramrequirement}MB required." + sleep 2 echo "You may encounter issues such as server lagging or shutting down unexpectedly." + sleep 0.5 fn_script_log_warn "Insufficient physical RAM: ${mbphysmem}MB available for ${ramrequirement}MB required." fi fi From 633372e84b435817cafff8ee5264a8cfc57495b0 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 26 Jul 2016 20:17:18 +0200 Subject: [PATCH 09/16] added function check_system_requirements.sh --- lgsm/functions/core_functions.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index e89b18fe7..ba8e3a241 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -222,6 +222,11 @@ functionfile="${FUNCNAME}" fn_fetch_function } +check_system_requirements.sh(){ +functionfile="${FUNCANME}" +fn_fetch_function +} + check_tmux.sh(){ functionfile="${FUNCNAME}" fn_fetch_function From fc99a2cf30ba27979c1d1394183e7bbb786036dc Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 26 Jul 2016 20:27:03 +0200 Subject: [PATCH 10/16] Missing quotes --- lgsm/functions/check_system_requirements.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/check_system_requirements.sh b/lgsm/functions/check_system_requirements.sh index cf8e40d00..5743281e6 100644 --- a/lgsm/functions/check_system_requirements.sh +++ b/lgsm/functions/check_system_requirements.sh @@ -8,13 +8,13 @@ mbphysmem=$(free -m | awk '/Mem:/ {print $2}') # RAM requirement in MegaBytes for each game or engine -if [ "${gamename} == "Rust" ]; then +if [ "${gamename}" == "Rust" ]; then ramrequirement="4000" fi # If the game or engine has a minimum RAM Requirement, compare it to system's available RAM if [ -n "${ramrequirement}" ]; then - if [ "${mbphysmem}" -lt "${ramrequirement} ]; then + if [ "${mbphysmem}" -lt "${ramrequirement}"" ]; then # Warn the user fn_print_warn "Insufficient physical RAM: ${mbphysmem}MB available for ${ramrequirement}MB required." sleep 2 From 03951aefed981e5b3cf9ed77dcdfe958490943a7 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 26 Jul 2016 20:36:10 +0200 Subject: [PATCH 11/16] FUNCANME > FUNCNAME for fuck sake --- lgsm/functions/core_functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index ba8e3a241..2dda20940 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -223,7 +223,7 @@ fn_fetch_function } check_system_requirements.sh(){ -functionfile="${FUNCANME}" +functionfile="${FUNCNAME}" fn_fetch_function } From cce566e8857ba7d396a59caf8f4a578d927c4feb Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 26 Jul 2016 20:37:34 +0200 Subject: [PATCH 12/16] removed damn autoquote --- lgsm/functions/check_system_requirements.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/check_system_requirements.sh b/lgsm/functions/check_system_requirements.sh index 5743281e6..5a0409265 100644 --- a/lgsm/functions/check_system_requirements.sh +++ b/lgsm/functions/check_system_requirements.sh @@ -14,7 +14,7 @@ fi # If the game or engine has a minimum RAM Requirement, compare it to system's available RAM if [ -n "${ramrequirement}" ]; then - if [ "${mbphysmem}" -lt "${ramrequirement}"" ]; then + if [ "${mbphysmem}" -lt "${ramrequirement}" ]; then # Warn the user fn_print_warn "Insufficient physical RAM: ${mbphysmem}MB available for ${ramrequirement}MB required." sleep 2 From 3f52a2f9880c30846038613bf66ad88ded6e5985 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 26 Jul 2016 20:40:04 +0200 Subject: [PATCH 13/16] Line jump --- lgsm/functions/check_system_requirements.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lgsm/functions/check_system_requirements.sh b/lgsm/functions/check_system_requirements.sh index 5a0409265..53d09a93b 100644 --- a/lgsm/functions/check_system_requirements.sh +++ b/lgsm/functions/check_system_requirements.sh @@ -18,6 +18,7 @@ if [ -n "${ramrequirement}" ]; then # Warn the user fn_print_warn "Insufficient physical RAM: ${mbphysmem}MB available for ${ramrequirement}MB required." sleep 2 + echo "" echo "You may encounter issues such as server lagging or shutting down unexpectedly." sleep 0.5 fn_script_log_warn "Insufficient physical RAM: ${mbphysmem}MB available for ${ramrequirement}MB required." From f0229868328b05ba8bf65cb7ac32a4a4cad8519d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 27 Jul 2016 22:02:18 +0100 Subject: [PATCH 14/16] Now using core_exit.sh Updated to use new exit code system. I have added a wiki page with the basics https://github.com/dgibbs64/linuxgsm/wiki/LGSM-Exit-Codes Corrected typos --- lgsm/functions/check_config.sh | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lgsm/functions/check_config.sh b/lgsm/functions/check_config.sh index 88a298f50..61d0a8caf 100644 --- a/lgsm/functions/check_config.sh +++ b/lgsm/functions/check_config.sh @@ -18,20 +18,22 @@ if [ ! -e "${servercfgfullpath}" ]; then sleep 2 fi fi + if [ "${gamename}" == "Rust" ]; then - if [ -z "${rconpassword}" ]; then - fn_print_dots "" - sleep 0.5 - fn_print_warn_nl "RCON password not set!" - echo "This would lead to unexpected behavior. Aborting." - fn_script_log_warn "No RCON Password set, exitting!" - exit 1 - elif [ "${rconpassword}" == "CHANGE_ME" ]; then - fn_print_dots "" - sleep 0.5 - fn_print_warn_nl "Default RCON Password detected!" - echo "Having CHANGE_ME as a passowrd is not very safe." - fn_script_log_warn "RCON Password is the default one!" - sleep 2 - fi + if [ -z "${rconpassword}" ]; then + fn_print_dots "" + sleep 0.5 + fn_print_fail_nl "RCON password is not set!" + echo " * Not setting an RCON password causes issues with ${gamename}" + fn_script_log_fatal "RCON password is not set" + fn_script_log_fatal "Not setting an RCON password causes issues with ${gamename}" + core_exit.sh + elif [ "${rconpassword}" == "CHANGE_ME" ]; then + fn_print_dots "" + sleep 0.5 + fn_print_warn_nl "Default RCON Password detected!" + echo " * Having ${rconpassword} as a password is not very safe." + fn_script_log_warn "Default RCON Password detected" + sleep 2 + fi fi From 1ba937212210dbc0c7126d0158538a1f63c757d0 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 27 Jul 2016 22:20:09 +0100 Subject: [PATCH 15/16] added physicaltotalmb --- lgsm/functions/info_distro.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/info_distro.sh b/lgsm/functions/info_distro.sh index b75499f3d..3e81c1a60 100644 --- a/lgsm/functions/info_distro.sh +++ b/lgsm/functions/info_distro.sh @@ -61,13 +61,13 @@ else fi physmemtotal=$(free ${humanreadable} | awk '/Mem:/ {print $2}') +physmemtotalmb=$(free -m | awk '/Mem:/ {print $2}') physmemused=$(free ${humanreadable} | awk '/Mem:/ {print $3}') physmemfree=$(free ${humanreadable} | awk '/Mem:/ {print $4}') swaptotal=$(free ${humanreadable} | awk '/Swap:/ {print $2}') swapused=$(free ${humanreadable} | awk '/Swap:/ {print $3}') swapfree=$(free ${humanreadable} | awk '/Swap:/ {print $4}') - ### Disk Infomation ## Available disk space on the partition. From 0d4df73f17010360258d3938bac4b95cd5fa5f24 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 27 Jul 2016 22:22:01 +0100 Subject: [PATCH 16/16] using info_distro and updated messages --- lgsm/functions/check_system_requirements.sh | 32 +++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lgsm/functions/check_system_requirements.sh b/lgsm/functions/check_system_requirements.sh index 53d09a93b..d9e56cc5f 100644 --- a/lgsm/functions/check_system_requirements.sh +++ b/lgsm/functions/check_system_requirements.sh @@ -3,24 +3,26 @@ # Author: Daniel Gibbs # Contributor: UltimateByte # Website: https://gameservermanagers.com -# Description: Checks RAM requirement +# Description: Checks RAM requirements -mbphysmem=$(free -m | awk '/Mem:/ {print $2}') +local commandname="CHECK" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -# RAM requirement in MegaBytes for each game or engine +info_distro.sh + +# RAM requirements in megabytes for each game or engine. if [ "${gamename}" == "Rust" ]; then - ramrequirement="4000" + ramrequirementmb="4000" + ramrequirementgb="4" fi -# If the game or engine has a minimum RAM Requirement, compare it to system's available RAM +# If the game or engine has a minimum RAM Requirement, compare it to system's available RAM. if [ -n "${ramrequirement}" ]; then - if [ "${mbphysmem}" -lt "${ramrequirement}" ]; then - # Warn the user - fn_print_warn "Insufficient physical RAM: ${mbphysmem}MB available for ${ramrequirement}MB required." - sleep 2 - echo "" - echo "You may encounter issues such as server lagging or shutting down unexpectedly." - sleep 0.5 - fn_script_log_warn "Insufficient physical RAM: ${mbphysmem}MB available for ${ramrequirement}MB required." - fi -fi + if [ "${physmemtotalmb}" -lt "${ramrequirementmb}" ]; then + # Warn the user + fn_print_warn "Insufficient memory: ${ramrequirementgb}G required, ${physmemtotal} available" + sleep 1 + fn_print_warning "You may experiance poor performance from your server" + sleep 1 + fi +fi