Skip to content

Commit

Permalink
refactor: improve conditional statements in install_config.sh
Browse files Browse the repository at this point in the history
The code changes refactor the conditional statements in the `install_config.sh` file. Instead of checking if `${shortname}` is equal to "dst" or "arma3", it now checks if `${clustercfgdir}` or `${networkcfgdir}` are not empty, respectively. This improves readability and maintainability of the code.

a
  • Loading branch information
dgibbs64 committed Sep 30, 2023
1 parent 81e5fe6 commit e499c1c
Showing 1 changed file with 33 additions and 12 deletions.
45 changes: 33 additions & 12 deletions lgsm/modules/install_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,47 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
# Checks if server cfg dir exists, creates it if it doesn't.
fn_check_cfgdir() {
changes=""
if [ "${shortname}" == "dst" ]; then
if [ -n "${clustercfgdir}" ]; then
echo -en "creating config directory [ ${italic}${clustercfgdir}${default} ]"
changes+=$(mkdir -pv "${clustercfgdir}")
elif [ "${shortname}" == "arma3" ]; then
if [ "$?" -ne 0 ]; then # shellcheck disable=SC2181
fn_print_fail_eol_nl
fn_script_log_fatal "creating ${servercfgdir} config directory"
core_exit.sh
elif [ "${changes}" != "" ]; then
fn_print_ok_eol_nl
fn_script_log_pass "creating ${servercfgdir} config directory"
else
fn_print_skip_eol_nl
fi
elif [ -n "${networkcfgdir}" ]; then
echo -en "creating config directory [ ${italic}${networkcfgdir}${default} ]"
changes+=$(mkdir -pv "${networkcfgdir}")
if [ "$?" -ne 0 ]; then # shellcheck disable=SC2181
fn_print_fail_eol_nl
fn_script_log_fatal "creating ${servercfgdir} config directory"
core_exit.sh
elif [ "${changes}" != "" ]; then
fn_print_ok_eol_nl
fn_script_log_pass "creating ${servercfgdir} config directory"
else
fn_print_skip_eol_nl
fi
else
echo -en "creating config directory [ ${italic}${servercfgdir}${default} ]"
changes+=$(mkdir -pv "${servercfgdir}")
if [ "$?" -ne 0 ]; then # shellcheck disable=SC2181
fn_print_fail_eol_nl
fn_script_log_fatal "creating ${servercfgdir} config directory"
core_exit.sh
elif [ "${changes}" != "" ]; then
fn_print_ok_eol_nl
fn_script_log_pass "creating ${servercfgdir} config directory"
else
fn_print_skip_eol_nl
fi
fi
if [ "$?" -ne 0 ]; then # shellcheck disable=SC2181
fn_print_fail_eol_nl
fn_script_log_fatal "creating ${servercfgdir} config directory"
core_exit.sh
elif [ "${changes}" != "" ]; then
fn_print_ok_eol_nl
fn_script_log_pass "creating ${servercfgdir} config directory"
else
fn_print_skip_eol_nl
fi

unset changes
}

Expand Down

0 comments on commit e499c1c

Please sign in to comment.