From 78881f5e71ade75fdd958240a5e990546c19aa86 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 11 Jul 2020 01:21:13 +0100 Subject: [PATCH] updated exit code if --- lgsm/functions/check_steamcmd.sh | 2 +- lgsm/functions/command_backup.sh | 2 +- lgsm/functions/command_fastdl.sh | 22 +++++++++++----------- lgsm/functions/command_mods_remove.sh | 8 ++++---- lgsm/functions/command_wipe.sh | 2 +- lgsm/functions/core_dl.sh | 6 +++--- lgsm/functions/mods_core.sh | 16 ++++++++-------- linuxgsm.sh | 2 +- tests/tests_fctrserver.sh | 6 +++--- tests/tests_jc2server.sh | 6 +++--- tests/tests_mcserver.sh | 6 +++--- tests/tests_ts3server.sh | 6 +++--- 12 files changed, 42 insertions(+), 42 deletions(-) diff --git a/lgsm/functions/check_steamcmd.sh b/lgsm/functions/check_steamcmd.sh index aa4140bbe..456870054 100644 --- a/lgsm/functions/check_steamcmd.sh +++ b/lgsm/functions/check_steamcmd.sh @@ -130,7 +130,7 @@ fn_check_steamcmd_clear(){ if [ "$(command -v steamcmd 2>/dev/null)" ]&&[ -d "${rootdir}/steamcmd" ]; then rm -rf "${steamcmddir:?}" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_script_log_fatal "Removing ${rootdir}/steamcmd" else fn_script_log_pass "Removing ${rootdir}/steamcmd" diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index d00bbdc86..7d62e965b 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -141,7 +141,7 @@ fn_backup_compression(){ tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "${excludedir}" --exclude "${lockdir}/backup.lock" ./. local exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol fn_script_log_fatal "Backup in progress: FAIL" echo -e "${extractcmd}" | tee -a "${lgsmlog}" diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index 623596b08..a4d06d5e6 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -72,7 +72,7 @@ fn_clear_old_fastdl(){ echo -en "clearing existing FastDL directory ${fastdldir}..." rm -fR "${fastdldir:?}" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Clearing existing FastDL directory ${fastdldir}" core_exit.sh @@ -89,7 +89,7 @@ fn_fastdl_dirs(){ echo -en "creating web directory ${webdir}..." mkdir -p "${webdir}" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Creating web directory ${webdir}" core_exit.sh @@ -102,7 +102,7 @@ fn_fastdl_dirs(){ echo -en "creating fastdl directory ${fastdldir}..." mkdir -p "${fastdldir}" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Creating fastdl directory ${fastdldir}" core_exit.sh @@ -248,7 +248,7 @@ fn_fastdl_gmod(){ echo -e "copying ${allowed_extention} : ${fileswc}..." cp --parents "${fastdlfile}" "${fastdldir}" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Copying ${fastdlfile} > ${fastdldir}" core_exit.sh @@ -265,7 +265,7 @@ fn_fastdl_gmod(){ echo -en "updating addons file structure..." cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Updating addons file structure" core_exit.sh @@ -278,7 +278,7 @@ fn_fastdl_gmod(){ fn_sleep_time rm -fR "${fastdldir:?}/addons" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Clearing addons dir from fastdl dir" core_exit.sh @@ -293,7 +293,7 @@ fn_fastdl_gmod(){ fn_sleep_time cp -Rf "${fastdldir}/lua/"* "${fastdldir}" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Correcting DarkRP files" core_exit.sh @@ -345,7 +345,7 @@ fn_fastdl_source(){ fi cp "${fastdlfile}" "${fastdldir}/${copytodir}" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Copying ${fastdlfile} > ${fastdldir}/${copytodir}" core_exit.sh @@ -381,7 +381,7 @@ fn_fastdl_gmod_dl_enforcer(){ echo -en "removing existing download enforcer: ${luafastdlfile}..." rm -f "${luafastdlfullpath:?}" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Removing existing download enforcer ${luafastdlfullpath}" core_exit.sh @@ -399,7 +399,7 @@ fn_fastdl_gmod_dl_enforcer(){ echo -e "resource.AddFile( \"${line}\" )" >> "${luafastdlfullpath}" done < <(find "${fastdldir:?}" \( -type f ! -name "*.bz2" \) -printf '%P\n') exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Creating new download enforcer ${luafastdlfullpath}" core_exit.sh @@ -416,7 +416,7 @@ fn_fastdl_bzip2(){ echo -en "\r\033[Kcompressing ${filetocompress}..." bzip2 -f "${filetocompress}" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Compressing ${filetocompress}" core_exit.sh diff --git a/lgsm/functions/command_mods_remove.sh b/lgsm/functions/command_mods_remove.sh index e353e7ec6..b2062333e 100644 --- a/lgsm/functions/command_mods_remove.sh +++ b/lgsm/functions/command_mods_remove.sh @@ -73,7 +73,7 @@ while [ "${modfileline}" -le "${modsfilelistsize}" ]; do if [ -f "${modinstalldir}/${currentfileremove}" ]||[ -d "${modinstalldir}/${currentfileremove}" ]; then rm -rf "${modinstalldir:?}/${currentfileremove:?}" ((exitcode=$?)) - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_script_log_fatal "Removing ${modinstalldir}/${currentfileremove}" break else @@ -84,7 +84,7 @@ while [ "${modfileline}" -le "${modsfilelistsize}" ]; do echo -e "removing ${modprettyname} ${modfileline} / ${modsfilelistsize} : ${currentfileremove}..." ((modfileline++)) done -if [ ${exitcode} -ne 0 ]; then +if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl core_exit.sh else @@ -95,7 +95,7 @@ echo -en "removing ${modcommand}-files.txt..." fn_sleep_time rm -rf "${modsdir:?}/${modcommand}-files.txt" local exitcode=$? -if [ ${exitcode} -ne 0 ]; then +if [ "${exitcode}" != 0 ]; then fn_script_log_fatal "Removing ${modsdir}/${modcommand}-files.txt" fn_print_fail_eol_nl core_exit.sh @@ -110,7 +110,7 @@ fn_sleep_time sed -i "/^${modcommand}$/d" "${modsinstalledlistfullpath}" local exitcode=$? -if [ ${exitcode} -ne 0 ]; then +if [ "${exitcode}" != 0 ]; then fn_script_log_fatal "Removing ${modcommand} from ${modsinstalledlist}" fn_print_fail_eol_nl core_exit.sh diff --git a/lgsm/functions/command_wipe.sh b/lgsm/functions/command_wipe.sh index 99c9a1ab6..96e10a98f 100644 --- a/lgsm/functions/command_wipe.sh +++ b/lgsm/functions/command_wipe.sh @@ -15,7 +15,7 @@ fn_commandname # Provides an exit code upon error. fn_wipe_exit_code(){ ((exitcode=$?)) - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_script_log_fatal "${currentaction}" core_exit.sh else diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 89ee784db..514eb3da8 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -25,7 +25,7 @@ fn_clear_tmp(){ if [ -d "${tmpdir}" ]; then rm -rf "${tmpdir:?}/"* local exitcode=$? - if [ ${exitcode} -eq 0 ]; then + if [ "${exitcode}" == 0 ]; then fn_print_ok_eol_nl fn_script_log_pass "clearing LinuxGSM tmp directory" else @@ -82,7 +82,7 @@ fn_dl_extract(){ extractcmd=$(unzip -qo -d "${extractdir}" "${local_filedir}/${local_filename}") fi local exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Extracting download" if [ -f "${lgsmlog}" ]; then @@ -171,7 +171,7 @@ fn_fetch_file(){ fi # On first try will error. On second try will fail. - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then if [ ${counter} -ge 2 ]; then fn_print_fail_eol_nl if [ -f "${lgsmlog}" ]; then diff --git a/lgsm/functions/mods_core.sh b/lgsm/functions/mods_core.sh index da2576207..bd6b6275c 100644 --- a/lgsm/functions/mods_core.sh +++ b/lgsm/functions/mods_core.sh @@ -53,7 +53,7 @@ fn_mod_lowercase(){ done < <(find "${extractdir}" -depth) echo -en "${renamedwc} / ${totalfileswc} / ${fileswc} converting ${modprettyname} files to lowercase..." - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl core_exit.sh else @@ -69,7 +69,7 @@ fn_mod_create_filelist(){ # ${modsdir}/${modcommand}-files.txt. find "${extractdir}" -mindepth 1 -printf '%P\n' > "${modsdir}/${modcommand}-files.txt" local exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Building ${modsdir}/${modcommand}-files.txt" core_exit.sh @@ -89,7 +89,7 @@ fn_mod_copy_destination(){ fn_sleep_time cp -Rf "${extractdir}/." "${modinstalldir}/" local exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Copying ${modprettyname} to ${modinstalldir}" else @@ -127,7 +127,7 @@ fn_mod_tidy_files_list(){ sed -i "/^${removefilevar}$/d" "${modsdir}/${modcommand}-files.txt" # Exit on error. local exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Error while tidying line: ${removefilevar} from: ${modsdir}/${modcommand}-files.txt" core_exit.sh @@ -382,7 +382,7 @@ fn_create_mods_dir(){ echo -en "creating LinuxGSM mods data directory ${modsdir}..." mkdir -p "${modsdir}" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Creating mod download dir ${modsdir}" core_exit.sh @@ -396,7 +396,7 @@ fn_create_mods_dir(){ echo -en "creating mods install directory ${modinstalldir}..." mkdir -p "${modinstalldir}" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Creating mod install directory ${modinstalldir}" core_exit.sh @@ -419,7 +419,7 @@ fn_mods_create_tmp_dir(){ mkdir -p "${modstmpdir}" exitcode=$? echo -en "creating mod download directory ${modstmpdir}..." - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Creating mod download directory ${modstmpdir}" core_exit.sh @@ -436,7 +436,7 @@ fn_mods_clear_tmp_dir(){ echo -en "clearing mod download directory ${modstmpdir}..." rm -fr "${modstmpdir:?}" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then fn_print_fail_eol_nl fn_script_log_fatal "Clearing mod download directory ${modstmpdir}" core_exit.sh diff --git a/linuxgsm.sh b/linuxgsm.sh index aececaed8..849c76472 100755 --- a/linuxgsm.sh +++ b/linuxgsm.sh @@ -113,7 +113,7 @@ fn_bootstrap_fetch_file(){ fi # On first try will error. On second try will fail. - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then if [ ${counter} -ge 2 ]; then echo -e "FAIL" if [ -f "${lgsmlog}" ]; then diff --git a/tests/tests_fctrserver.sh b/tests/tests_fctrserver.sh index da71c2b5a..adb465b1a 100644 --- a/tests/tests_fctrserver.sh +++ b/tests/tests_fctrserver.sh @@ -119,7 +119,7 @@ fn_bootstrap_fetch_file(){ fi # On first try will error. On second try will fail. - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then if [ ${counter} -ge 2 ]; then echo -e "FAIL" if [ -f "${lgsmlog}" ]; then @@ -389,7 +389,7 @@ else echo -en "copying _default.cfg...\c" cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then echo -e "FAIL" exit 1 else @@ -402,7 +402,7 @@ else echo -en "copying _default.cfg...\c" cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then echo -e "FAIL" exit 1 else diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index b52cf1f1b..eaf7047e9 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -120,7 +120,7 @@ fn_bootstrap_fetch_file(){ fi # On first try will error. On second try will fail. - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then if [ ${counter} -ge 2 ]; then echo -e "FAIL" if [ -f "${lgsmlog}" ]; then @@ -390,7 +390,7 @@ else echo -en "copying _default.cfg...\c" cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then echo -e "FAIL" exit 1 else @@ -403,7 +403,7 @@ else echo -en "copying _default.cfg...\c" cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then echo -e "FAIL" exit 1 else diff --git a/tests/tests_mcserver.sh b/tests/tests_mcserver.sh index 8d7bab6b6..74b86b0d6 100644 --- a/tests/tests_mcserver.sh +++ b/tests/tests_mcserver.sh @@ -120,7 +120,7 @@ fn_bootstrap_fetch_file(){ fi # On first try will error. On second try will fail. - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then if [ ${counter} -ge 2 ]; then echo -e "FAIL" if [ -f "${lgsmlog}" ]; then @@ -390,7 +390,7 @@ else echo -en "copying _default.cfg...\c" cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then echo -e "FAIL" exit 1 else @@ -403,7 +403,7 @@ else echo -en "copying _default.cfg...\c" cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then echo -e "FAIL" exit 1 else diff --git a/tests/tests_ts3server.sh b/tests/tests_ts3server.sh index fb4f889bf..d785fa0b5 100644 --- a/tests/tests_ts3server.sh +++ b/tests/tests_ts3server.sh @@ -120,7 +120,7 @@ fn_bootstrap_fetch_file(){ fi # On first try will error. On second try will fail. - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then if [ ${counter} -ge 2 ]; then echo -e "FAIL" if [ -f "${lgsmlog}" ]; then @@ -390,7 +390,7 @@ else echo -en "copying _default.cfg...\c" cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then echo -e "FAIL" exit 1 else @@ -403,7 +403,7 @@ else echo -en "copying _default.cfg...\c" cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg" exitcode=$? - if [ ${exitcode} -ne 0 ]; then + if [ "${exitcode}" != 0 ]; then echo -e "FAIL" exit 1 else