From ce0fad562c6901c15fb08404ff90c38b77d3b769 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 27 Sep 2023 10:18:20 +0100 Subject: [PATCH] refactor: improve logging and error handling in command_update_linuxgsm.sh - Refactored log messages for better clarity and readability. - Improved error handling by checking the return value of curl command. - Updated backup location log message to include brackets. --- lgsm/modules/command_update_linuxgsm.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lgsm/modules/command_update_linuxgsm.sh b/lgsm/modules/command_update_linuxgsm.sh index 22af6b1a2..511a1b480 100644 --- a/lgsm/modules/command_update_linuxgsm.sh +++ b/lgsm/modules/command_update_linuxgsm.sh @@ -36,7 +36,7 @@ else fi # Check linuxsm.sh -echo -en "checking ${remotereponame} [ linuxgsm.sh ]\c" +echo -en "checking ${remotereponame} script [ linuxgsm.sh ]\c" if [ "${remotereponame}" == "GitHub" ]; then curl --connect-timeout 10 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null else @@ -44,7 +44,7 @@ else fi if [ $? != "0" ]; then fn_print_fail_eol_nl - fn_script_log_fatal "Checking ${remotereponame} linuxgsm.sh" + fn_script_log_fatal "Checking ${remotereponame} script linuxgsm.sh" fn_script_log_fatal "Curl returned error: $?" core_exit.sh fi @@ -57,37 +57,37 @@ fi if [ "${tmp_script_diff}" != "" ]; then fn_print_update_eol_nl - fn_script_log "Checking ${remotereponame} linuxgsm.sh" + fn_script_log "Checking ${remotereponame} script linuxgsm.sh" rm -f "${tmpdir:?}/linuxgsm.sh" fn_fetch_file_github "" "linuxgsm.sh" "${tmpdir}" "nochmodx" "norun" "noforcedl" "nohash" else fn_print_update_eol_nl - fn_script_log_pass "Checking ${remotereponame} linuxgsm.sh" + fn_script_log_pass "Checking ${remotereponame} script linuxgsm.sh" fi # Check gameserver.sh # Compare gameserver.sh against linuxgsm.sh in the tmp dir. # Ignoring server specific vars. -echo -en "checking [ ${selfname} ]\c" +echo -en "checking script [ ${selfname} ]\c" fn_script_log_info "Checking ${selfname}" script_diff=$(diff <(sed '\/shortname/d;\/gameservername/d;\/gamename/d;\/githubuser/d;\/githubrepo/d;\/githubbranch/d' "${tmpdir}/linuxgsm.sh") <(sed '\/shortname/d;\/gameservername/d;\/gamename/d;\/githubuser/d;\/githubrepo/d;\/githubbranch/d' "${rootdir}/${selfname}")) if [ "${script_diff}" != "" ]; then fn_print_update_eol_nl - fn_script_log "Checking ${selfname}" + fn_script_log "Checking script ${selfname}" echo -en "backup ${selfname}\c" - fn_script_log_info "Backup ${selfname}" + fn_script_log_info "Backup script ${selfname}" if [ ! -d "${backupdir}/script" ]; then mkdir -p "${backupdir}/script" fi cp "${rootdir}/${selfname}" "${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak" if [ $? != 0 ]; then fn_print_fail_eol_nl - fn_script_log_fatal "Backup ${selfname}" + fn_script_log_fatal "Backup script ${selfname}" core_exit.sh else fn_print_ok_eol_nl - fn_script_log_pass "Backup ${selfname}" - echo -e "backup location ${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak" + fn_script_log_pass "Backup script${selfname}" + echo -e "backup location [ ${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak ]" fn_script_log_pass "Backup location ${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak" fi