Browse Source

refactor: improve conditional statements in install_config.sh

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
feature/dst-changes
Daniel Gibbs 2 years ago
parent
commit
e499c1c450
No known key found for this signature in database GPG Key ID: 2076B128385E8C55
  1. 45
      lgsm/modules/install_config.sh

45
lgsm/modules/install_config.sh

@ -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
}

Loading…
Cancel
Save