Browse Source

standardise exitcode

feature/dst-changes
Daniel Gibbs 4 months ago
parent
commit
0de015177a
  1. 2
      lgsm/modules/alert_email.sh
  2. 3
      lgsm/modules/check_deps.sh
  3. 4
      lgsm/modules/command_backup.sh
  4. 7
      lgsm/modules/command_debug.sh
  5. 24
      lgsm/modules/command_fastdl.sh
  6. 10
      lgsm/modules/command_mods_remove.sh
  7. 2
      lgsm/modules/command_skeleton.sh
  8. 31
      lgsm/modules/command_update_linuxgsm.sh
  9. 2
      lgsm/modules/command_wipe.sh
  10. 22
      lgsm/modules/core_dl.sh
  11. 10
      lgsm/modules/core_exit.sh
  12. 2
      lgsm/modules/core_steamcmd.sh
  13. 3
      lgsm/modules/fix.sh
  14. 9
      lgsm/modules/info_distro.sh
  15. 8
      lgsm/modules/install_complete.sh
  16. 5
      lgsm/modules/install_config.sh
  17. 4
      lgsm/modules/install_ts3db.sh
  18. 46
      lgsm/modules/mods_core.sh
  19. 4
      lgsm/modules/update_mcb.sh
  20. 14
      linuxgsm.sh

2
lgsm/modules/alert_email.sh

@ -15,7 +15,7 @@ else
mail -s "${alerttitle}" "${email}" < "${alertlog}"
fi
exitcode=$?
if [ "${exitcode}" == "0" ]; then
if [ "${exitcode}" -qe 0 ]; then
fn_print_ok_nl "Sending Email alert: ${email}"
fn_script_log_pass "Sending Email alert: ${email}"
else

3
lgsm/modules/check_deps.sh

@ -78,7 +78,8 @@ fn_install_mono_repo() {
# Did Mono repo install correctly?
if [ "${monoautoinstall}" != "1" ]; then
if [ $? != 0 ]; then
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_print_failure_nl "Unable to install Mono repository."
fn_script_log_fail "Unable to install Mono repository."
else

4
lgsm/modules/command_backup.sh

@ -127,8 +127,8 @@ fn_backup_compression() {
fi
tar --use-compress-program=pigz -cf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "${excludedir}" --exclude "${lockdir}" --exclude "${tmpdir}" ./.
local exitcode=$?
if [ "${exitcode}" != 0 ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol
fn_script_log_fail "Backup in progress: FAIL"
echo -e "${extractcmd}" | tee -a "${lgsmlog}"

7
lgsm/modules/command_debug.sh

@ -123,9 +123,10 @@ else
eval "${preexecutable} ${executable} ${startparameters}"
fi
if [ $? -ne 0 ]; then
fn_print_error_nl "Server has stopped: exit code: $?"
fn_script_log_error "Server has stopped: exit code: $?"
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_error_nl "Server has stopped: exit code: ${exitcode}"
fn_script_log_error "Server has stopped: exit code: ${exitcode}"
fn_print_error_nl "Press ENTER to exit debug mode"
read -r
else

24
lgsm/modules/command_fastdl.sh

@ -68,7 +68,7 @@ fn_clear_old_fastdl() {
fn_print "clearing existing Fastdl directory ${fastdldir}"
rm -rf "${fastdldir:?}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Clearing existing Fastdl directory ${fastdldir}"
core_exit.sh
@ -85,7 +85,7 @@ fn_fastdl_dirs() {
fn_print "creating web directory ${webdir}"
mkdir -p "${webdir}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Creating web directory ${webdir}"
core_exit.sh
@ -98,7 +98,7 @@ fn_fastdl_dirs() {
fn_print "creating fastdl directory ${fastdldir}"
mkdir -p "${fastdldir}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Creating fastdl directory ${fastdldir}"
core_exit.sh
@ -214,7 +214,7 @@ fn_fastdl_preview() {
filesize=$(stat -c %s "${dufile}")
filesizetotal=$((filesizetotal + filesize))
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Calculating total file size"
core_exit.sh
@ -247,7 +247,7 @@ fn_fastdl_gmod() {
fn_print "copying ${allowed_extention} : ${fileswc}"
cp --parents "${fastdlfile}" "${fastdldir}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Copying ${fastdlfile} > ${fastdldir}"
core_exit.sh
@ -264,7 +264,7 @@ fn_fastdl_gmod() {
fn_print "updating addons file structure..."
cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Updating addons file structure"
core_exit.sh
@ -277,7 +277,7 @@ fn_fastdl_gmod() {
fn_sleep_time_1
rm -rf "${fastdldir:?}/addons"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Clearing addons dir from fastdl dir"
core_exit.sh
@ -292,7 +292,7 @@ fn_fastdl_gmod() {
fn_sleep_time_1
cp -Rf "${fastdldir}/lua/"* "${fastdldir}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Correcting DarkRP files"
core_exit.sh
@ -343,7 +343,7 @@ fn_fastdl_source() {
fi
cp "${fastdlfile}" "${fastdldir}/${copytodir}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Copying ${fastdlfile} > ${fastdldir}/${copytodir}"
core_exit.sh
@ -379,7 +379,7 @@ fn_fastdl_gmod_dl_enforcer() {
fn_print "removing existing download enforcer: ${luafastdlfile}"
rm -f "${luafastdlfullpath:?}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Removing existing download enforcer ${luafastdlfullpath}"
core_exit.sh
@ -397,7 +397,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}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Creating new download enforcer ${luafastdlfullpath}"
core_exit.sh
@ -414,7 +414,7 @@ fn_fastdl_bzip2() {
fn_print "compressing ${filetocompress}"
bzip2 -f "${filetocompress}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Compressing ${filetocompress}"
core_exit.sh

10
lgsm/modules/command_mods_remove.sh

@ -70,8 +70,8 @@ while [ "${modfileline}" -le "${modsfilelistsize}" ]; do
if [ -f "${modinstalldir}/${currentfileremove}" ] || [ -d "${modinstalldir}/${currentfileremove}" ]; then
rm -rf "${modinstalldir:?}/${currentfileremove:?}"
((exitcode = $?))
if [ "${exitcode}" != 0 ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_script_log_fail "Removing ${modinstalldir}/${currentfileremove}"
break
else
@ -87,7 +87,7 @@ done
# Added logic not to fail since removing game specific mods (amxmodxcs) removes files that will
# not be found when removing the base (amxmodx) mod
if [ "${modcommand}" != "amxmodx" ]; then
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
core_exit.sh
else
@ -102,7 +102,7 @@ echo -en "removing ${modcommand}-files.txt..."
fn_sleep_time_1
rm -rf "${modsdir:?}/${modcommand}-files.txt"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_script_log_fail "Removing ${modsdir}/${modcommand}-files.txt"
fn_print_fail_eol_nl
core_exit.sh
@ -117,7 +117,7 @@ fn_sleep_time_1
sed -i "/^${modcommand}$/d" "${modsinstalledlistfullpath}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_script_log_fail "Removing ${modcommand} from ${modsinstalledlist}"
fn_print_fail_eol_nl
core_exit.sh

2
lgsm/modules/command_skeleton.sh

@ -16,7 +16,7 @@ check.sh
# Find all directorys and create them in the skel directory
find "${rootdir}" -type d -not \( -path ./skel -prune \) | cpio -pdvm skel 2> /dev/null
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_nl "Creating skeleton directory"
fn_script_log_fail "Creating skeleton directory"
else

31
lgsm/modules/command_update_linuxgsm.sh

@ -27,10 +27,11 @@ fn_script_log_info "Selecting repo"
# Select remotereponame
curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null
if [ $? != "0" ]; then
exitcode=$?
if [ "${exitcode}" -ne "0" ]; then
curl curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null
if [ $? != "0" ]; then
exitcode=$?
if [ "${exitcode}" -ne "0" ]; then
fn_print_fail_nl "Selecting repo: Unable to to access GitHub or Bitbucket repositories"
fn_script_log_fail "Selecting repo: Unable to to access GitHub or Bitbucket repositories"
core_exit.sh
@ -50,10 +51,11 @@ if [ "${remotereponame}" == "GitHub" ]; then
else
curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null
fi
if [ $? != "0" ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Checking ${remotereponame} linuxgsm.sh"
fn_script_log_fail "Curl returned error: $?"
fn_script_log_fail "Curl returned error: ${exitcode}"
core_exit.sh
fi
@ -88,7 +90,8 @@ if [ "${script_diff}" != "" ]; then
mkdir -p "${backupdir}/script"
fi
cp "${rootdir}/${selfname}" "${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak"
if [ $? != 0 ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Backup ${selfname}"
core_exit.sh
@ -109,7 +112,8 @@ if [ "${script_diff}" != "" ]; then
sed -i "s+githubrepo=\"LinuxGSM\"+githubrepo=\"${githubrepo}\"+g" "${rootdir}/${selfname}"
sed -i "s+githubbranch=\"master\"+githubbranch=\"${githubbranch}\"+g" "${rootdir}/${selfname}"
if [ $? != "0" ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "copying ${selfname}"
core_exit.sh
@ -130,10 +134,11 @@ if [ "${remotereponame}" == "GitHub" ]; then
else
curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg" 1> /dev/null
fi
if [ $? != "0" ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Checking ${remotereponame} config _default.cfg"
fn_script_log_fail "Curl returned error: $?"
fn_script_log_fail "Curl returned error: ${exitcode}"
core_exit.sh
fi
@ -164,10 +169,11 @@ if [ -f "${datadir}/${distroid}-${distroversioncsv}.csv" ]; then
else
curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv" 1> /dev/null
fi
if [ $? != "0" ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Checking ${remotereponame} ${distroid}-${distroversioncsv}.csv"
fn_script_log_fail "Curl returned error: $?"
fn_script_log_fail "Curl returned error: ${exitcode}"
core_exit.sh
fi
@ -202,7 +208,8 @@ if [ -n "${modulesdir}" ]; then
else
curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${modulefile}" 1> /dev/null
fi
if [ $? != 0 ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_error_eol_nl
fn_script_log_error "Checking ${remotereponame} module ${modulefile}"
echo -en "removing module ${modulefile}...\c"

2
lgsm/modules/command_wipe.sh

@ -13,7 +13,7 @@ fn_firstcommand_set
# Provides an exit code upon error.
fn_wipe_exit_code() {
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
core_exit.sh
else

22
lgsm/modules/core_dl.sh

@ -54,7 +54,7 @@ fn_dl_steamcmd() {
rm -f "${steamcmdlog:?}"
fi
counter=0
while [ "${counter}" == "0" ] || [ "${exitcode}" != "0" ]; do
while [ "${counter}" -eq 0 ] || [ "${exitcode}" -ne 0 ]; do
counter=$((counter + 1))
# Select SteamCMD parameters
# If GoldSrc (appid 90) servers. GoldSrc (appid 90) require extra commands.
@ -133,7 +133,7 @@ fn_dl_steamcmd() {
fn_print_nl "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}" -ne 0 ]; then
fn_print_error2_nl "${commandaction} ${selfname}: ${remotelocation}: Exit code: ${exitcode}"
fn_script_log_error "${commandaction} ${selfname}: ${remotelocation}: Exit code: ${exitcode}"
else
@ -154,8 +154,8 @@ fn_clear_tmp() {
echo -en "clearing tmp directory [ ${italic}${tmpdir}${default} ]"
if [ -d "${tmpdir}" ]; then
rm -rf "${tmpdir:?}/"*
local exitcode=$?
if [ "${exitcode}" != 0 ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_error_eol_nl
fn_script_log_error "clearing tmp directory ${tmpdir}"
else
@ -260,8 +260,8 @@ fn_dl_extract() {
extractcmd=$(unzip -qo -d "${extractdest}" "${local_filedir}/${local_filename}")
fi
fi
local exitcode=$?
if [ "${exitcode}" != 0 ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Extracting ${local_filename}"
if [ -f "${lgsmlog}" ]; then
@ -316,10 +316,10 @@ fn_check_file() {
counter=$((counter + 1))
echo -e "checking ${fileurl_name} ${remote_filename}\c"
curlcmd=$(curl --output /dev/null --silent --head --fail "${fileurl}" 2>&1)
local exitcode=$?
exitcode=$?
# On first try will error. On second try will fail.
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
if [ ${counter} -ge 2 ]; then
fn_print_fail_eol_nl
if [ -f "${lgsmlog}" ]; then
@ -404,12 +404,12 @@ fn_fetch_file() {
echo -e "downloading file [ ${italic}${local_filename}${default} ]"
fn_sleep_time
"${curlcmd[@]}" --progress-bar "${fileurl}" 2>&1
exitcode="$?"
exitcode=$?
echo -en "downloading file [ ${italic}${local_filename}${default} ]"
else
echo -en "fetching ${fileurl_name} [ ${italic}${local_filename}${default} ]\c"
"${curlcmd[@]}" --silent --show-error "${fileurl}" 2>&1
exitcode="$?"
exitcode=$?
fi
# Download will fail if downloads a html file.
@ -421,7 +421,7 @@ fn_fetch_file() {
fi
# On first try will error. On second try will fail.
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
if [ ${counter} -ge 2 ]; then
fn_print_fail_eol_nl
if [ -f "${lgsmlog}" ]; then

10
lgsm/modules/core_exit.sh

@ -27,14 +27,14 @@ fi
if [ "${exitbypass}" ]; then
unset exitbypass
elif [ "${exitcode}" != "0" ]; then
elif [ "${exitcode}" -ne 0 ]; then
# List LinuxGSM version in logs
fn_script_log_info "LinuxGSM version: ${version}"
if [ "${exitcode}" == "1" ]; then
if [ "${exitcode}" -eq 1 ]; then
fn_script_log_fail "${moduleselfname} exiting with code: ${exitcode}"
elif [ "${exitcode}" == "2" ]; then
elif [ "${exitcode}" -eq 2 ]; then
fn_script_log_error "${moduleselfname} exiting with code: ${exitcode}"
elif [ "${exitcode}" == "3" ]; then
elif [ "${exitcode}" -eq 3 ]; then
fn_script_log_warn "${moduleselfname} exiting with code: ${exitcode}"
else
# if exit code is not set assume error.
@ -45,7 +45,7 @@ elif [ "${exitcode}" != "0" ]; then
# remove trap.
trap - INT
exit "${exitcode}"
elif [ "${exitcode}" ] && [ "${exitcode}" == "0" ]; then
elif [ "${exitcode}" ] && [ "${exitcode}" -qe 0 ]; then
# List LinuxGSM version in logs
fn_script_log_info "LinuxGSM version: ${version}"
fn_script_log_pass "${moduleselfname} exiting with code: ${exitcode}"

2
lgsm/modules/core_steamcmd.sh

@ -129,7 +129,7 @@ fn_check_steamcmd_clear() {
if [ "$(command -v steamcmd 2> /dev/null)" ] && [ -d "${rootdir}/steamcmd" ]; then
rm -rf "${steamcmddir:?}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_script_log_fail "Removing ${rootdir}/steamcmd"
else
fn_script_log_pass "Removing ${rootdir}/steamcmd"

3
lgsm/modules/fix.sh

@ -22,7 +22,8 @@ fn_fix_msg_start_nl() {
}
fn_fix_msg_end() {
if [ $? != 0 ]; then
exirtcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_error_nl "Applying ${fixname} fix: ${gamename}"
fn_script_log_error "Applying ${fixname} fix: ${gamename}"
else

9
lgsm/modules/info_distro.sh

@ -188,13 +188,10 @@ if [ "$(command -v numfmt 2> /dev/null)" ]; then
else
# Older distros will need to use free.
# Older versions of free do not support -h option.
if [ "$(
free -h > /dev/null 2>&1
echo $?
)" -ne "0" ]; then
humanreadable="-m"
else
if free -h > /dev/null 2>&1; then
humanreadable="-h"
else
humanreadable="-m"
fi
physmemtotalmb="$(free -m | awk '/Mem:/ {print $2}')" # integer
physmemtotalgb="$(free -m | awk '/Mem:/ {print $2}')" # integer

8
lgsm/modules/install_complete.sh

@ -9,16 +9,16 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
echo -e ""
if [ "${exitcode}" == "1" ]; then
if [ "${exitcode}" -eq 1 ]; then
echo -e "${bold}${red}Install Failed!${default}"
fn_script_log_fail "Install Failed!"
elif [ "${exitcode}" == "2" ]; then
elif [ "${exitcode}" -eq 2 ]; then
echo -e "${bold}${red}Install Completed with Errors!${default}}"
fn_script_log_error "Install Completed with Errors!"
elif [ "${exitcode}" == "3" ]; then
elif [ "${exitcode}" -eq 3 ]; then
echo -e "${bold}${lightyellow}Install Completed with Warnings!${default}}"
fn_script_log_warn "Install Completed with Warnings!"
elif [ -z "${exitcode}" ] || [ "${exitcode}" == "0" ]; then
elif [ -z "${exitcode}" ] || [ "${exitcode}" -qe 0 ]; then
echo -e "${bold}${green}Install Complete!${default}"
fn_script_log_pass "Install Complete!"
fi

5
lgsm/modules/install_config.sh

@ -104,7 +104,7 @@ fn_default_config_local() {
echo -en "copying config file [ ${italic}${servercfgdefault}${default} ]: "
cp --update=none "${servercfgdir}/${servercfgdefault}" "${servercfgfullpath}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol
fn_script_log_fail "copying config file [ ${servercfgdefault} ]: "
else
@ -191,7 +191,8 @@ fn_set_dst_config_vars() {
echo -en "generating cluster key"
changes=""
changes+=$(sed -i "s/CLUSTERKEY/${randomstring}/g w /dev/stdout" "${clustercfgfullpath}")
if [ "$?" -ne 0 ]; then # shellcheck disable=SC2181
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol
fn_script_log_fail "generating cluster key"
elif [ "${changes}" != "" ]; then

4
lgsm/modules/install_ts3db.sh

@ -11,8 +11,8 @@ fn_install_ts3db_mariadb() {
if [ ! -f "${serverfiles}/libts3db_mariadb.so" ]; then
echo -e "copying libmariadb.so.2...\c"
cp "${serverfiles}/redist/libmariadb.so.2" "${serverfiles}"
local exitcode=$?
if [ "${exitcode}" != "0" ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "copying libmariadb.so.2"
core_exit.sh

46
lgsm/modules/mods_core.sh

@ -57,8 +57,8 @@ fn_mod_lowercase() {
# Finally we can rename the file
mv "${src}" "${dst}"
# Exit if it fails for any reason
local exitcode=$?
if [ "${exitcode}" != 0 ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
core_exit.sh
fi
@ -74,8 +74,8 @@ fn_mod_create_filelist() {
fn_sleep_time
# ${modsdir}/${modcommand}-files.txt.
find "${extractdest}" -mindepth 1 -printf '%P\n' > "${modsdir}/${modcommand}-files.txt"
local exitcode=$?
if [ "${exitcode}" != 0 ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Building ${modsdir}/${modcommand}-files.txt"
core_exit.sh
@ -94,8 +94,8 @@ fn_mod_copy_destination() {
echo -en "copying ${modprettyname} to ${modinstalldir}..."
fn_sleep_time
cp -Rf "${extractdest}/." "${modinstalldir}/"
local exitcode=$?
if [ "${exitcode}" != 0 ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Copying ${modprettyname} to ${modinstalldir}"
else
@ -132,8 +132,8 @@ fn_mod_tidy_files_list() {
# Delete line(s) matching exactly.
sed -i "/^${removefilevar}$/d" "${modsdir}/${modcommand}-files.txt"
# Exit on error.
local exitcode=$?
if [ "${exitcode}" != 0 ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Error while tidying line: ${removefilevar} from: ${modsdir}/${modcommand}-files.txt"
core_exit.sh
@ -388,7 +388,7 @@ fn_create_mods_dir() {
echo -en "creating LinuxGSM mods data directory ${modsdir}..."
mkdir -p "${modsdir}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Creating mod download dir ${modsdir}"
core_exit.sh
@ -402,7 +402,7 @@ fn_create_mods_dir() {
echo -en "creating mods install directory ${modinstalldir}..."
mkdir -p "${modinstalldir}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Creating mod install directory ${modinstalldir}"
core_exit.sh
@ -425,7 +425,7 @@ fn_mods_create_tmp_dir() {
mkdir -p "${modstmpdir}"
exitcode=$?
echo -en "creating mod download directory ${modstmpdir}..."
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Creating mod download directory ${modstmpdir}"
core_exit.sh
@ -442,7 +442,7 @@ fn_mods_clear_tmp_dir() {
echo -en "clearing mod download directory ${modstmpdir}..."
rm -rf "${modstmpdir:?}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Clearing mod download directory ${modstmpdir}"
core_exit.sh
@ -580,7 +580,7 @@ fn_mod_install_liblist_gam_file() {
grep -q "addons/metamod/dlls/metamod.dll" "${modinstalldir}/liblist.gam"
exitcode=$?
# if replacement back didn't happen, error out.
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_script_log_fail "${logentry}"
fn_print_fail_eol_nl
else
@ -596,7 +596,7 @@ fn_mod_install_liblist_gam_file() {
grep -q "addons/metamod/dlls/metamod.so" "${modinstalldir}/liblist.gam"
exitcode=$?
# if replacement back didn't happen, error out
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_script_log_fail "${logentry}"
fn_print_fail_eol_nl
else
@ -614,7 +614,7 @@ fn_mod_install_liblist_gam_file() {
grep -q "addons/metamod/dlls/metamod.dylib" "${modinstalldir}/liblist.gam"
exitcode=$?
# if replacement back didn't happen, error out.
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_script_log_fail "${logentry}"
fn_print_fail_eol_nl
else
@ -638,7 +638,7 @@ fn_mod_remove_liblist_gam_file() {
grep -q "${moddll}" "${modinstalldir}/liblist.gam"
exitcode=$?
# if replacement back didn't happen, error out.
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_script_log_fail "${logentry}"
fn_print_fail_eol_nl
else
@ -654,7 +654,7 @@ fn_mod_remove_liblist_gam_file() {
grep -q "${modso}" "${modinstalldir}/liblist.gam"
exitcode=$?
# if replacement back didn't happen, error out
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_script_log_fail "${logentry}"
fn_print_fail_eol_nl
else
@ -672,7 +672,7 @@ fn_mod_remove_liblist_gam_file() {
grep -q "${moddylib}" "${modinstalldir}/liblist.gam"
# if replacement back didn't happen, error out.
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_script_log_fail "${logentry}"
fn_print_fail_eol_nl
else
@ -691,11 +691,11 @@ fn_mod_install_amxmodx_file() {
echo -en "adding amxmodx_mm_i386.so in plugins.ini..."
grep -q "amxmodx_mm_i386.so" "${modinstalldir}/addons/metamod/plugins.ini"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
# file exists but the entry does not, let's add it
echo "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" >> "${modinstalldir}/addons/metamod/plugins.ini"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_script_log_fail "${logentry}"
fn_print_fail_eol_nl
else
@ -707,7 +707,7 @@ fn_mod_install_amxmodx_file() {
# create new file and add the mod to it
echo "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" > "${modinstalldir}/addons/metamod/plugins.ini"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_script_log_fail "${logentry}"
fn_print_fail_eol_nl
core_exit.sh
@ -726,13 +726,13 @@ fn_mod_remove_amxmodx_file() {
grep -q "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" "${modinstalldir}/addons/metamod/plugins.ini"
# iIs it found? If so remove it and clean up
exitcode=$?
if [ "${exitcode}" == 0 ]; then
if [ "${exitcode}" -eq 0 ]; then
# delete the line we inserted
sed -i '/linux addons\/amxmodx\/dlls\/amxmodx_mm_i386.so/d' "${modinstalldir}/addons/metamod/plugins.ini"
# remove empty lines
sed -i '/^$/d' "${modinstalldir}/addons/metamod/plugins.ini"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
fn_script_log_fail "${logentry}"
fn_print_fail_eol_nl
else

4
lgsm/modules/update_mcb.sh

@ -15,8 +15,8 @@ fn_update_dl() {
else
unzip -oq "${tmpdir}/bedrock_server.${remotebuildversion}.zip" -x "permissions.json" "server.properties" "allowlist.json" -d "${serverfiles}"
fi
local exitcode=$?
if [ "${exitcode}" != 0 ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fail "Extracting ${local_filename}"
if [ -f "${lgsmlog}" ]; then

14
linuxgsm.sh

@ -154,12 +154,12 @@ fn_bootstrap_fetch_file() {
echo -e "downloading file [ ${local_filename} ]"
fn_sleep_time
"${curlcmd[@]}" --progress-bar "${fileurl}" 2>&1
exitcode="$?"
exitcode=$?
echo -en "downloading file [ ${local_filename} ]"
else
echo -en "fetching ${fileurl_name} [ ${local_filename} ]\c"
"${curlcmd[@]}" --silent --show-error "${fileurl}" 2>&1
exitcode="$?"
exitcode=$?
fi
# Download will fail if downloads a html file.
@ -171,7 +171,7 @@ fn_bootstrap_fetch_file() {
fi
# On first try will error. On second try will fail.
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
if [ ${counter} -ge 2 ]; then
echo -e " ... FAIL"
if [ -f "${lgsmlog}" ]; then
@ -293,7 +293,8 @@ fn_install_menu_whiptail() {
menu_options+=("${val//\"/}" "${key//\"/}")
done < "${options}"
OPTION=$(${menucmd} --title "${title}" --menu "${caption}" "${height}" "${width}" "${menuheight}" "${menu_options[@]}" 3>&1 1>&2 2>&3)
if [ $? == 0 ]; then
exitcode=$?
if [ "${exitcode}" == 0 ]; then
eval "$resultvar=\"${OPTION}\""
else
eval "$resultvar="
@ -445,7 +446,7 @@ else
echo -en "copying _default.cfg\c"
cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
if [ "${exitcode}" -ne 0 ]; then
echo -e " ... FAIL"
exit 1
else
@ -457,7 +458,8 @@ else
fn_print_warn_nl "_default.cfg has altered. reloading config."
echo -en "copying _default.cfg...\c"
cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg"
if [ $? != 0 ]; then
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
echo -e "FAIL"
exit 1
else

Loading…
Cancel
Save