From 1bcc7f4821165a685eb1d0efc9762885f051e026 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 8 Mar 2023 22:10:50 +0000 Subject: [PATCH] chore: flipping exit code if statements Must have consistancy XD --- lgsm/functions/command_backup.sh | 11 ++++++----- lgsm/functions/core_dl.sh | 14 +++++++------- lgsm/functions/core_exit.sh | 2 +- lgsm/functions/info_game.sh | 6 +++--- lgsm/functions/install_ts3db.sh | 8 ++++---- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index 0dfabcd03..d69c57a0f 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -99,16 +99,17 @@ fn_backup_migrate_olddir() { fn_script_log_info "${rootdir}/backups > ${backupdir}" mv "${rootdir}/backups/"* "${backupdir}" 2> /dev/null exitcode=$? - if [ "${exitcode}" -eq 0 ]; then + if [ "${exitcode}" == 0 ]; then rmdir "${rootdir}/backups" 2> /dev/null exitcode=$? fi - if [ "${exitcode}" -eq 0 ]; then - fn_print_ok_nl "Backup directory is being migrated" - fn_script_log_pass "Backup directory is being migrated" - else + if [ "${exitcode}" != 0 ]; then fn_print_error_nl "Backup directory is being migrated" fn_script_log_error "Backup directory is being migrated" + else + + fn_print_ok_nl "Backup directory is being migrated" + fn_script_log_pass "Backup directory is being migrated" fi fi fi diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 2e6db690e..98daf79cf 100755 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -124,7 +124,7 @@ fn_dl_steamcmd() { echo -en "Please provide content log to LinuxGSM developers https://linuxgsm.com/steamcmd-error" fn_script_log_error "${commandaction} ${selfname}: ${remotelocation}: Unknown error occured" fi - elif [ "${exitcode}" != "0" ]; then + elif [ "${exitcode}" != 0 ]; then fn_print_error2_nl "${commandaction} ${selfname}: ${remotelocation}: Exit code: ${exitcode}" fn_script_log_error "${commandaction} ${selfname}: ${remotelocation}: Exit code: ${exitcode}" else @@ -146,12 +146,12 @@ fn_clear_tmp() { if [ -d "${tmpdir}" ]; then rm -rf "${tmpdir:?}/"* local exitcode=$? - if [ "${exitcode}" == 0 ]; then - fn_print_ok_eol_nl - fn_script_log_pass "clearing LinuxGSM tmp directory" - else + if [ "${exitcode}" != 0 ]; then fn_print_error_eol_nl fn_script_log_error "clearing LinuxGSM tmp directory" + else + fn_print_ok_eol_nl + fn_script_log_pass "clearing LinuxGSM tmp directory" fi fi } @@ -226,7 +226,7 @@ fn_dl_extract() { local exitcode=$? if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl - fn_script_log_fatal "Extracting download" + fn_script_log_fatal "Extracting ${local_filename}" if [ -f "${lgsmlog}" ]; then echo -e "${extractcmd}" >> "${lgsmlog}" fi @@ -234,7 +234,7 @@ fn_dl_extract() { core_exit.sh else fn_print_ok_eol_nl - fn_script_log_pass "Extracting download" + fn_script_log_pass "Extracting ${local_filename}" fi } diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index 2d2f5b8fa..95d9d8cae 100755 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -25,7 +25,7 @@ fi if [ "${exitbypass}" ]; then unset exitbypass -elif [ "${exitcode}" ] && [ "${exitcode}" != "0" ]; then +elif [ "${exitcode}" != "0" ]; then # List LinuxGSM version in logs fn_script_log_info "LinuxGSM version: ${version}" if [ "${exitcode}" == "1" ]; then diff --git a/lgsm/functions/info_game.sh b/lgsm/functions/info_game.sh index 4a1256431..f5dc108da 100644 --- a/lgsm/functions/info_game.sh +++ b/lgsm/functions/info_game.sh @@ -2551,10 +2551,10 @@ if [ ! -f "${tmpdir}/extip.txt" ]; then extip="$(curl --connect-timeout 10 -s https://api.ipify.org 2> /dev/null)" exitcode=$? # if curl passes add extip to externalip.txt - if [ "${exitcode}" == "0" ]; then - echo "${extip}" > "${tmpdir}/extip.txt" - else + if [ "${exitcode}" != "0" ]; then echo "Unable to get external IP address" + else + echo "${extip}" > "${tmpdir}/extip.txt" fi else extip="$(cat "${tmpdir}/extip.txt")" diff --git a/lgsm/functions/install_ts3db.sh b/lgsm/functions/install_ts3db.sh index e394296de..035077757 100755 --- a/lgsm/functions/install_ts3db.sh +++ b/lgsm/functions/install_ts3db.sh @@ -12,13 +12,13 @@ fn_install_ts3db_mariadb() { echo -e "copying libmariadb.so.2...\c" cp "${serverfiles}/redist/libmariadb.so.2" "${serverfiles}" local exitcode=$? - if [ "${exitcode}" == "0" ]; then - fn_print_ok_eol_nl - fn_script_log_pass "copying libmariadb.so.2" - else + if [ "${exitcode}" != "0" ]; then fn_print_fail_eol_nl fn_script_log_fatal "copying libmariadb.so.2" core_exit.sh + else + fn_print_ok_eol_nl + fn_script_log_pass "copying libmariadb.so.2" fi fi