Browse Source

updated exit code if

pull/2958/head
Daniel Gibbs 5 years ago
parent
commit
78881f5e71
  1. 2
      lgsm/functions/check_steamcmd.sh
  2. 2
      lgsm/functions/command_backup.sh
  3. 22
      lgsm/functions/command_fastdl.sh
  4. 8
      lgsm/functions/command_mods_remove.sh
  5. 2
      lgsm/functions/command_wipe.sh
  6. 6
      lgsm/functions/core_dl.sh
  7. 16
      lgsm/functions/mods_core.sh
  8. 2
      linuxgsm.sh
  9. 6
      tests/tests_fctrserver.sh
  10. 6
      tests/tests_jc2server.sh
  11. 6
      tests/tests_mcserver.sh
  12. 6
      tests/tests_ts3server.sh

2
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"

2
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}"

22
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

8
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

2
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

6
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

16
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

2
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

6
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

6
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

6
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

6
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

Loading…
Cancel
Save