Skip to content

Commit

Permalink
refactor: renamed fatal to fail to improve consistency
Browse files Browse the repository at this point in the history
- Updated the log level from "fatal" to "fail" in the alert scripts.
  • Loading branch information
dgibbs64 committed Oct 1, 2023
1 parent ee738a6 commit eb5c833
Show file tree
Hide file tree
Showing 48 changed files with 144 additions and 144 deletions.
2 changes: 1 addition & 1 deletion lgsm/modules/alert_discord.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ discordsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json"

if [ -n "${discordsend}" ]; then
fn_print_fail_nl "Sending Discord alert: ${discordsend}"
fn_script_log_fatal "Sending Discord alert: ${discordsend}"
fn_script_log_fail "Sending Discord alert: ${discordsend}"
else
fn_print_ok_nl "Sending Discord alert"
fn_script_log_pass "Sending Discord alert"
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/alert_email.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ if [ "${exitcode}" == "0" ]; then
fn_script_log_pass "Sending Email alert: ${email}"
else
fn_print_fail_nl "Sending Email alert: ${email}"
fn_script_log_fatal "Sending Email alert: ${email}"
fn_script_log_fail "Sending Email alert: ${email}"
fi
2 changes: 1 addition & 1 deletion lgsm/modules/alert_gotify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ if [ -n "${gotifysend}" ]; then
fn_script_log_pass "Sending Gotify alert"
else
fn_print_fail_nl "Sending Gotify alert: ${gotifysend}"
fn_script_log_fatal "Sending Gotify alert: ${gotifysend}"
fn_script_log_fail "Sending Gotify alert: ${gotifysend}"
fi
2 changes: 1 addition & 1 deletion lgsm/modules/alert_ifttt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ iftttsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -

if [ -n "${iftttsend}" ]; then
fn_print_fail_nl "Sending IFTTT alert: ${pushbulletsend}"
fn_script_log_fatal "Sending IFTTT alert: ${pushbulletsend}"
fn_script_log_fail "Sending IFTTT alert: ${pushbulletsend}"
else
fn_print_ok_nl "Sending IFTTT alert"
fn_script_log_pass "Sent IFTTT alert"
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/alert_mailgun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mailgunsend=$(curl --connect-timeout 10 -s --user "api:${mailguntoken}" \

if [ -z "${mailgunsend}" ]; then
fn_print_fail_nl "Sending Email alert: Mailgun: ${mailgunemail}"
fn_script_log_fatal "Sending Email alert: Mailgun: ${mailgunemail}"
fn_script_log_fail "Sending Email alert: Mailgun: ${mailgunemail}"
else
fn_print_ok_nl "Sending Email alert: Mailgun: ${mailgunemail}"
fn_script_log_pass "Sending Email alert: Mailgun: ${mailgunemail}"
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/alert_pushbullet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pushbulletsend=$(curl --connect-timeout 10 -sSL -u """${pushbullettoken}"":" -H

if [ -n "${pushbulletsend}" ]; then
fn_print_fail_nl "Sending Pushbullet alert: ${pushbulletsend}"
fn_script_log_fatal "Sending Pushbullet alert: ${pushbulletsend}"
fn_script_log_fail "Sending Pushbullet alert: ${pushbulletsend}"
else
fn_print_ok_nl "Sending Pushbullet alert"
fn_script_log_pass "Sent Pushbullet alert"
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/alert_pushover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pushoversend=$(curl --connect-timeout 10 -sS -F token="${pushovertoken}" -F user

if [ -n "${pushoversend}" ]; then
fn_print_fail_nl "Sending Pushover alert: ${pushoversend}"
fn_script_log_fatal "Sending Pushover alert: ${pushoversend}"
fn_script_log_fail "Sending Pushover alert: ${pushoversend}"
else
fn_print_ok_nl "Sending Pushover alert"
fn_script_log_pass "Sent Pushover alert"
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/alert_rocketchat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ if [ -n "${rocketchatsend}" ]; then
fn_script_log_pass "Sending Rocketchat alert"
else
fn_print_fail_nl "Sending Rocketchat alert: ${rocketchatsend}"
fn_script_log_fatal "Sending Rocketchat alert: ${rocketchatsend}"
fn_script_log_fail "Sending Rocketchat alert: ${rocketchatsend}"
fi
2 changes: 1 addition & 1 deletion lgsm/modules/alert_slack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ if [ "${slacksend}" == "ok" ]; then
fn_script_log_pass "Sending Slack alert"
else
fn_print_fail_nl "Sending Slack alert: ${slacksend}"
fn_script_log_fatal "Sending Slack alert: ${slacksend}"
fn_script_log_fail "Sending Slack alert: ${slacksend}"
fi
2 changes: 1 addition & 1 deletion lgsm/modules/alert_telegram.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ telegramsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json

if [ -n "${telegramsend}" ]; then
fn_print_fail_nl "Sending Telegram alert: ${telegramsend}"
fn_script_log_fatal "Sending Telegram alert: ${telegramsend}"
fn_script_log_fail "Sending Telegram alert: ${telegramsend}"
else
fn_print_ok_nl "Sending Telegram alert"
fn_script_log_pass "Sent Telegram alert"
Expand Down
4 changes: 2 additions & 2 deletions lgsm/modules/check_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ fi

if [ "${shortname}" == "vh" ] && [ -z "${serverpassword}" ]; then
fn_print_fail_nl "serverpassword is not set"
fn_script_log_fatal "serverpassword is not set"
fn_script_log_fail "serverpassword is not set"
elif [ "${shortname}" == "vh" ] && [ "${#serverpassword}" -le "4" ]; then
fn_print_fail_nl "serverpassword is to short (min 5 chars)"
fn_script_log_fatal "serverpassword is to short (min 5 chars)"
fn_script_log_fail "serverpassword is to short (min 5 chars)"
fi
4 changes: 2 additions & 2 deletions lgsm/modules/check_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn_install_mono_repo() {
if [ "${monoautoinstall}" != "1" ]; then
if [ $? != 0 ]; then
fn_print_failure_nl "Unable to install Mono repository."
fn_script_log_fatal "Unable to install Mono repository."
fn_script_log_fail "Unable to install Mono repository."
else
fn_print_complete_nl "Installing Mono repository completed."
fn_script_log_pass "Installing Mono repository completed."
Expand Down Expand Up @@ -215,7 +215,7 @@ fn_install_missing_deps() {
if [ "${steamcmdfail}" ]; then
if [ "${commandname}" == "INSTALL" ]; then
fn_print_failure_nl "Missing dependencies required to run SteamCMD."
fn_script_log_fatal "Missing dependencies required to run SteamCMD."
fn_script_log_fail "Missing dependencies required to run SteamCMD."
core_exit.sh
else
fn_print_error_nl "Missing dependencies required to run SteamCMD."
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/check_executable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if [ ! -f "${executabledir}/${execname}" ]; then
fn_print_fail_nl "executable was not found"
echo -e "* ${executabledir}/${execname}"
if [ -d "${lgsmlogdir}" ]; then
fn_script_log_fatal "Executable was not found: ${executabledir}/${execname}"
fn_script_log_fail "Executable was not found: ${executabledir}/${execname}"
fi
unset exitbypass
core_exit.sh
Expand Down
6 changes: 3 additions & 3 deletions lgsm/modules/check_permissions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn_check_ownership() {
fi
if [ "${selfownissue}" == "1" ] || [ "${funcownissue}" == "1" ] || [ "${filesownissue}" == "1" ]; then
fn_print_fail_nl "Ownership issues found"
fn_script_log_fatal "Ownership issues found"
fn_script_log_fail "Ownership issues found"
fn_print_information_nl "The current user ($(whoami)) does not have ownership of the following files:"
fn_script_log_info "The current user ($(whoami)) does not have ownership of the following files:"
{
Expand Down Expand Up @@ -56,7 +56,7 @@ fn_check_permissions() {
if [ -d "${modulesdir}" ]; then
if [ "$(find "${modulesdir}" -type f -not -executable | wc -l)" -ne "0" ]; then
fn_print_fail_nl "Permissions issues found"
fn_script_log_fatal "Permissions issues found"
fn_script_log_fail "Permissions issues found"
fn_print_information_nl "The following files are not executable:"
fn_script_log_info "The following files are not executable:"
{
Expand All @@ -80,7 +80,7 @@ fn_check_permissions() {
grouprootdirperm="${rootdirperm:1:1}"
if [ "${userrootdirperm}" != "7" ] && [ "${grouprootdirperm}" != "7" ]; then
fn_print_fail_nl "Permissions issues found"
fn_script_log_fatal "Permissions issues found"
fn_script_log_fail "Permissions issues found"
fn_print_information_nl "The following directory does not have the correct permissions:"
fn_script_log_info "The following directory does not have the correct permissions:"
fn_script_log_info "${rootdir}"
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/check_root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if [ "$(whoami)" == "root" ]; then
if [ "${commandname}" != "INSTALL" ]; then
fn_print_fail_nl "Do NOT run this script as root!"
if [ -d "${lgsmlogdir}" ]; then
fn_script_log_fatal "${selfname} attempted to run as root."
fn_script_log_fail "${selfname} attempted to run as root."
else
# Forces exit code is log does not yet exist.
exitcode=1
Expand Down
4 changes: 2 additions & 2 deletions lgsm/modules/check_system_dir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
if [ ! -d "${serverfiles}" ]; then
fn_print_fail_nl "Cannot access ${serverfiles}: No such directory"
if [ -d "${lgsmlogdir}" ]; then
fn_script_log_fatal "Cannot access ${serverfiles}: No such directory."
fn_script_log_fail "Cannot access ${serverfiles}: No such directory."
fi
core_exit.sh
fi

if [ ! -d "${systemdir}" ]; then
fn_print_fail_nl "Cannot access ${systemdir}: No such directory"
if [ -d "${lgsmlogdir}" ]; then
fn_script_log_fatal "Cannot access ${systemdir}: No such directory."
fn_script_log_fail "Cannot access ${systemdir}: No such directory."
fi
core_exit.sh
fi
4 changes: 2 additions & 2 deletions lgsm/modules/check_tmuxception.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_check_is_in_tmux() {
if [ "${TMUX}" ]; then
fn_print_fail_nl "tmuxception error: Sorry Cobb you cannot start a tmux session inside of a tmux session."
fn_script_log_fatal "Tmuxception error: Attempted to start a tmux session inside of a tmux session."
fn_script_log_fail "Tmuxception error: Attempted to start a tmux session inside of a tmux session."
fn_print_information_nl "LinuxGSM creates a tmux session when starting the server."
echo -e "It is not possible to run a tmux session inside another tmux session"
echo -e "https://docs.linuxgsm.com/requirements/tmux#tmuxception"
Expand All @@ -21,7 +21,7 @@ fn_check_is_in_tmux() {
fn_check_is_in_screen() {
if [ "${STY}" ]; then
fn_print_fail_nl "tmuxception error: Sorry Cobb you cannot start a tmux session inside of a screen session."
fn_script_log_fatal "Tmuxception error: Attempted to start a tmux session inside of a screen session."
fn_script_log_fail "Tmuxception error: Attempted to start a tmux session inside of a screen session."
fn_print_information_nl "LinuxGSM creates a tmux session when starting the server."
echo -e "It is not possible to run a tmux session inside screen session"
echo -e "https://docs.linuxgsm.com/requirements/tmux#tmuxception"
Expand Down
10 changes: 5 additions & 5 deletions lgsm/modules/command_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,18 @@ fn_backup_compression() {
# Check that excludedir is a valid path.
if [ ! -d "${excludedir}" ]; then
fn_print_fail_nl "Problem identifying the previous backup directory for exclusion."
fn_script_log_fatal "Problem identifying the previous backup directory for exclusion"
fn_script_log_fail "Problem identifying the previous backup directory for exclusion"
core_exit.sh
fi

tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "${excludedir}" --exclude "${lockdir}" ./.
local exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol
fn_script_log_fatal "Backup in progress: FAIL"
fn_script_log_fail "Backup in progress: FAIL"
echo -e "${extractcmd}" | tee -a "${lgsmlog}"
fn_print_fail_nl "Starting backup"
fn_script_log_fatal "Starting backup"
fn_script_log_fail "Starting backup"
else
fn_print_ok_eol
fn_print_ok_nl "Completed: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')"
Expand Down Expand Up @@ -217,15 +217,15 @@ fn_backup_relpath() {
declare -a rdirtoks=($(readlink -f "${rootdir}" | sed "s/\// /g"))
if [ ${#rdirtoks[@]} -eq 0 ]; then
fn_print_fail_nl "Problem assessing rootdir during relative path assessment"
fn_script_log_fatal "Problem assessing rootdir during relative path assessment: ${rootdir}"
fn_script_log_fail "Problem assessing rootdir during relative path assessment: ${rootdir}"
core_exit.sh
fi

# Populate an array of tokens initialized from the backupdir components.
declare -a bdirtoks=($(readlink -f "${backupdir}" | sed "s/\// /g"))
if [ ${#bdirtoks[@]} -eq 0 ]; then
fn_print_fail_nl "Problem assessing backupdir during relative path assessment"
fn_script_log_fatal "Problem assessing backupdir during relative path assessment: ${rootdir}"
fn_script_log_fail "Problem assessing backupdir during relative path assessment: ${rootdir}"
core_exit.sh
fi

Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/command_dev_detect_glibc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn_messages_separator

if [ ! "$(command -v objdump 2> /dev/null)" ]; then
fn_print_failure_nl "objdump is missing"
fn_script_log_fatal "objdump is missing"
fn_script_log_fail "objdump is missing"
core_exit.sh
fi

Expand Down
28 changes: 14 additions & 14 deletions lgsm/modules/command_fastdl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ luafastdlfullpath="${luasvautorundir}/${luafastdlfile}"
# Check if bzip2 is installed.
if [ ! "$(command -v bzip2 2> /dev/null)" ]; then
fn_print_fail "bzip2 is not installed"
fn_script_log_fatal "bzip2 is not installed"
fn_script_log_fail "bzip2 is not installed"
core_exit.sh
fi

Expand Down Expand Up @@ -72,7 +72,7 @@ fn_clear_old_fastdl() {
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fatal "Clearing existing FastDL directory ${fastdldir}"
fn_script_log_fail "Clearing existing FastDL directory ${fastdldir}"
core_exit.sh
else
fn_print_ok_eol_nl
Expand All @@ -89,7 +89,7 @@ fn_fastdl_dirs() {
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fatal "Creating web directory ${webdir}"
fn_script_log_fail "Creating web directory ${webdir}"
core_exit.sh
else
fn_print_ok_eol_nl
Expand All @@ -102,7 +102,7 @@ fn_fastdl_dirs() {
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fatal "Creating fastdl directory ${fastdldir}"
fn_script_log_fail "Creating fastdl directory ${fastdldir}"
core_exit.sh
else
fn_print_ok_eol_nl
Expand Down Expand Up @@ -218,13 +218,13 @@ fn_fastdl_preview() {
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fatal "Calculating total file size."
fn_script_log_fail "Calculating total file size."
core_exit.sh
fi
done < "${tmpdir}/fastdl_files_to_compress.txt"
else
fn_print_fail_eol_nl "generating file list"
fn_script_log_fatal "Generating file list."
fn_script_log_fail "Generating file list."
core_exit.sh
fi
echo -e "about to compress ${totalfiles} files, total size $(fn_human_readable_file_size ${filesizetotal} 0)"
Expand All @@ -251,7 +251,7 @@ fn_fastdl_gmod() {
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fatal "Copying ${fastdlfile} > ${fastdldir}"
fn_script_log_fail "Copying ${fastdlfile} > ${fastdldir}"
core_exit.sh
else
fn_script_log_pass "Copying ${fastdlfile} > ${fastdldir}"
Expand All @@ -268,7 +268,7 @@ fn_fastdl_gmod() {
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fatal "Updating addons file structure"
fn_script_log_fail "Updating addons file structure"
core_exit.sh
else
fn_print_ok_eol_nl
Expand All @@ -281,7 +281,7 @@ fn_fastdl_gmod() {
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fatal "Clearing addons dir from fastdl dir"
fn_script_log_fail "Clearing addons dir from fastdl dir"
core_exit.sh
else
fn_print_ok_eol_nl
Expand All @@ -296,7 +296,7 @@ fn_fastdl_gmod() {
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fatal "Correcting DarkRP files"
fn_script_log_fail "Correcting DarkRP files"
core_exit.sh
else
fn_print_ok_eol_nl
Expand Down Expand Up @@ -347,7 +347,7 @@ fn_fastdl_source() {
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fatal "Copying ${fastdlfile} > ${fastdldir}/${copytodir}"
fn_script_log_fail "Copying ${fastdlfile} > ${fastdldir}/${copytodir}"
core_exit.sh
else
fn_script_log_pass "Copying ${fastdlfile} > ${fastdldir}/${copytodir}"
Expand Down Expand Up @@ -383,7 +383,7 @@ fn_fastdl_gmod_dl_enforcer() {
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fatal "Removing existing download enforcer ${luafastdlfullpath}"
fn_script_log_fail "Removing existing download enforcer ${luafastdlfullpath}"
core_exit.sh
else
fn_print_ok_eol_nl
Expand All @@ -401,7 +401,7 @@ fn_fastdl_gmod_dl_enforcer() {
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fatal "Creating new download enforcer ${luafastdlfullpath}"
fn_script_log_fail "Creating new download enforcer ${luafastdlfullpath}"
core_exit.sh
else
fn_print_ok_eol_nl
Expand All @@ -418,7 +418,7 @@ fn_fastdl_bzip2() {
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol_nl
fn_script_log_fatal "Compressing ${filetocompress}"
fn_script_log_fail "Compressing ${filetocompress}"
core_exit.sh
else
fn_script_log_pass "Compressing ${filetocompress}"
Expand Down
6 changes: 3 additions & 3 deletions lgsm/modules/command_mods_remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ while [ "${modfileline}" -le "${modsfilelistsize}" ]; do
rm -rf "${modinstalldir:?}/${currentfileremove:?}"
((exitcode = $?))
if [ "${exitcode}" != 0 ]; then
fn_script_log_fatal "Removing ${modinstalldir}/${currentfileremove}"
fn_script_log_fail "Removing ${modinstalldir}/${currentfileremove}"
break
else
fn_script_log_pass "Removing ${modinstalldir}/${currentfileremove}"
Expand Down Expand Up @@ -103,7 +103,7 @@ fn_sleep_time
rm -rf "${modsdir:?}/${modcommand}-files.txt"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_script_log_fatal "Removing ${modsdir}/${modcommand}-files.txt"
fn_script_log_fail "Removing ${modsdir}/${modcommand}-files.txt"
fn_print_fail_eol_nl
core_exit.sh
else
Expand All @@ -118,7 +118,7 @@ fn_sleep_time
sed -i "/^${modcommand}$/d" "${modsinstalledlistfullpath}"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_script_log_fatal "Removing ${modcommand} from ${modsinstalledlist}"
fn_script_log_fail "Removing ${modcommand} from ${modsinstalledlist}"
fn_print_fail_eol_nl
core_exit.sh
else
Expand Down
Loading

0 comments on commit eb5c833

Please sign in to comment.