From dc053ff9368fef3edc4fef8ed96bffc680f0d9b5 Mon Sep 17 00:00:00 2001 From: Jimmy Maple <38733055+jimmyatSplunk@users.noreply.github.com> Date: Sun, 12 Apr 2020 23:23:15 -0400 Subject: [PATCH 1/5] fix(bug): gamedig not using correct JSON object Command to output the results for player count was looking at the wrong object in the tree. This change corrects it to the right objects. --- lgsm/functions/query_gamedig.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/query_gamedig.sh b/lgsm/functions/query_gamedig.sh index 4f1bc5638..bfe38b937 100644 --- a/lgsm/functions/query_gamedig.sh +++ b/lgsm/functions/query_gamedig.sh @@ -30,7 +30,7 @@ if [ "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ]; fi # numplayers. - gdplayers=$(echo -e "${gamedigraw}" | jq -re '.players') + gdplayers=$(echo -e "${gamedigraw}" | jq -re '.raw.vanilla.raw.players.online') if [ "${gdplayers}" == "null" ]; then unset gdplayers elif [ "${gdplayers}" == "[]" ]; then From 4b16cb26c58c676b519071fbae31fc765fe59f74 Mon Sep 17 00:00:00 2001 From: Jimmy Maple <38733055+jimmyatSplunk@users.noreply.github.com> Date: Sun, 12 Apr 2020 23:57:06 -0400 Subject: [PATCH 2/5] feat(monitor): Include bot count in monitor output Update to include bot count in monitor output from Gamedig. --- lgsm/functions/command_monitor.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index 5c4ead99a..8b644b30c 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -12,7 +12,7 @@ local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")") fn_monitor_check_lockfile(){ # Monitor does not run it lockfile is not found. - if [ ! -f "${lockdir}/${selfname}.lock" ]; then + if [ ! -f "${rootdir}/${lockselfname}" ]; then fn_print_dots "Checking lockfile: " fn_print_checking_eol fn_script_log_info "Checking lockfile: CHECKING" @@ -21,13 +21,13 @@ fn_monitor_check_lockfile(){ fn_print_error_eol_nl fn_script_log_error "Checking lockfile: No lockfile found: ERROR" fn_sleep_time - echo -en "* Start ${selfname} to run monitor." + echo -e "* Start ${selfname} to run monitor." core_exit.sh fi # Fix if lockfile is not unix time or contains letters - if [[ "$(cat "${lockdir}/${selfname}.lock")" =~ [A-Za-z] ]]; then - date '+%s' > "${lockdir}/${selfname}.lock" + if [[ "$(cat "${rootdir}/${lockselfname}")" =~ [A-Za-z] ]]; then + date '+%s' > "${rootdir}/${lockselfname}" fi } @@ -108,7 +108,7 @@ for queryattempt in {1..5}; do fn_script_log_info "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt} : QUERYING" fn_sleep_time # querydelay - if [ "$(cat "${lockdir}/${selfname}.lock")" -gt "$(date "+%s" -d "${querydelay} mins ago")" ]; then + if [ "$(cat "${rootdir}/${lockselfname}")" -gt "$(date "+%s" -d "${querydelay} mins ago")" ]; then fn_print_ok "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: " fn_print_delay_eol_nl fn_script_log_info "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt} : DELAY" @@ -147,6 +147,9 @@ for queryattempt in {1..5}; do if [ "${gdplayers}" ]; then fn_script_log_info "Players: ${gdplayers}/${gdmaxplayers}" fi + if [ "${gdbots}" ]; then + fn_script_log_info "Bots: ${gdbots}" + fi if [ "${gdmap}" ]; then fn_script_log_info "Map: ${gdmap}" fi @@ -236,7 +239,6 @@ info_parms.sh # query pre-checks fn_monitor_check_lockfile -check_last_update.sh fn_monitor_check_update fn_monitor_check_session # Monitor will not continue if session only check. From a2eb7f66e4a6149e85e95222771d9edf43570cb7 Mon Sep 17 00:00:00 2001 From: Jimmy Maple <38733055+jimmyatSplunk@users.noreply.github.com> Date: Sun, 12 Apr 2020 23:59:58 -0400 Subject: [PATCH 3/5] fix(messages): Fix to set proper component logging Fixed issue where messages from different actions weren't logging correctly due to using the wrong variable in when crafting the log message --- lgsm/functions/core_messages.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index da90ebc43..386ff1c7c 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -47,7 +47,7 @@ fn_sleep_time(){ fn_script_log(){ if [ -d "${lgsmlogdir}" ]; then if [ "${modulename}" ]; then - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandname}: ${1}" >> "${lgsmlog}" + echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandaction}: ${1}" >> "${lgsmlog}" else echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${1}" >> "${lgsmlog}" fi @@ -59,7 +59,7 @@ fn_script_log_pass(){ if [ -d "${lgsmlogdir}" ]; then if [ "${modulename}" ]; then - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandname}: PASS: ${1}" >> "${lgsmlog}" + echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandaction}: PASS: ${1}" >> "${lgsmlog}" else echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: PASS: ${1}" >> "${lgsmlog}" fi @@ -83,7 +83,7 @@ fn_script_log_fatal(){ fn_script_log_error(){ if [ -d "${lgsmlogdir}" ]; then if [ "${modulename}" ]; then - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandname}: ERROR: ${1}" >> "${lgsmlog}" + echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandaction}: ERROR: ${1}" >> "${lgsmlog}" else echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ERROR: ${1}" >> "${lgsmlog}" fi @@ -95,7 +95,7 @@ fn_script_log_error(){ fn_script_log_warn(){ if [ -d "${lgsmlogdir}" ]; then if [ "${modulename}" ]; then - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandname}: WARN: ${1}" >> "${lgsmlog}" + echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandaction}: WARN: ${1}" >> "${lgsmlog}" else echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: WARN: ${1}" >> "${lgsmlog}" fi @@ -107,7 +107,7 @@ fn_script_log_warn(){ fn_script_log_info(){ if [ -d "${lgsmlogdir}" ]; then if [ "${modulename}" ]; then - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandname}: INFO: ${1}" >> "${lgsmlog}" + echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandaction}: INFO: ${1}" >> "${lgsmlog}" else echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: INFO: ${1}" >> "${lgsmlog}" fi From b0f782a6532a10cdebecc23cc91f4cb19a3bb08e Mon Sep 17 00:00:00 2001 From: Jimmy Maple Date: Mon, 13 Apr 2020 18:32:54 -0400 Subject: [PATCH 4/5] Confirm commit for changes made Commit changes made after pull change submiited. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 25996581a..6fecaea1a 100644 --- a/README.md +++ b/README.md @@ -60,3 +60,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! + From a6c2352ebc526d8a972b679d8c3996361e782ebf Mon Sep 17 00:00:00 2001 From: Jimmy Maple Date: Sun, 19 Apr 2020 00:28:19 -0400 Subject: [PATCH 5/5] fix(command_backup): Correct path for exludedir variable The current implementation doesn't use the full file path to determine the existence of the backup directory in relation to the server which means the current stats just looks for the "lgsm/backup" directory. That may work if you're already in the root directory for the server but if you're scripting the backups via cron, you're not likely going to be invoking the backup from the root directory. --- lgsm/functions/command_backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index 5e84d76d1..99cd1237c 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -132,7 +132,7 @@ fn_backup_compression(){ excludedir=$(fn_backup_relpath) # Check that excludedir is a valid path. - if [ ! -d "${excludedir}" ] ; then + if [ ! -d "${rootdir}/${excludedir}" ] ; then fn_print_fail_nl "Problem identifying the previous backup directory for exclusion." fn_script_log_fatal "Problem identifying the previous backup directory for exclusion" core_exit.sh