From 64545ac6697c89e9f5531a9281ff1e554011429f Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 27 Sep 2023 14:37:24 +0100 Subject: [PATCH] refactor: improve logging and remove unnecessary code - 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 --- lgsm/modules/install_config.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lgsm/modules/install_config.sh b/lgsm/modules/install_config.sh index 8486871a10..d5de0531ab 100644 --- a/lgsm/modules/install_config.sh +++ b/lgsm/modules/install_config.sh @@ -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 @@ -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 @@ -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 }