Browse Source
refactor: optimize sleep time functions
- Refactored the code to optimize the sleep time functions.
- Updated the `fn_sleep_time` function calls to `fn_sleep_time_1` in multiple files.
- Removed unnecessary sleep time calls in some files.
pull/4339/head
Daniel Gibbs
2 years ago
No known key found for this signature in database
GPG Key ID: 2076B128385E8C55
13 changed files with
16 additions and
16 deletions
lgsm/modules/check_deps.sh
lgsm/modules/check_glibc.sh
lgsm/modules/check_permissions.sh
lgsm/modules/check_system_requirements.sh
lgsm/modules/check_version.sh
lgsm/modules/command_dev_details.sh
lgsm/modules/command_fastdl.sh
lgsm/modules/command_wipe.sh
lgsm/modules/install_gslt.sh
lgsm/modules/install_logs.sh
lgsm/modules/install_squad_license.sh
lgsm/modules/install_stats.sh
lgsm/modules/install_ts3db.sh
@ -306,14 +306,14 @@ fn_deps_detector() {
missingdep = 0
if [ " ${ commandname } " = = "INSTALL" ] ; then
echo -e " ${ green } ${ deptocheck } ${ default } "
fn_sleep_time
fn_sleep_time_1
fi
elif [ " ${ depstatus } " != "0" ] ; then
# If dependency is not found.
missingdep = 1
if [ " ${ commandname } " = = "INSTALL" ] ; then
echo -e " ${ red } ${ deptocheck } ${ default } "
fn_sleep_time
fn_sleep_time_1
fi
# If SteamCMD requirements are not met install will fail.
if [ -n " ${ appid } " ] ; then
@ -16,6 +16,7 @@ elif [ -z "${glibc}" ]; then
fn_print_dots "glibc"
fn_print_error_nl "glibc requirement unknown"
fn_script_log_error "glibc requirement unknown"
fn_sleep_time_5
elif [ " $( printf '%s\n' ${ glibc } '\n' " ${ glibcversion } " | sort -V | head -n 1) " != " ${ glibc } " ] ; then
fn_print_dots "glibc"
fn_print_error_nl "glibc requirements not met"
@ -26,4 +27,5 @@ elif [ "$(printf '%s\n'${glibc}'\n' "${glibcversion}" | sort -V | head -n 1)" !=
echo -en "\n"
fn_print_information_nl "distro upgrade is required"
fn_script_log_info "distro upgrade is required"
fn_sleep_time_5
fi
@ -171,7 +171,7 @@ fn_sys_perm_fix_manually_msg() {
fn_script_log_info "To fix this issue, run the following command as root:"
echo -e " chmod a+rx /sys /sys/class /sys/class/net"
fn_script_log "chmod a+rx /sys /sys/class /sys/class/net"
fn_sleep_time
fn_sleep_time_5
if [ " ${ monitorflag } " = = 1 ] ; then
alert = "permissions"
alert.sh
@ -50,6 +50,6 @@ if [ "${ramrequirementmb}" ]; then
# Warn the user.
fn_print_warn_nl " Check RAM: ${ ramrequirementgb } G required, ${ physmemtotal } available "
echo " * ${ gamename } server may fail to run or experience poor performance. "
fn_sleep_time
fn_sleep_time_5
fi
fi
@ -16,8 +16,8 @@ if [ -n "${modulesversion}" ] && [ -n "${version}" ] && [ "${version}" != "${mod
echo -e " * ${ selfname } : ${ version } "
echo -e " * modules: ${ modulesversion } "
echo -e ""
fn_sleep_time
fn_script_log_error " LinuxGSM Version mismatch: ${ selfname } : ${ version } : modules: ${ modulesversion } "
fn_sleep_time_1
command_update_linuxgsm.sh
fn_firstcommand_reset
fi
@ -19,8 +19,8 @@ carriagereturn=$(file -b "${servercfgfullpath}" | grep -q CRLF && echo "${red}CR
echo -e ""
echo -e " ${ bold } ${ lightgreen } Server Details ${ default } "
fn_messages_separator
echo -e ""
echo -e ""
echo -e " Game: ${ gamename } "
echo -e " Config type: ${ configtype } "
echo -e " Config file: ${ servercfgfullpath } "
@ -209,7 +209,7 @@ fn_fastdl_preview() {
fi
if [ -f " ${ tmpdir } /fastdl_files_to_compress.txt " ] ; then
echo -e "calculating total file size..."
fn_sleep_time
fn_sleep_time_1
totalfiles = $( wc -l < " ${ tmpdir } /fastdl_files_to_compress.txt " )
# Calculates total file size.
while read -r dufile; do
@ -276,7 +276,7 @@ fn_fastdl_gmod() {
fi
# Clear addons directory in fastdl.
echo -en "clearing addons dir from fastdl dir..."
fn_sleep_time
fn_sleep_time_1
rm -rf " ${ fastdldir : ? } /addons "
exitcode = $?
if [ " ${ exitcode } " != 0 ] ; then
@ -79,7 +79,7 @@ fn_map_wipe_warning() {
fn_script_log_warn "Map wipe will reset the map data and keep blueprint data"
totalseconds = 3
for seconds in { 3..1} ; do
fn_print_warn " M ap wipe will reset the map data and keep blueprint data: ${ totalseconds } "
fn_print_warn " m ap wipe will reset the map data and keep blueprint data: ${ totalseconds } "
totalseconds = $(( totalseconds - 1 ))
fn_sleep_time_1
if [ " ${ seconds } " = = "0" ] ; then
@ -94,7 +94,7 @@ fn_full_wipe_warning() {
fn_script_log_warn "Server wipe will reset the map data and remove blueprint data"
totalseconds = 3
for seconds in { 3..1} ; do
fn_print_warn " S erver wipe will reset the map data and remove blueprint data: ${ totalseconds } "
fn_print_warn " s erver wipe will reset the map data and remove blueprint data: ${ totalseconds } "
totalseconds = $(( totalseconds - 1 ))
fn_sleep_time_1
if [ " ${ seconds } " = = "0" ] ; then
@ -36,7 +36,7 @@ if [ -z "${autoinstall}" ]; then
fi
fi
fi
fn_sleep_time
if [ " ${ shortname } " = = "tu" ] ; then
echo -e " The GSLT can be changed by editing ${ servercfgdir } / ${ servercfg } . "
fn_script_log_info " The GSLT can be changed by editing ${ servercfgdir } / ${ servercfg } . "
@ -44,4 +44,5 @@ else
echo -e " The GSLT can be changed by editing ${ configdirserver } / ${ selfname } .cfg. "
fn_script_log_info " The GSLT can be changed by editing ${ configdirserver } / ${ selfname } .cfg. "
fi
fn_sleep_time_1
echo -e ""
@ -11,9 +11,7 @@ if [ "${checklogs}" != "1" ]; then
echo -e ""
echo -e " ${ bold } ${ lightyellow } Creating Log Directories ${ default } "
fn_messages_separator
fn_sleep_time
fi
fn_sleep_time
# Create LinuxGSM logs.
echo -en " installing log dir: ${ logdir } ... "
mkdir -p " ${ logdir } "
@ -18,7 +18,7 @@ echo -e "https://squad.fandom.com/wiki/Server_licensing"
fn_script_log_info "Get more info and a server license here:"
fn_script_log_info "https://squad.fandom.com/wiki/Server_licensing"
echo -e ""
fn_sleep_time
fn_sleep_time_1
echo -e " The Squad server license can be changed by editing ${ servercfgdir } /License.cfg. "
fn_script_log_info " The Squad server license can be changed by editing ${ selfname } . "
echo -e ""
@ -10,7 +10,6 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
echo -e ""
echo -e " ${ bold } ${ lightyellow } LinuxGSM Stats ${ default } "
fn_messages_separator
fn_sleep_time
echo -e "Assist LinuxGSM development by sending anonymous stats to developers."
echo -e " Collected data is publicly available: ${ italic } https://linuxgsm.com/data/usage ${ default } "
echo -e " More info: ${ italic } https://docs.linuxgsm.com/configuration/linuxgsm-stats ${ default } "
@ -45,7 +45,7 @@ fn_install_ts3db_mariadb() {
sed -i "s/dbpluginparameter=/dbpluginparameter=ts3db_mariadb.ini/g" " ${ servercfgfullpath } "
sed -i "s/dbsqlcreatepath=create_sqlite\//dbsqlcreatepath=create_mariadb\//g" " ${ servercfgfullpath } "
echo -e "updating ts3db_mariadb.ini."
fn_sleep_time
fn_sleep_time_1
}
echo -e ""