Skip to content

Commit

Permalink
refactor: optimize sleep time functions
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
dgibbs64 committed Oct 10, 2023
1 parent 6d607a8 commit 174a6d1
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lgsm/modules/check_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lgsm/modules/check_glibc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
2 changes: 1 addition & 1 deletion lgsm/modules/check_permissions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/check_system_requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lgsm/modules/check_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lgsm/modules/command_dev_details.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
4 changes: 2 additions & 2 deletions lgsm/modules/command_fastdl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lgsm/modules/command_wipe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "Map wipe will reset the map data and keep blueprint data: ${totalseconds}"
fn_print_warn "map wipe will reset the map data and keep blueprint data: ${totalseconds}"
totalseconds=$((totalseconds - 1))
fn_sleep_time_1
if [ "${seconds}" == "0" ]; then
Expand All @@ -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 "Server wipe will reset the map data and remove blueprint data: ${totalseconds}"
fn_print_warn "server wipe will reset the map data and remove blueprint data: ${totalseconds}"
totalseconds=$((totalseconds - 1))
fn_sleep_time_1
if [ "${seconds}" == "0" ]; then
Expand Down
3 changes: 2 additions & 1 deletion lgsm/modules/install_gslt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ 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}."
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 ""
2 changes: 0 additions & 2 deletions lgsm/modules/install_logs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/install_squad_license.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
1 change: 0 additions & 1 deletion lgsm/modules/install_stats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/install_ts3db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down

0 comments on commit 174a6d1

Please sign in to comment.