Skip to content

Commit

Permalink
refactor: improve logging and remove unnecessary code
Browse files Browse the repository at this point in the history
- Changed `fn_print_failure_eol` to `fn_print_fail_eol` for consistency.
- Removed redundant log messages and sleep time.
- Simplified the logic for changing hostname and rcon/admin password.
- Removed warning message when config file is not found.

Co-authored-by: AI Assistant <[email protected]>
  • Loading branch information
dgibbs64 and AI Assistant committed Sep 27, 2023
1 parent e02d212 commit 64545ac
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lgsm/modules/install_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn_default_config_local() {
echo -e "copying config file [ ${servercfgdefault} ]"
cp -nv "${servercfgdir}/${servercfgdefault}" "${servercfgfullpath}"
if [ "${exitcode}" != 0 ]; then
fn_print_failure_eol
fn_print_fail_eol
fn_script_log_fatal "copying config file [ ${servercfgdefault} ]"
else
fn_print_ok_eol
Expand All @@ -89,8 +89,8 @@ fn_set_config_vars() {
random=$(tr -dc 'A-Za-z0-9_' < /dev/urandom 2> /dev/null | head -c 8 | xargs)
servername="LinuxGSM"
rconpass="admin${random}"
echo -e "changing hostname."
fn_script_log_info "changing hostname."
echo -e "changing hostname"
fn_script_log_info "changing hostname"
fn_sleep_time
# prevents var from being overwritten with the servername.
if grep -q "SERVERNAME=SERVERNAME" "${lgsmdir}/config-default/config-game/${config}" 2> /dev/null; then
Expand All @@ -100,18 +100,14 @@ fn_set_config_vars() {
else
sed -i "s/SERVERNAME/${servername}/g" "${servercfgfullpath}"
fi
echo -e "changing rcon/admin password."
fn_script_log_info "changing rcon/admin password."
echo -e "changing rcon/admin password"
fn_script_log_info "changing rcon/admin password"
if [ "${shortname}" == "squad" ]; then
sed -i "s/ADMINPASSWORD/${rconpass}/g" "${servercfgdir}/Rcon.cfg"
else
sed -i "s/ADMINPASSWORD/${rconpass}/g" "${servercfgfullpath}"
fi
fn_sleep_time
else
fn_script_log_warn "Config file not found, cannot alter it."
echo -e "Config file not found, cannot alter it."
fn_sleep_time
fi
}

Expand Down

0 comments on commit 64545ac

Please sign in to comment.