Skip to content

Commit

Permalink
refactor: improve code readability and fix typos
Browse files Browse the repository at this point in the history
- Refactored the code to improve readability and organization.
- Fixed typos in the comments and echo statements.
- Changed some echo statements to use variables for better consistency.
- Updated URLs in the echo statements to be clickable links.

Co-authored-by: [co-author name]
  • Loading branch information
dgibbs64 committed Sep 28, 2023
1 parent e040597 commit 9f14489
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 42 deletions.
10 changes: 5 additions & 5 deletions lgsm/modules/install_complete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ echo -e ""
echo -e "${bold}=================================${default}"

if [ "${exitcode}" == "1" ]; then
echo -e "Install Failed!"
echo -e "${red}Install Failed!${default}"
fn_script_log_fatal "Install Failed!"
elif [ "${exitcode}" == "2" ]; then
echo -e "Install Completed with Errors!"
echo -e "${red}Install Completed with Errors!${default}}"
fn_script_log_error "Install Completed with Errors!"
elif [ "${exitcode}" == "3" ]; then
echo -e "Install Completed with Warnings!"
echo -e "${lightyellow}Install Completed with Warnings!${default}}"
fn_script_log_warn "Install Completed with Warnings!"
elif [ -z "${exitcode}" ] || [ "${exitcode}" == "0" ]; then
echo -e "Install Complete!"
echo -e "${green}Install Complete!${default}}"
fn_script_log_pass "Install Complete!"
fi

echo -e ""
echo -e "To start the ${gamename} server type:"
echo -e "./${selfname} start"
echo -e "${italic}./${selfname} start${default}"
echo -e ""
core_exit.sh
85 changes: 48 additions & 37 deletions lgsm/modules/install_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,24 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"

# Checks if server cfg dir exists, creates it if it doesn't.
fn_check_cfgdir() {
if [ ! -d "${servercfgdir}" ]; then

if [ "${shortname}" == "dst" ]; then
echo -en "creating ${clustercfgfullpath} config directory"
mkdir -p "${clustercfgfullpath}"
elif [ "${shortname}" == "arma3" ]; then
echo -en "creating ${networkcfgfullpath} config directory"
mkdir -p "${networkcfgfullpath}"
else
echo -en "creating ${servercfgdir} config directory"
mkdir -pv "${servercfgdir}"
if [ "$?" -ne 0 ]; then # shellcheck disable=SC2181
fn_print_fail_eol
fn_script_log_fatal "creating ${servercfgdir} config directory"
core_exit.sh
else
fn_print_ok_eol
fn_script_log_pass "creating ${servercfgdir} config directory"
fi
mkdir -p "${servercfgdir}"
fi
if [ "$?" -ne 0 ]; then # shellcheck disable=SC2181
fn_print_fail_eol
fn_script_log_fatal "creating ${servercfgdir} config directory"
core_exit.sh
else
fn_print_ok_eol
fn_script_log_pass "creating ${servercfgdir} config directory"
fi
}

Expand All @@ -36,31 +43,35 @@ fn_default_config_remote() {
fn_sleep_time
githuburl="https://raw.githubusercontent.com/GameServerManagers/Game-Server-Configs/main"
for config in "${array_configs[@]}"; do
fn_fetch_file "${githuburl}/${shortname}/${config}" "${remote_fileurl_backup}" "GitHub" "Bitbucket" "${lgsmdir}/config-default/config-game" "${config}" "nochmodx" "norun" "forcedl" "nohash"
done
fn_check_cfgdir
for config in "${array_configs[@]}"; do
# every config is copied
echo -en "copying config file [ ${italic}${servercfgfullpath}${default} ]"
if [ "${config}" == "${servercfgdefault}" ]; then
mkdir -p "${servercfgdir}"
cp -nv "${lgsmdir}/config-default/config-game/${config}" "${servercfgfullpath}"
elif [ "${shortname}" == "arma3" ] && [ "${config}" == "${networkcfgdefault}" ]; then
mkdir -p "${servercfgdir}"
cp -nv "${lgsmdir}/config-default/config-game/${config}" "${networkcfgfullpath}"
elif [ "${shortname}" == "dst" ] && [ "${config}" == "${clustercfgdefault}" ]; then
mkdir -p "${clustercfgfullpath}"
cp -nv "${lgsmdir}/config-default/config-game/${clustercfgdefault}" "${clustercfgfullpath}"
else
mkdir -p "${servercfgdir}"
cp -nv "${lgsmdir}/config-default/config-game/${config}" "${servercfgdir}/${config}"
fi
if [ "$?" -ne 0 ]; then # shellcheck disable=SC2181
fn_print_failure_eol_nl
fn_script_log_fatal "copying config file ${servercfgfullpath}"
else
fn_print_ok_eol_nl
fn_script_log_pass "copying config file ${servercfgfullpath}"
if [ ! -f "${lgsmdir}/config-default/config-game/${config}" ]; then
fn_fetch_file "${githuburl}/${shortname}/${config}" "${remote_fileurl_backup}" "GitHub" "Bitbucket" "${lgsmdir}/config-default/config-game" "${config}" "nochmodx" "norun" "forcedl" "nohash"

fn_check_cfgdir

changes=""
if [ "${config}" == "${servercfgdefault}" ]; then
echo -en "copying config file [ ${italic}${servercfgfullpath}${default} ]"
changes+=$(cp -n "${lgsmdir}/config-default/config-game/${config}" "${servercfgfullpath}")
elif [ "${shortname}" == "arma3" ] && [ "${config}" == "${networkcfgdefault}" ]; then
echo -en "copying config file [ ${italic}${networkcfgfullpath}${default} ]"
changes+=$(cp -n "${lgsmdir}/config-default/config-game/${config}" "${networkcfgfullpath}")
elif [ "${shortname}" == "dst" ] && [ "${config}" == "${clustercfgdefault}" ]; then
echo -en "copying config file [ ${italic}${clustercfgdefault}${default} ]"
changes+=$(cp -n "${lgsmdir}/config-default/config-game/${clustercfgdefault}" "${clustercfgfullpath}")
else
echo -en "copying config file [ ${italic}${servercfgdir}/${config}${default} ]"
changes+=$(cp -n "${lgsmdir}/config-default/config-game/${config}" "${servercfgdir}/${config}")
fi
if [ "$?" -ne 0 ]; then # shellcheck disable=SC2181
fn_print_failure_eol_nl
fn_script_log_fatal "copying config file ${servercfgfullpath}"
elif [ "${changes}" != "" ]; then
fn_print_ok_eol_nl
fn_script_log_pass "copying config file ${servercfgfullpath}"
else
fn_print_skip_eol_nl
fi

fi
done
}
Expand All @@ -69,7 +80,7 @@ fn_default_config_remote() {
fn_default_config_local() {
fn_check_cfgdir
echo -en "copying config file [ ${italic}${servercfgdefault}${default} ]"
cp -nv "${servercfgdir}/${servercfgdefault}" "${servercfgfullpath}"
cp -n "${servercfgdir}/${servercfgdefault}" "${servercfgfullpath}"
if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol
fn_script_log_fatal "copying config file [ ${servercfgdefault} ]"
Expand Down Expand Up @@ -176,7 +187,7 @@ fn_list_config_locations() {
fi
fi
echo -e "LinuxGSM config: ${italic}${lgsmdir}/config-lgsm/${gameservername}${default}"
echo -e "Config documentation: ${italic}https://docs.linuxgsm.com/configuration{default}"
echo -e "Config documentation: ${italic}https://docs.linuxgsm.com/configuration${default}"
}

if [ "${shortname}" == "sdtd" ]; then
Expand Down

0 comments on commit 9f14489

Please sign in to comment.