From d9e1af2c25ad765ff013e11690c1b100b7502f74 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 10 Sep 2018 21:50:51 +0100 Subject: [PATCH] ANSI colour disabling can now works. ansi colours fails to disable as core_messages.sh loaded before the config. ansi colours are now in a function that is called after the config has been loaded. allowing colour to only load once the config has confirmed that it is allowed. --- lgsm/functions/core_messages.sh | 3 ++- linuxgsm.sh | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index cff44d140..6dc791fc3 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -7,7 +7,7 @@ # nl: new line: message is following by a new line # eol: end of line: message is placed at the end of the current line - +fn_ansi_loader(){ if [ "${ansi}" != "off" ]; then # echo colors default="\e[0m" @@ -27,6 +27,7 @@ if [ "${ansi}" != "off" ]; then # carriage return & erase to end of line creeol="\r\033[K" fi +} # Log display ######################## diff --git a/linuxgsm.sh b/linuxgsm.sh index 7ed07760a..004f34677 100755 --- a/linuxgsm.sh +++ b/linuxgsm.sh @@ -79,14 +79,14 @@ fn_bootstrap_fetch_file(){ curlcmd=$(${curlpath} -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1) local exitcode=$? if [ ${exitcode} -ne 0 ]; then - echo -e "\e[0;31mFAIL\e[0m\n" + echo -e "FAIL" if [ -f "${lgsmlog}" ]; then echo -e "${remote_fileurl}" | tee -a "${lgsmlog}" echo "${curlcmd}" | tee -a "${lgsmlog}" fi exit 1 else - echo -e "\e[0;32mOK\e[0m" + echo -e "OK" fi else echo "[ FAIL ] Curl is not installed" @@ -324,10 +324,10 @@ else cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg" exitcode=$? if [ ${exitcode} -ne 0 ]; then - echo -e "\e[0;31mFAIL\e[0m\n" + echo -e "FAIL" exit 1 else - echo -e "\e[0;32mOK\e[0m" + echo -e "OK" fi else function_file_diff=$(diff -q "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg") @@ -337,10 +337,10 @@ else cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg" exitcode=$? if [ ${exitcode} -ne 0 ]; then - echo -e "\e[0;31mFAIL\e[0m\n" + echo -e "FAIL" exit 1 else - echo -e "\e[0;32mOK\e[0m" + echo -e "OK" fi fi fi @@ -359,11 +359,13 @@ else else source "${configdirserver}/${servicename}.cfg" fi + # Load the linuxgsm.sh in to tmpdir. If missing download it if [ ! -f "${tmpdir}/linuxgsm.sh" ]; then fn_fetch_file_github "" "linuxgsm.sh" "${tmpdir}" "chmodx" "norun" "noforcedl" "nomd5" fi - + # Enables ANSI colours from core_messages.sh. Can be disabled with ansi=off + fn_ansi_loader # Prevents running of core_exit.sh for Travis. if [ "${travistest}" != "1" ]; then getopt=$1