From ee20e18be320a9fd5d1b9c5611404809d108bf00 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 11 Dec 2024 22:29:17 +0000 Subject: [PATCH] feat: User interface refactor (#4716) * refactor: improve log directory creation - Changed the variable `checklogs` from being set to `1` to being set to `true`. - Improved the logic for creating log directories and files. - Added more informative console output for each step of the process. - Refactored code to use conditional statements instead of nested if statements. - Removed unnecessary print statements. This commit improves the way log directories are created and handles cases where logs already exist. It also provides clearer console output during the process. * refactor: improve console output formatting - Added color support for console output using tput commands - Updated print functions to display formatted messages with colors and bold text * refactor: improve console log creation The code in `install_logs.sh` has been refactored to improve the creation of the console log. The commit removes unnecessary whitespace and updates the echo statement to provide a more concise output. * a * refactor: improve log directory creation messages - Changed the format of log directory creation messages to include parentheses around the directory path. - Updated the messages in `install_logs.sh` file to reflect this change. * refactor: improve log directory symlink creation The code has been refactored to improve the creation of symlinks for game log directories. The commit removes unnecessary echo statements and updates the output format to provide clearer information about the created symlinks. * feat: create server directory - Updated the script to create a server directory - Removed unnecessary check for existing server directory * refactor: improve console output for fetching files The commit refactors the code in `install_server_dir.sh` and `linuxgsm.sh` to improve the console output when fetching files. The message now includes more descriptive information about the file being fetched, such as the source URL and local filename. Additionally, the success message has been updated to include brackets around "OK" for better readability. * refactor: improve formatting of success message The success message in the core_messages.sh file has been updated to include square brackets around "OK" for better visibility. * ui * refactor: improve console output for checking and fetching files - Updated the console output in `command_update_linuxgsm.sh` to include formatting and improved readability. - Improved the console output in `core_dl.sh` to include formatting and better indicate the progress of file fetching. * refactor: improve logging message in fn_fetch_file The logging message in the fn_fetch_file function has been improved to provide a more concise and informative output. Instead of mentioning the local filename separately, it is now included within the same line as the file URL name. This change enhances readability and clarity when fetching files. * refactor: improve console output in core_dl.sh and linuxgsm.sh - Refactored code to improve the console output in core_dl.sh and linuxgsm.sh. - Updated echo statements to provide more informative messages. - Removed unnecessary characters from the console output. * refactor: improve code readability and remove unnecessary comments The commit message summarizes the changes made to the code. In this case, the code has been refactored to improve its readability and remove unnecessary comments. * refactor: improve readability and consistency in code - Refactored echo statements to provide more informative messages. - Renamed variables for better clarity. - Removed unnecessary comments and unused code. * refactor: improve logging message in core_dl.sh The logging message in the `fn_fetch_file` function has been updated to provide a more concise and informative description of the file being fetched. * refactor(core_messages): update print functions - Updated the print functions in the core_messages.sh file to improve readability and consistency. - Replaced the use of "tputreset" with "${default}" for better code clarity. - Modified the formatting of the output messages to follow a consistent pattern. - Removed unnecessary escape sequences from the echo statements. * refactor: improve header and server directory installation messages - Updated ASCII logo formatting for better visibility. - Added emphasis to the LinuxGSM name in the header message. - Changed the contributor and sponsor links to be more descriptive. - Modified the server directory installation message to indicate if a game server already exists at the specified location. * refactor: improve log directory creation messages - Changed the log directory creation messages to include square brackets around the directory paths. - Updated the console log and game log directory creation messages to use square brackets as well. - Modified the symlink creation messages for game logs and Steam logs to also include square brackets. This commit improves the readability of the log directory creation process by adding square brackets around the relevant paths. * refactor: improve log directory creation and server directory installation - Change log directory creation message to use bold font for emphasis. - Update symlink creation message to clarify that it is creating a symlink to the game log directory. - Add a check to skip creating a symlink if it already exists for the Steam log directory. - Change server directory installation message to use bold font for emphasis. * refactor: improve log directory symlink creation This commit refactors the code in `install_logs.sh` to improve the creation of symlinks for game log directories. The commit fixes a typo in the echo statement and updates the symlink paths for both game logs and Steam logs. * feat: create serverfiles directory - Updated the message to indicate that a serverfiles directory is being created - Improved clarity and readability of the code * refactor: improve consistency and readability of print functions - Refactored the print functions in the core_messages.sh file to improve consistency and readability. - Updated the output format by adding ellipsis (...) before each status message for better visual separation. - Replaced hard-coded color codes with variables for easier maintenance. Co-authored-by: AI Assistant * refactor: improve readability of code in command_update_linuxgsm.sh - Replaced "checking" with "checking [filename]" for better clarity - Changed echo statements to use fn_print_update_eol_nl instead of fn_print_ok_eol_nl - Updated comments for better understanding of the code flow * refactor: improve logging and error handling in command_update_linuxgsm.sh - Refactored log messages for better clarity and readability. - Improved error handling by checking the return value of curl command. - Updated backup location log message to include brackets. * refactor: simplify code for checking file differences The commit simplifies the code for checking file differences in the `command_update_linuxgsm.sh` script. It replaces the function `fn_print_ok_eol_nl` with `fn_print_skip_eol_nl` to improve readability and maintainability. * refactor: improve print message in command_update_linuxgsm.sh The code change refactors the print message in the command_update_linuxgsm.sh file. Instead of printing "OK", it now prints "SKIP" to indicate that a module is being removed. This improves clarity and consistency in the script's output. * skip * refactor: improve readability and add emphasis to file names in code - Refactored code to improve readability and maintainability. - Added emphasis to file names by using italics. - Updated echo statements to reflect the changes. * feat: improve fetch file output - Updated the fetch file function in core_dl.sh and linuxgsm.sh to provide more informative output. - Replaced the parentheses with square brackets to enclose the local filename. - Added italics formatting to highlight the local filename. * feat: improve log directory creation - Updated log directory creation to include italic formatting for directory names. - Added italic formatting for script log, console log, game log, and steam log directories. - Improved serverfiles directory creation by including italic formatting for the directory name. * refactor: improve readability and consistency in code - Updated the echo statement to include formatting for script name - Added bold formatting to EULA acceptance message - Removed unnecessary line breaks and added italic formatting to EULA URL - Refactored code to remove duplicate calls to install_eula.sh * feat: add new line before Y/N prompt The commit adds a new line before the Y/N prompt in the `fn_prompt_yn` function. This improves readability and user experience. refactor: improve formatting in install_server_files.sh The commit improves the formatting in the `install_server_files.sh` file by adding bold styling to the installation header. It also adds bold styling to the separator line for better visual separation. These changes enhance the overall appearance of the installation process. fix: correct formatting issue in install_server_files.sh The commit fixes a formatting issue in the `install_server_files.sh` file where an extra separator line was not properly formatted with bold styling. The fix ensures consistent and correct formatting throughout the script. chore: update prompt message in install_server_files.sh The commit updates a prompt message in the `install_server_files.sh` file to make it more informative and user-friendly. The updated message asks if the installation was successful, providing clearer instructions for users. refactor: remove redundant separator line in install_server_files.sh The commit removes a redundant separator line from the `install_server_files.sh` file that was causing unnecessary visual clutter. This improves code readability and simplifies the installation process. * changes * refactor: improve logging and error handling in install_config.sh - Refactored the code to use more descriptive function names. - Improved logging by using fn_print_ok_eol and fn_print_failure_eol functions. - Added error handling for copying config files, displaying failure messages if necessary. - Updated comments for better clarity. * 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 * refactor: update server names in default configuration files - Updated the servername value in multiple default configuration files to "LinuxGSM" for consistency. - Refactored the code to reflect the changes made. This commit refactors the default configuration files for various game servers by updating the servername value to "LinuxGSM". This change ensures consistency across different game servers. * refactor: remove unused code and files This commit removes unused code and files from the project. The deleted files include default configuration files and test scripts that are no longer needed. * refactor: improve readability and error handling in install_config.sh - Refactored the code to improve readability by adding bold formatting to console output. - Improved error handling by using the exit status of commands instead of a separate variable. - Replaced repetitive sleep calls with fn_sleep_time function. - Updated log messages for clarity and consistency. - Added conditional checks for successful file copying and printing appropriate status messages. Co-authored-by: AI Assistant * refactor: simplify config file copying and error handling This commit simplifies the code for copying default config files from the Game-Server-Configs repository to the server's config location. It also improves error handling by printing appropriate messages and logging them. * misc changes * reword of dst config install Removed install settings as it complicates setup. The admin how has to manually setup a slave shard using configs. By default LinuxGSM will setup a Master shard. Docs will need to be updated. * refactor: improve config location listing - Renamed the function `fn_list_config_locations` to better reflect its purpose. - Updated the output messages to provide clearer information about the config locations. - Added formatting enhancements for better readability. This commit refactors the code related to listing config locations, making it more user-friendly and informative. * ui changes * refactor: improve code readability and fix typos - 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] * ui changes * ui changes * fix: update warning message for missing SteamCMD The commit updates the warning message in the code to indicate that SteamCMD is not installed instead of being missing. Additionally, it modifies the log message accordingly. * refactor: simplify directory creation in install_config.sh This commit simplifies the code for creating config directories in the install_config.sh file. Instead of using separate variables for each directory path, it now uses a single variable to create the necessary directories. This improves readability and reduces redundancy in the code. * feat: add installation and information for SteamCMD - Added code to install SteamCMD if it is missing or the steamcmd directory is missing. - Modified the check_steamcmd function to print a warning message if SteamCMD is not installed. - Modified the info_game_dst function to retrieve additional information from server and cluster configuration files. - Updated the installation script to display a bold header before installing SteamCMD. * refactor: improve error message in install_config.sh The commit refactors the code in `install_config.sh` to improve the error message when copying a config file. The function `fn_print_failure_eol_nl` is renamed to `fn_print_fail_eol_nl` for clarity and consistency. This change enhances the readability and maintainability of the code. * refactor: improve conditional statements in install_config.sh The code changes refactor the conditional statements in the `install_config.sh` file. Instead of checking if `${shortname}` is equal to "dst" or "arma3", it now checks if `${clustercfgdir}` or `${networkcfgdir}` are not empty, respectively. This improves readability and maintainability of the code. a * refactor: simplify config directory creation and copying The code changes simplify the logic for creating config directories and copying config files. The function `fn_check_cfgdir` now only creates the server config directory if it exists, removing unnecessary checks for other directories. Additionally, the function `fn_default_config_remote` no longer duplicates the call to `fn_check_cfgdir`. * refactor: improve variable naming and remove unnecessary code duplication The commit refactors the code in `install_config.sh` to improve variable naming and remove unnecessary code duplication. Specifically, it renames the variables for better clarity and removes redundant lines of code. refactor: improve installation and configuration process - Refactored the fix_dst.sh script to keep the shard name in server.ini consistent with the LinuxGSM config. - Updated install_config.sh to provide clearer messages during the default config download and copy processes. refactor: update shard name in server.ini The code has been refactored to update the shard name in the server.ini file. This change ensures that the shard name in the LinuxGSM config matches the one in server.ini. * feat: improve console output formatting - Added separator function to improve readability of console output. - Replaced multiple instances of manual separators with the new function. - Updated commit message to follow conventional commit standard. * refactor: remove unnecessary fn_sleep_time calls This commit removes the fn_sleep_time function calls that are no longer needed in multiple modules. The fn_sleep_time function was used to introduce a delay, but it is no longer necessary for the current implementation. * refactor: remove unused functions This commit removes a large number of unused functions from the core_functions.sh module. These functions were not being called or used anywhere in the codebase and were therefore unnecessary. Removing them helps to clean up the code and improve maintainability. * refactor: improve consistency and readability of code - Changed the color of "Missing Server Details" to bold yellow - Changed the color of "Query IP Addresses" to bold yellow - Changed the color of "Game Server Ports" to bold yellow - Changed the color of "SS Output" to bold yellow - Changed the color of "Query Port - Raw Output" to bold yellow - Changed the color of "Gamedig Raw Output" to bold yellow - Changed the color of "gsquery Raw Output" to bold yellow - Changed the color of "TCP Raw Output" to bold yellow - Changed the color of "Game Port - Raw Output" to bold yellow - Changed the color of "Steam Master Server Response" to bold yellow - Updated commit message formatting for better readability * refactor: improve code readability and efficiency in command_dev_query_raw.sh - Simplify conditionals by replacing [ -v var ] with [ -n "${var}" ] - Remove unnecessary checks for the presence of jq and gamedig - Update output headers to be more descriptive and consistent - Use italic formatting for curl command in Steam Master Server Response section * refactor: improve query output formatting The code changes refactor the query output formatting in the command_dev_query_raw.sh file. The changes include: - Adding italics to certain command outputs for better readability - Removing unnecessary echo statements - Updating comments and indentation for clarity * refactor: simplify storage information display The code in `info_messages.sh` has been refactored to improve the readability and conciseness of the storage information display. The labels for total and used space have been shortened to "Total" and "Used" respectively. * refactor: renamed fatal to fail to improve consistency - Updated the log level from "fatal" to "fail" in the alert scripts. * feat: add conditional printing of alert messages This commit adds conditional statements to only print alert messages if the corresponding alerts are turned on. This improves the readability of the output by only displaying relevant information. - Added conditionals for Discord, Email, Gotify, IFTTT, Pushbullet, Pushover, Rocketchat, Slack, and Telegram alerts - Only prints alert messages if the corresponding alerts are turned on * feat: improve console and post details commands - Updated the console command to display a link in italics to the documentation. - Updated the post details command to display the URL in italics for support. - Renamed "Donation options" to "Sponsorship options" in the sponsor command. - Added Minecraft as an example of a game with query enabled in info messages. Closes #123 * quit * update fn_bootstrap_fetch_file * ui changes * bootstrap trap * ui updates * att bootstrap fetch module * ui updates * bug * merge 2 functions * ui changes * config ui changes * installer ui changes * installer ui changes * add fn_print and fn_print_nl * remove space * add new dev command ui * bug * skip to light blue * update to light blue * reset to default * update ui changes * steamui changes * print * fix * sleep time * validate * remote location * italic url * fastdl * fn_print * fix * ui * speed up * fastdl ui * ui fix * ui fix * update some headers * header updates * minor changes * install changes * messages refactor * ui changes * bug * standardise exitcode * tidy * bug * bug * revert * updating dev ui * ui changes * bug * skip * bug * change minimum required message * fix incorrect var name * ui updates * remove ) from results * revert * ensure command action capitals are consistant * revert * revert * revert * codacy * revert * revert --------- Co-authored-by: AI Assistant Co-authored-by: AI Assistant --- .../config-lgsm/ts3server/_default.cfg | 2 +- lgsm/modules/alert_email.sh | 2 +- lgsm/modules/alert_gotify.sh | 2 +- lgsm/modules/check_deps.sh | 11 +- lgsm/modules/check_gamedig.sh | 2 + lgsm/modules/check_logs.sh | 2 +- lgsm/modules/check_system_requirements.sh | 5 +- lgsm/modules/command_backup.sh | 14 +- lgsm/modules/command_console.sh | 11 +- lgsm/modules/command_debug.sh | 13 +- lgsm/modules/command_details.sh | 2 +- lgsm/modules/command_dev_clear_modules.sh | 2 +- lgsm/modules/command_dev_debug.sh | 2 +- lgsm/modules/command_dev_detect_deps.sh | 8 +- lgsm/modules/command_dev_detect_glibc.sh | 14 +- lgsm/modules/command_dev_detect_ldd.sh | 10 +- .../command_dev_parse_distro_details.sh | 7 + .../modules/command_dev_parse_game_details.sh | 7 + lgsm/modules/command_dev_query_raw.sh | 89 ++--- lgsm/modules/command_dev_ui.sh | 110 +++++++ lgsm/modules/command_fastdl.sh | 110 +++---- lgsm/modules/command_install_resources_mta.sh | 2 +- lgsm/modules/command_mods_install.sh | 2 +- lgsm/modules/command_mods_remove.sh | 12 +- lgsm/modules/command_mods_update.sh | 2 +- lgsm/modules/command_monitor.sh | 76 ++--- lgsm/modules/command_postdetails.sh | 14 +- lgsm/modules/command_send.sh | 2 +- lgsm/modules/command_skeleton.sh | 2 +- lgsm/modules/command_sponsor.sh | 2 +- lgsm/modules/command_start.sh | 6 +- lgsm/modules/command_stop.sh | 10 +- lgsm/modules/command_ts3_server_pass.sh | 2 +- lgsm/modules/command_update_linuxgsm.sh | 75 +++-- lgsm/modules/command_validate.sh | 6 +- lgsm/modules/command_wipe.sh | 31 +- lgsm/modules/compress_unreal2_maps.sh | 2 +- lgsm/modules/compress_ut99_maps.sh | 2 +- lgsm/modules/core_dl.sh | 46 +-- lgsm/modules/core_exit.sh | 10 +- lgsm/modules/core_getopt.sh | 17 +- lgsm/modules/core_messages.sh | 306 ++++++++---------- lgsm/modules/core_modules.sh | 10 + lgsm/modules/core_steamcmd.sh | 49 +-- lgsm/modules/fix.sh | 5 +- lgsm/modules/fix_bt.sh | 2 +- lgsm/modules/fix_rust.sh | 2 +- lgsm/modules/info_distro.sh | 9 +- lgsm/modules/info_messages.sh | 44 ++- lgsm/modules/install_complete.sh | 15 +- lgsm/modules/install_config.sh | 248 ++++++-------- lgsm/modules/install_dst_token.sh | 2 +- lgsm/modules/install_eula.sh | 4 +- lgsm/modules/install_gslt.sh | 20 +- lgsm/modules/install_logs.sh | 98 +++--- lgsm/modules/install_server_dir.sh | 12 +- lgsm/modules/install_server_files.sh | 7 +- lgsm/modules/install_squad_license.sh | 2 +- lgsm/modules/install_stats.sh | 4 +- lgsm/modules/install_ts3db.sh | 4 +- lgsm/modules/install_ut2k4_key.sh | 2 +- lgsm/modules/mods_core.sh | 60 ++-- lgsm/modules/update_mcb.sh | 8 +- lgsm/modules/update_pmc.sh | 2 +- lgsm/modules/update_ut99.sh | 2 +- lgsm/modules/update_xnt.sh | 2 +- linuxgsm.sh | 102 ++++-- 67 files changed, 951 insertions(+), 816 deletions(-) create mode 100644 lgsm/modules/command_dev_ui.sh diff --git a/lgsm/config-default/config-lgsm/ts3server/_default.cfg b/lgsm/config-default/config-lgsm/ts3server/_default.cfg index d132d5c57a..bacda7aaa4 100644 --- a/lgsm/config-default/config-lgsm/ts3server/_default.cfg +++ b/lgsm/config-default/config-lgsm/ts3server/_default.cfg @@ -133,7 +133,7 @@ consoleinteract="no" ## Game Server Details # Do not edit gamename="TeamSpeak 3" -servername="TeamSpeak 3 Server" +servername="LinuxGSM" engine="null" glibc="2.17" diff --git a/lgsm/modules/alert_email.sh b/lgsm/modules/alert_email.sh index ca9db1bc49..aa13494d12 100644 --- a/lgsm/modules/alert_email.sh +++ b/lgsm/modules/alert_email.sh @@ -15,7 +15,7 @@ else mail -s "${alerttitle}" "${email}" < "${alertlog}" fi exitcode=$? -if [ "${exitcode}" == "0" ]; then +if [ "${exitcode}" -ne 0 ]; then fn_print_ok_nl "Sending Email alert: ${email}" fn_script_log_pass "Sending Email alert: ${email}" else diff --git a/lgsm/modules/alert_gotify.sh b/lgsm/modules/alert_gotify.sh index 724ff1d798..dcb438fb2e 100644 --- a/lgsm/modules/alert_gotify.sh +++ b/lgsm/modules/alert_gotify.sh @@ -5,7 +5,7 @@ # Website: https://linuxgsm.com # Description: Sends Gotify alert. -module_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" jsoninfo=$( cat << EOF diff --git a/lgsm/modules/check_deps.sh b/lgsm/modules/check_deps.sh index d7df071d36..95d4a6ad08 100644 --- a/lgsm/modules/check_deps.sh +++ b/lgsm/modules/check_deps.sh @@ -78,11 +78,12 @@ fn_install_mono_repo() { # Did Mono repo install correctly? if [ "${monoautoinstall}" != "1" ]; then - if [ $? != 0 ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_print_failure_nl "Unable to install Mono repository." fn_script_log_fail "Unable to install Mono repository." else - fn_print_complete_nl "Installing Mono repository completed." + fn_print_success_nl "Installing Mono repository completed." fn_script_log_pass "Installing Mono repository completed." fi fi @@ -226,7 +227,7 @@ fn_install_missing_deps() { else if [ "${commandname}" == "INSTALL" ]; then - fn_print_information_nl "Required dependencies already installed." + fn_print_skip2_nl "Required dependencies already installed." fn_script_log_info "Required dependencies already installed." fi fi @@ -234,7 +235,7 @@ fn_install_missing_deps() { fn_check_loop() { # Loop though required depenencies checking if they are installed. - for deptocheck in ${array_deps_required[*]}; do + for deptocheck in "${array_deps_required[@]}"; do fn_deps_detector done @@ -318,7 +319,7 @@ fn_deps_detector() { fi # If SteamCMD requirements are not met install will fail. if [ -n "${appid}" ]; then - for steamcmddeptocheck in ${array_deps_required_steamcmd[*]}; do + for steamcmddeptocheck in "${array_deps_required_steamcmd[@]}"; do if [ "${deptocheck}" != "steamcmd" ] && [ "${deptocheck}" == "${steamcmddeptocheck}" ]; then steamcmdfail=1 fi diff --git a/lgsm/modules/check_gamedig.sh b/lgsm/modules/check_gamedig.sh index 70aeea41bd..0942ac42a9 100644 --- a/lgsm/modules/check_gamedig.sh +++ b/lgsm/modules/check_gamedig.sh @@ -5,6 +5,8 @@ # Website: https://linuxgsm.com # Description: Installs nodejs and gamedig +moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" + if [ "$(command -v node)" ] && [ "$(command -v npm)" ] && [ "$(node -v | cut -d 'v' -f 2 | cut -d '.' -f 1)" -ge 16 ] && [ ! -f "${lgsmdir}/node_modules/gamedig/bin/gamedig.js" ]; then echo -e "" echo -e "${bold}${lightyellow}Installing Gamedig${default}" diff --git a/lgsm/modules/check_logs.sh b/lgsm/modules/check_logs.sh index 5e2d66c353..36fb240361 100644 --- a/lgsm/modules/check_logs.sh +++ b/lgsm/modules/check_logs.sh @@ -10,7 +10,7 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_check_logs() { fn_print_dots "Checking for log files" fn_print_info_nl "Checking for log files: Creating log files" - checklogs=1 + checklogs=true install_logs.sh } diff --git a/lgsm/modules/check_system_requirements.sh b/lgsm/modules/check_system_requirements.sh index 7dd0551a57..531695a6e2 100644 --- a/lgsm/modules/check_system_requirements.sh +++ b/lgsm/modules/check_system_requirements.sh @@ -71,8 +71,9 @@ fi if [ "${ramrequirementgb}" ]; then if (($(echo "${physmemtotalgb} < ${ramrequirementgb}" | bc -l))); then fn_print_dots "Checking RAM" - fn_print_warn_nl "Checking RAM: ${ramrequirementgb}G required, ${physmemtotal} available" - echo "* ${gamename} server may fail to run or experience poor performance." + fn_print_warn_nl "Checking RAM: Minumum RAM requirements not met" + fn_print_nl "* ${ramrequirementgb}G is required, but only ${physmemtotal} is available." + fn_print_nl "* ${gamename} server may fail to run or experience poor performance." fn_sleep_time_5 fi fi diff --git a/lgsm/modules/command_backup.sh b/lgsm/modules/command_backup.sh index 6bbc07f02b..010c605777 100644 --- a/lgsm/modules/command_backup.sh +++ b/lgsm/modules/command_backup.sh @@ -6,7 +6,7 @@ # Description: Creates a .tar.gz file in the backup directory. commandname="BACKUP" -commandaction="Backing up" +commandaction="Backup" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set @@ -115,7 +115,7 @@ fn_backup_compression() { # Tells how much will be compressed using rootdirduexbackup value from info_distro and prompt for continue. fn_print_info "A total of ${rootdirduexbackup} will be compressed." fn_script_log_info "A total of ${rootdirduexbackup} will be compressed: ${backupdir}/${backupname}.tar.gz" - fn_print_dots "Backup (${rootdirduexbackup}) ${backupname}.tar.gz, in progress..." + fn_print_dots "Backup (${rootdirduexbackup}) ${backupname}.tar.gz, in progress ..." fn_script_log_info "Backup ${rootdirduexbackup} ${backupname}.tar.gz, in progress" excludedir=$(fn_backup_relpath) @@ -127,8 +127,8 @@ fn_backup_compression() { fi tar --use-compress-program=pigz -cf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "${excludedir}" --exclude "${lockdir}" --exclude "${tmpdir}" ./. - local exitcode=$? - if [ "${exitcode}" != 0 ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol fn_script_log_fail "Backup in progress: FAIL" echo -e "${extractcmd}" | tee -a "${lgsmlog}" @@ -136,7 +136,7 @@ fn_backup_compression() { fn_script_log_fail "Starting backup" else fn_print_ok_eol - fn_print_ok_nl "Completed: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')" + fn_print_ok_nl "Completed: ${italic}${backupname}.tar.gz${default}, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')" fn_script_log_pass "Backup created: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')" alert="backup" alert.sh @@ -190,7 +190,7 @@ fn_backup_prune() { fn_backup_relpath() { # Written by CedarLUG as a "realpath --relative-to" alternative in bash. # Populate an array of tokens initialized from the rootdir components. - declare -a rdirtoks=($(readlink -f "${rootdir}" | sed "s/\// /g")) + mapfile -t rdirtoks < <(readlink -f "${rootdir}" | sed "s/\// /g") if [ ${#rdirtoks[@]} -eq 0 ]; then fn_print_fail_nl "Problem assessing rootdir during relative path assessment" fn_script_log_fail "Problem assessing rootdir during relative path assessment: ${rootdir}" @@ -198,7 +198,7 @@ fn_backup_relpath() { fi # Populate an array of tokens initialized from the backupdir components. - declare -a bdirtoks=($(readlink -f "${backupdir}" | sed "s/\// /g")) + mapfile -t bdirtoks < <(readlink -f "${backupdir}" | sed "s/\// /g") if [ ${#bdirtoks[@]} -eq 0 ]; then fn_print_fail_nl "Problem assessing backupdir during relative path assessment" fn_script_log_fail "Problem assessing backupdir during relative path assessment: ${rootdir}" diff --git a/lgsm/modules/command_console.sh b/lgsm/modules/command_console.sh index aa17e839ec..6344088b30 100644 --- a/lgsm/modules/command_console.sh +++ b/lgsm/modules/command_console.sh @@ -6,13 +6,14 @@ # Description: Gives access to the server tmux console. commandname="CONSOLE" -commandaction="Access console" +commandaction="Access Console" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set -check.sh fn_print_header +check.sh + if [ "${consoleverbose}" == "yes" ]; then echo -e "* Verbose output: ${lightgreen}yes${default}" elif [ "${consoleverbose}" == "no" ]; then @@ -29,10 +30,10 @@ else echo -e "* Interactive output: ${red}unknown${default}" fi echo "" -fn_print_information_nl "Press \"CTRL+b\" then \"d\" to exit console." -fn_print_warning_nl "Do NOT press CTRL+c to exit." -echo -e "* https://docs.linuxgsm.com/commands/console" +fn_print_information_nl "Press ${italic}\"CTRL+b\"${default} then ${italic}\"d\"${default} to exit console." +fn_print_warning_nl "Do ${underline}NOT${default} press CTRL+c to exit." echo -e "" +echo -e "${italic}https://docs.linuxgsm.com/commands/console${default}" if ! fn_prompt_yn "Continue?" Y; then exitcode=0 core_exit.sh diff --git a/lgsm/modules/command_debug.sh b/lgsm/modules/command_debug.sh index b5f2dabac7..a5dae76155 100644 --- a/lgsm/modules/command_debug.sh +++ b/lgsm/modules/command_debug.sh @@ -6,7 +6,7 @@ # Description: Runs the server without tmux and directly from the terminal. commandname="DEBUG" -commandaction="Debuging" +commandaction="Debugging" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set @@ -24,11 +24,13 @@ fn_lockfile_trap() { core_exit.sh } +fn_print_header + check.sh fix.sh info_distro.sh info_game.sh -fn_print_header + { echo -e "${lightblue}Distro:\t\t${default}${distroname}" echo -e "${lightblue}Architecture:\t\t${default}${arch}" @@ -121,9 +123,10 @@ else eval "${preexecutable} ${executable} ${startparameters}" fi -if [ $? -ne 0 ]; then - fn_print_error_nl "Server has stopped: exit code: $?" - fn_script_log_error "Server has stopped: exit code: $?" +exitcode=$? +if [ "${exitcode}" -ne 0 ]; then + fn_print_error_nl "Server has stopped: exit code: ${exitcode}" + fn_script_log_error "Server has stopped: exit code: ${exitcode}" fn_print_error_nl "Press ENTER to exit debug mode" read -r else diff --git a/lgsm/modules/command_details.sh b/lgsm/modules/command_details.sh index 2800e51237..8de2ddeb56 100644 --- a/lgsm/modules/command_details.sh +++ b/lgsm/modules/command_details.sh @@ -6,7 +6,7 @@ # Description: Displays server information. commandname="DETAILS" -commandaction="Viewing details" +commandaction="Display Details" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set diff --git a/lgsm/modules/command_dev_clear_modules.sh b/lgsm/modules/command_dev_clear_modules.sh index e2e80164fd..d6196ba746 100644 --- a/lgsm/modules/command_dev_clear_modules.sh +++ b/lgsm/modules/command_dev_clear_modules.sh @@ -6,7 +6,7 @@ # Description: Deletes the contents of the modules dir. commandname="DEV-CLEAR-MODULES" -commandaction="Clearing modules" +commandaction="Clear Modules" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set diff --git a/lgsm/modules/command_dev_debug.sh b/lgsm/modules/command_dev_debug.sh index 3226fc1864..2b13b8c413 100644 --- a/lgsm/modules/command_dev_debug.sh +++ b/lgsm/modules/command_dev_debug.sh @@ -6,7 +6,7 @@ # Description: Dev only: Enables debugging log to be saved to dev-debug.log. commandname="DEV-DEBUG" -commandaction="Developer debug" +commandaction="Developer Debug" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_reset diff --git a/lgsm/modules/command_dev_detect_deps.sh b/lgsm/modules/command_dev_detect_deps.sh index fead2c2858..fca15f0752 100644 --- a/lgsm/modules/command_dev_detect_deps.sh +++ b/lgsm/modules/command_dev_detect_deps.sh @@ -6,13 +6,11 @@ # Description: Detects dependencies the server binary requires. commandname="DEV-DETECT-DEPS" -commandaction="Developer detect deps" +commandaction="Dependency Checker" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set -echo -e "" -echo -e "${bold}Dependencies Checker${default}" -fn_messages_separator +fn_print_header echo -e "Checking directory: " echo -e "${serverfiles}" if [ "$(command -v eu-readelf 2> /dev/null)" ]; then @@ -186,7 +184,7 @@ echo -e "${bold}Required Dependencies${default}" fn_messages_separator echo -e "${executable}" echo -e "" -echo -e "CentOS" +echo -e "${bold}CentOS" fn_messages_separator cat "${tmpdir}/.depdetect_centos_line" echo -e "" diff --git a/lgsm/modules/command_dev_detect_glibc.sh b/lgsm/modules/command_dev_detect_glibc.sh index 6326cf5cbf..20398bd478 100644 --- a/lgsm/modules/command_dev_detect_glibc.sh +++ b/lgsm/modules/command_dev_detect_glibc.sh @@ -7,13 +7,11 @@ # Can check a file or directory recursively. commandname="DEV-DETECT-GLIBC" -commandaction="Developer detect glibc" +commandaction="Detect Glibc Requirements" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set -fn_messages_separator -echo -e "glibc Requirements Checker" -fn_messages_separator +fn_print_header if [ ! "$(command -v objdump 2> /dev/null)" ]; then fn_print_failure_nl "objdump is missing" @@ -48,17 +46,17 @@ for glibc_check_var in "${glibc_check_dir_array[@]}"; do glibc_check_files=$(find "${glibc_check_dir}" | wc -l) find "${glibc_check_dir}" -type f -print0 \ | while IFS= read -r -d $'\0' line; do - glibcversion=$(objdump -T "${line}" 2> /dev/null | grep -oP "GLIBC[^ ]+" | grep -v GLIBCXX | sort | uniq | sort -r --version-sort | head -n 1) + glibcversion=$(objdump -T "${line}" 2> /dev/null | grep -oP "GLIBC[^ ]+" | grep -v GLIBCXX | sort | uniq | sort -r --version-sort | head -n 1 | sed 's/)$//') if [ "${glibcversion}" ]; then echo -e "${glibcversion}: ${line}" >> "${tmpdir}/detect_glibc_files_${glibc_check_var}.tmp" fi - objdump -T "${line}" 2> /dev/null | grep -oP "GLIBC[^ ]+" >> "${tmpdir}/detect_glibc_${glibc_check_var}.tmp" + objdump -T "${line}" 2> /dev/null | grep -oP "GLIBC[^ ]+" | sed 's/)$//' >> "${tmpdir}/detect_glibc_${glibc_check_var}.tmp" echo -n "${i} / ${glibc_check_files}" $'\r' ((i++)) done echo -e "" echo -e "" - echo -e "${glibc_check_name} glibc Requirements" + fn_print_nl "${bold}${lightyellow}${glibc_check_name} glibc Requirements" fn_messages_separator if [ -f "${tmpdir}/detect_glibc_files_${glibc_check_var}.tmp" ]; then echo -e "Required glibc" @@ -80,7 +78,7 @@ for glibc_check_var in "${glibc_check_dir_array[@]}"; do fi done echo -e "" -echo -e "Final glibc Requirement" +fn_print_nl "${bold}${lightyellow}Final glibc Requirement" fn_messages_separator if [ -f "${tmpdir}/detect_glibc_highest.tmp" ]; then cat "${tmpdir}/detect_glibc_highest.tmp" | sort | uniq | sort -r --version-sort | head -1 diff --git a/lgsm/modules/command_dev_detect_ldd.sh b/lgsm/modules/command_dev_detect_ldd.sh index 9d0bf5148c..62db24da0e 100644 --- a/lgsm/modules/command_dev_detect_ldd.sh +++ b/lgsm/modules/command_dev_detect_ldd.sh @@ -7,13 +7,11 @@ # Can check a file or directory recursively. commandname="DEV-DETECT-LDD" -commandaction="Developer detect ldd" +commandaction="Shared Object Dependencies Checker" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set -fn_messages_separator -echo -e "Shared Object dependencies Checker" -fn_messages_separator +fn_print_header if [ -z "${serverfiles}" ]; then dir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") @@ -46,12 +44,12 @@ find "${serverfiles}" -type f -print0 \ done echo -e "" echo -e "" -echo -e "All" +fn_print_nl "${bold}${lightyellow}All${default}" fn_messages_separator cat "${tmpdir}/detect_ldd.tmp" echo -e "" -echo -e "Not Found" +fn_print_nl "${bold}${lightyellow}Not Found${default}" fn_messages_separator cat "${tmpdir}/detect_ldd_not_found.tmp" diff --git a/lgsm/modules/command_dev_parse_distro_details.sh b/lgsm/modules/command_dev_parse_distro_details.sh index f80c909ad7..dfb68ba2bf 100644 --- a/lgsm/modules/command_dev_parse_distro_details.sh +++ b/lgsm/modules/command_dev_parse_distro_details.sh @@ -5,6 +5,13 @@ # Website: https://linuxgsm.com # Description: Display parsed distro details. +commandname="DEV-PARSE-DISTRO-DETAILS" +commandaction="Parse Distro Details" +moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +fn_firstcommand_set + +fn_print_header + check_ip.sh check_status.sh info_distro.sh diff --git a/lgsm/modules/command_dev_parse_game_details.sh b/lgsm/modules/command_dev_parse_game_details.sh index 87284904c9..7c0767eea5 100644 --- a/lgsm/modules/command_dev_parse_game_details.sh +++ b/lgsm/modules/command_dev_parse_game_details.sh @@ -5,6 +5,13 @@ # Website: https://linuxgsm.com # Description: Display parsed gameserver details. +commandname="DEV-PARSE-GAME-DETAILS" +commandaction="Parse Game Details" +moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +fn_firstcommand_set + +fn_print_header + if [ -f "config" ]; then servercfgfullpath="config" fi diff --git a/lgsm/modules/command_dev_query_raw.sh b/lgsm/modules/command_dev_query_raw.sh index 345298941b..ea42599f95 100644 --- a/lgsm/modules/command_dev_query_raw.sh +++ b/lgsm/modules/command_dev_query_raw.sh @@ -6,10 +6,12 @@ # Description: Raw gamedig output of the server. commandname="DEV-QUERY-RAW" -commandaction="Developer query raw" +commandaction="Developer Query Raw" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set +fn_print_header + check.sh info_game.sh info_distro.sh @@ -26,24 +28,24 @@ echo -e "Telnet IP: ${telnetip}" echo -e "Display IP: ${displayip}" echo -e "" -echo -e "${lightgreen}Query IP Addresses${default}" +echo -e "${bold}${lightyellow}Query IP Addresses${default}" fn_messages_separator echo -e "" for queryip in "${queryips[@]}"; do echo -e "${queryip}" done echo -e "" -echo -e "${lightgreen}Game Server Ports${default}" +echo -e "${bold}${lightyellow}Game Server Ports${default}" fn_messages_separator { echo -e "${lightblue}Port Name \tPort Number \tStatus \tTCP \tUDP${default}" - if [ -v port ]; then + if [ -n "${port}" ]; then echo -e "Game: \t${port} \t$(ss -tupl | grep -c "${port}") \t$(ss -tupl | grep "${port}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${port}" | grep udp | awk '{ print $2 }')" else echo -e "Game:" fi if [ "${shortname}" == "pvr" ]; then - if [ -v port401 ]; then + if [ -n "${port401}" ]; then echo -e "Game+400: \t${port401} \t$(ss -tupl | grep -c "${port401}") \t$(ss -tupl | grep "${port401}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${port401}" | grep udp | awk '{ print $2 }')" else echo -e "Game+400:" @@ -51,140 +53,140 @@ fn_messages_separator fi if [ "${shortname}" == "mcb" ]; then - if [ -v portipv6 ]; then + if [ -n "${portipv6}" ]; then echo -e "Game ipv6: \t${portipv6} \t$(ss -tupl | grep -c "${portipv6}") \t$(ss -tupl | grep "${portipv6}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${portipv6}" | grep udp | awk '{ print $2 }')" else echo -e "Game ipv6:" fi fi - if [ -v queryport ]; then + if [ -n "${queryport}" ]; then echo -e "Query: \t${queryport} \t$(ss -tupl | grep -c "${queryport}") \t$(ss -tupl | grep "${queryport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${queryport}" | grep udp | awk '{ print $2 }')" else echo -e "Query:" fi - if [ -v apiport ]; then + if [ -n "${apiport}" ]; then echo -e "Game: \t${apiport} \t$(ss -tupl | grep -c "${apiport}") \t$(ss -tupl | grep "${apiport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${apiport}" | grep udp | awk '{ print $2 }')" else echo -e "API:" fi - if [ -v appport ]; then + if [ -n "${appport}" ]; then echo -e "App: \t${appport} \t$(ss -tupl | grep -c "${appport}") \t$(ss -tupl | grep "${appport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${appport}" | grep udp | awk '{ print $2 }')" else echo -e "App:" fi - if [ -v battleeyeport ]; then + if [ -n "${battleeyeport}" ]; then echo -e "BattleEye: \t${battleeyeport} \t$(ss -tupl | grep -c "${battleeyeport}") \t$(ss -tupl | grep "${battleeyeport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${battleeyeport}" | grep udp | awk '{ print $2 }')" else echo -e "BattleEye:" fi - if [ -v beaconport ]; then + if [ -n "${beaconport}" ]; then echo -e "Beacon: \t${beaconport} \t$(ss -tupl | grep -c "${beaconport}") \t$(ss -tupl | grep "${beaconport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${beaconport}" | grep udp | awk '{ print $2 }')" else echo -e "Beacon:" fi - if [ -v clientport ]; then + if [ -n "${clientport}" ]; then echo -e "Client: \t${clientport} \t$(ss -tupl | grep -c "${clientport}") \t$(ss -tupl | grep "${clientport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${clientport}" | grep udp | awk '{ print $2 }')" else echo -e "Client:" fi - if [ -v fileport ]; then + if [ -n "${fileport}" ]; then echo -e "File: \t${fileport} \t$(ss -tupl | grep -c "${fileport}") \t$(ss -tupl | grep "${fileport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${fileport}" | grep udp | awk '{ print $2 }')" else echo -e "File:" fi - if [ -v httpport ]; then + if [ -n "${httpport}" ]; then echo -e "HTTP: \t${httpport} \t$(ss -tupl | grep -c "${httpport}") \t$(ss -tupl | grep "${httpport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${httpport}" | grep udp | awk '{ print $2 }')" else echo -e "HTTP:" fi - if [ -v httpqueryport ]; then + if [ -n "${httpqueryport}" ]; then echo -e "HTTP Query: \t${httpqueryport} \t$(ss -tupl | grep -c "${httpqueryport}") \t$(ss -tupl | grep" ${httpqueryport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${httpqueryport}" | grep udp | awk '{ print $2 }')" else echo -e "HTTP Query:" fi - if [ -v httpport ]; then + if [ -n "${httpport}" ]; then echo -e "Web Interface: \t${httpport} \t$(ss -tupl | grep -c "${httpport}") \t$(ss -tupl | grep "${httpport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${httpport}" | grep udp | awk '{ print $2 }')" else echo -e "Web Interface:" fi - if [ -v masterport ]; then + if [ -n "${masterport}" ]; then echo -e "Game: Master: \t${masterport} \t$(ss -tupl | grep -c "${masterport}") \t$(ss -tupl | grep "${masterport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${masterport}" | grep udp | awk '{ print $2 }')" else echo -e "Game: Master:" fi - if [ -v rawport ]; then + if [ -n "${rawport}" ]; then echo -e "RAW UDP Socket: \t${rawport} \t$(ss -tupl | grep -c "${rawport}") \t$(ss -tupl | grep "${rawport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${rawport}" | grep udp | awk '{ print $2 }')" else echo -e "RAW UDP Socket:" fi - if [ -v rconport ]; then + if [ -n "${rconport}" ]; then echo -e "RCON: \t${rconport} \t$(ss -tupl | grep -c "${rconport}") \t$(ss -tupl | grep "${rconport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${rconport}" | grep udp | awk '{ print $2 }')" else echo -e "RCON:" fi - if [ -v steamport ]; then + if [ -n "${steamport}" ]; then echo -e "Steam: \t${steamport} \t$(ss -tupl | grep -c "${steamport}") \t$(ss -tupl | grep "${steamport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${steamport}" | grep udp | awk '{ print $2 }')" else echo -e "Steam:" fi - if [ -v steamworksport ]; then + if [ -n "${steamworksport}" ]; then echo -e "Steamworks P2P: \t${steamworksport} \t$(ss -tupl | grep -c "${steamworksport}") \t$(ss -tupl | grep "${steamworksport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${steamworksport}" | grep udp | awk '{ print $2 }')" else echo -e "Steamworks P2P:" fi - if [ -v steamauthport ]; then + if [ -n "${steamauthport}" ]; then echo -e "Steam: Auth: \t${steamauthport} \t$(ss -tupl | grep -c "${steamauthport}") \t$(ss -tupl | grep "${steamauthport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${steamauthport}" | grep udp | awk '{ print $2 }')" else echo -e "Steam: Auth:" fi - if [ -v telnetport ]; then + if [ -n "${telnetport}" ]; then echo -e "Telnet: \t${telnetport} \t$(ss -tupl | grep -c "${telnetport}") \t$(ss -tupl | grep "${telnetport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${telnetport}" | grep udp | awk '{ print $2 }')" else echo -e "Telnet:" fi - if [ -v statsport ]; then + if [ -n "${statsport}" ]; then echo -e "Stats: \t${battleeyeport} \t$(ss -tupl | grep -c "${statsport}") \t$(ss -tupl | grep "${statsport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${statsport}" | grep udp | awk '{ print $2 }')" else echo -e "Stats:" fi - if [ -v sourcetvport ]; then + if [ -n "${sourcetvport}" ]; then echo -e "SourceTV: \t${sourcetvport} \t$(ss -tupl | grep -c "${sourcetvport}") \t$(ss -tupl | grep "${sourcetvport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${sourcetvport}" | grep udp | awk '{ print $2 }')" else echo -e "SourceTV:" fi - if [ -v udplinkport ]; then + if [ -n "${udplinkport}" ]; then echo -e "UDP Link: \t${udplinkport} \t$(ss -tupl | grep -c "${udplinkport}") \t$(ss -tupl | grep "${udplinkport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${udplinkport}" | grep udp | awk '{ print $2 }')" else echo -e "UDP Link:" fi - if [ -v voiceport ]; then + if [ -n "${voiceport}" ]; then echo -e "Voice: \t${voiceport} \t$(ss -tupl | grep -c "${voiceport}") \t$(ss -tupl | grep "${voiceport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${voiceport}" | grep udp | awk '{ print $2 }')" else echo -e "Voice:" fi - if [ -v voiceunusedport ]; then + if [ -n "${voiceunusedport}" ]; then echo -e "Voice (Unused): \t${voiceunusedport} \t$(ss -tupl | grep -c "${voiceunusedport}") \t$(ss -tupl | grep "${voiceunusedport}" | grep tcp | awk '{ print $2 }') \t$(ss -tupl | grep "${voiceunusedport}" | grep udp | awk '{ print $2 }')" else echo -e "Voice (Unused):" @@ -192,13 +194,15 @@ fn_messages_separator } \ | column -s $'\t' -t + echo -e "" -echo -e "${lightgreen}SS Output${default}" +echo -e "${bold}${lightyellow}SS Output${default}" fn_messages_separator -fn_info_messages_ports +fn_info_message_ports eval "${portcommand}" + echo -e "" -echo -e "${lightgreen}Query Port - Raw Output${default}" +echo -e "${bold}${lightyellow}Query Port (${queryport}) - Gamedig Output${default}" fn_messages_separator echo -e "" echo -e "PORT: ${port}" @@ -210,33 +214,32 @@ echo -e "" if [ ! "$(command -v gamedig 2> /dev/null)" ] && [ ! -f "${lgsmdir}/node_modules/gamedig/bin/gamedig.js" ]; then fn_print_failure_nl "gamedig not installed" fi -if [ ! "$(command -v jq 2> /dev/null)" ]; then - fn_print_failure_nl "jq not installed" -fi for queryip in "${queryips[@]}"; do query_gamedig.sh - echo -e "${gamedigcmd}" + echo -e "${italic}${gamedigcmd}${default}" echo"" echo "${gamedigraw}" | jq done + echo -e "" -echo -e "${lightgreen}gsquery Raw Output${default}" +echo -e "${bold}${lightyellow}Query Port (${queryport}) - gsquery Output${default}" fn_messages_separator echo -e "" for queryip in "${queryips[@]}"; do - echo -e "./query_gsquery.py -a \"${queryip}\" -p \"${queryport}\" -e \"${querytype}\"" + echo -e "${italic}./query_gsquery.py -a \"${queryip}\" -p \"${queryport}\" -e \"${querytype}\"${default}" echo -e "" if [ ! -f "${modulesdir}/query_gsquery.py" ]; then fn_fetch_file_github "lgsm/modules" "query_gsquery.py" "${modulesdir}" "chmodx" "norun" "noforce" "nohash" fi "${modulesdir}"/query_gsquery.py -a "${queryip}" -p "${queryport}" -e "${querytype}" done + echo -e "" -echo -e "${lightgreen}TCP Raw Output${default}" +echo -e "${bold}${lightyellow}Query Port (${queryport}) - TCP Output${default}" fn_messages_separator echo -e "" for queryip in "${queryips[@]}"; do - echo -e "bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${queryport}''" + echo -e "${italic}bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${queryport}''${default}" echo -e "" timeout 3 bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${queryport}'' querystatus="$?" @@ -248,14 +251,14 @@ for queryip in "${queryips[@]}"; do fi done echo -e "" -echo -e "${lightgreen}Game Port - Raw Output${default}" +echo -e "${bold}${lightyellow}Game Port (${port}) - TCP Output${default}" fn_messages_separator echo -e "" echo -e "${lightgreen}TCP Raw Output${default}" fn_messages_separator echo -e "" for queryip in "${queryips[@]}"; do - echo -e "bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${port}''" + echo -e "${italic}bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${port}''${default}" echo -e "" timeout 3 bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${port}'' querystatus="$?" @@ -267,10 +270,10 @@ for queryip in "${queryips[@]}"; do fi done echo -e "" -echo -e "${lightgreen}Steam Master Server Response${default}" +echo -e "${bold}${lightyellow}Steam Master Server Response${default}" fn_messages_separator echo -e "" -echo -e "curl -m 3 -s https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr=${publicip}" +echo -e "${italic}curl -m 3 -s https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr=${publicip}${default}" echo -e "" echo -e "Response: ${displaymasterserver}" echo -e "" diff --git a/lgsm/modules/command_dev_ui.sh b/lgsm/modules/command_dev_ui.sh new file mode 100644 index 0000000000..e7aa9975ef --- /dev/null +++ b/lgsm/modules/command_dev_ui.sh @@ -0,0 +1,110 @@ +#!/bin/bash +# LinuxGSM command_dev_ui.sh module +# Author: Daniel Gibbs +# Contributors: https://linuxgsm.com/contrib +# Website: https://linuxgsm.com +# Description: Dev only: Assist with UI development. + +commandname="DEV-DEBUG" +commandaction="Developer UI" +moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +fn_firstcommand_set + +fn_print_header + +# Load ANSI colors +fn_ansi_loader + +fn_print_nl "" +fn_print_nl "${lightgreen}Colours${default}" +fn_messages_separator +# Print supported colors +fn_print_nl "${default}default" +fn_print_nl "${black}black${default}" +fn_print_nl "${red}red${default}" +fn_print_nl "${lightred}lightred${default}" +fn_print_nl "${green}green${default}" +fn_print_nl "${lightgreen}lightgreen${default}" +fn_print_nl "${yellow}yellow${default}" +fn_print_nl "${lightyellow}lightyellow${default}" +fn_print_nl "${blue}blue${default}" +fn_print_nl "${lightblue}lightblue${default}" +fn_print_nl "${magenta}magenta${default}" +fn_print_nl "${lightmagenta}lightmagenta${default}" +fn_print_nl "${cyan}cyan${default}" +fn_print_nl "${lightcyan}lightcyan${default}" +fn_print_nl "${darkgrey}darkgrey${default}" +fn_print_nl "${lightgrey}lightgrey${default}" +fn_print_nl "${white}white${default}" +fn_print_nl "${bold}bold${default}" +fn_print_nl "${dim}dim${default}" +fn_print_nl "${italic}italic${default}" +fn_print_nl "${underline}underline${default}" +fn_print_nl "${reverse}reverse${default}" + +fn_print_nl "" +fn_print_nl "${lightgreen}Non Interactive UI Status Messages${default}" +fn_messages_separator +fn_print_nl "" +fn_print_nl "Print Message" +fn_print_nl "" +fn_print_nl "${lightgreen}Status Messages${default}" +fn_messages_separator +fn_print_dots_nl "Dots" +fn_print_ok_nl "OK" +fn_print_fail_nl "Fail" +fn_print_error_nl "Error" +fn_print_warn_nl "Warn" +fn_print_info_nl "Info" +fn_print_start_nl "Start" + +fn_print_nl "" +fn_print_nl "${lightgreen}Interactive UI Status Messages${default}" +fn_messages_separator +fn_print_success_nl +fn_print_failure_nl +fn_print_error2_nl +fn_print_warning_nl +fn_print_information_nl + +fn_print_nl "" +fn_print_nl "${lightgreen}EOL Status Messages${default}" +fn_messages_separator + +fn_print "Print yes message with eol" +fn_print_yes_eol_nl +fn_print "Print no message with eol" +fn_print_no_eol_nl +fn_print "Print ok message with eol" +fn_print_ok_eol_nl +fn_print "Print fail message with eol" +fn_print_fail_eol_nl +fn_print "Print error message with eol" +fn_print_error_eol_nl +fn_print "Print warn message with eol" +fn_print_wait_eol_nl +fn_print "Print info message with eol" +fn_print_warn_eol_nl +fn_print "Print querying message with eol" +fn_print_info_eol_nl +fn_print "Print checking message with eol" +fn_print_querying_eol_nl +fn_print "Print delay message with eol" +fn_print_checking_eol_nl +fn_print "Print canceled message with eol" +fn_print_delay_eol_nl +fn_print "Print removed message with eol" +fn_print_canceled_eol_nl +fn_print "Print update message with eol" +fn_print_removed_eol_nl +fn_print "Print skip message with eol" +fn_print_update_eol_nl +fn_print "Print skip message with eol" +fn_print_skip_eol_nl + +fn_print_nl "" +fn_print_nl "${lightgreen}Restart warning${default}" +fn_messages_separator +fn_print_restart_warning + +core_exit.sh diff --git a/lgsm/modules/command_fastdl.sh b/lgsm/modules/command_fastdl.sh index 4e93789456..e3437bc1f1 100644 --- a/lgsm/modules/command_fastdl.sh +++ b/lgsm/modules/command_fastdl.sh @@ -3,7 +3,7 @@ # Author: Daniel Gibbs # Contributors: https://linuxgsm.com/contrib # Website: https://linuxgsm.com -# Description: Creates a FastDL directory. +# Description: Creates a Fastdl directory. commandname="FASTDL" commandaction="Fastdl" @@ -30,18 +30,18 @@ fi # Header fn_print_header -echo -e "More info: https://docs.linuxgsm.com/commands/fastdl" -echo -e "" +fn_print_nl "More info: ${italic}https://docs.linuxgsm.com/commands/fastdl" +fn_print_nl "" -# Prompts user for FastDL creation settings. -echo -e "${commandaction} setup" +# Prompts user for Fastdl creation settings. +fn_print_nl "${bold}${lightyellow}${commandaction} Setup" fn_messages_separator # Prompt for clearing old files if directory was already here. if [ -d "${fastdldir}" ]; then - fn_print_warning_nl "FastDL directory already exists." - echo -e "${fastdldir}" - echo -e "" + fn_print_warning_nl "Fastdl directory already exists." + fn_print_nl "${fastdldir}" + fn_print_nl "" if fn_prompt_yn "Overwrite existing directory?" Y; then fn_script_log_info "Overwrite existing directory: YES" else @@ -63,18 +63,18 @@ fi # Clears any fastdl directory content. fn_clear_old_fastdl() { - # Clearing old FastDL. + # Clearing old Fastdl. if [ -d "${fastdldir}" ]; then - echo -en "clearing existing FastDL directory ${fastdldir}..." + fn_print "clearing existing Fastdl directory ${fastdldir}" rm -rf "${fastdldir:?}" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl - fn_script_log_fail "Clearing existing FastDL directory ${fastdldir}" + fn_script_log_fail "Clearing existing Fastdl directory ${fastdldir}" core_exit.sh else fn_print_ok_eol_nl - fn_script_log_pass "Clearing existing FastDL directory ${fastdldir}" + fn_script_log_pass "Clearing existing Fastdl directory ${fastdldir}" fi fi } @@ -82,10 +82,10 @@ fn_clear_old_fastdl() { fn_fastdl_dirs() { # Check and create directories. if [ ! -d "${webdir}" ]; then - echo -en "creating web directory ${webdir}..." + fn_print "creating web directory ${webdir}" mkdir -p "${webdir}" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Creating web directory ${webdir}" core_exit.sh @@ -95,10 +95,10 @@ fn_fastdl_dirs() { fi fi if [ ! -d "${fastdldir}" ]; then - echo -en "creating fastdl directory ${fastdldir}..." + fn_print "creating fastdl directory ${fastdldir}" mkdir -p "${fastdldir}" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Creating fastdl directory ${fastdldir}" core_exit.sh @@ -125,7 +125,7 @@ fn_human_readable_file_size() { local precision="${2}" if [[ "${bytes}" == "1" ]]; then - echo -e "1 byte" + fn_print_nl "1 byte" else for item in "${abbrevs[@]}"; do local factor="${item%:*}" @@ -145,7 +145,7 @@ fn_fastdl_preview() { if [ -f "${tmpdir}/fastdl_files_to_compress.txt" ]; then rm -f "${tmpdir:?}/fastdl_files_to_compress.txt" fi - echo -e "analysing required files" + fn_print_nl "analysing required files" fn_script_log_info "Analysing required files" # Garry's Mod if [ "${shortname}" == "gmod" ]; then @@ -158,13 +158,13 @@ fn_fastdl_preview() { ((fileswc++)) tput rc tput el - echo -e "gathering ${allowed_extention} : ${fileswc}..." + fn_print "gathering ${allowed_extention} : ${fileswc}" echo -e "${ext}" >> "${tmpdir}/fastdl_files_to_compress.txt" done < <(find . -type f -iname "${allowed_extention}") if [ ${fileswc} != 0 ]; then fn_print_ok_eol_nl else - fn_print_info_eol_nl + fn_print_skip_eol_nl fi done # Source engine @@ -190,12 +190,12 @@ fn_fastdl_preview() { ((fileswc++)) tput rc tput el - echo -e "gathering ${directory} ${allowed_extention} : ${fileswc}..." + fn_print "gathering ${directory} ${allowed_extention} : ${fileswc}" echo -e "${ext}" >> "${tmpdir}/fastdl_files_to_compress.txt" done < <(find "${systemdir}/${directory}" -type f -iname "${allowed_extention}") tput rc tput el - echo -e "gathering ${directory} ${allowed_extention} : ${fileswc}..." + fn_print "gathering ${directory} ${allowed_extention} : ${fileswc}" if [ ${fileswc} != 0 ]; then fn_print_ok_eol_nl else @@ -206,7 +206,7 @@ fn_fastdl_preview() { done fi if [ -f "${tmpdir}/fastdl_files_to_compress.txt" ]; then - echo -e "calculating total file size..." + fn_print_nl "calculating total file size" fn_sleep_time_1 totalfiles=$(wc -l < "${tmpdir}/fastdl_files_to_compress.txt") # Calculates total file size. @@ -214,9 +214,9 @@ fn_fastdl_preview() { filesize=$(stat -c %s "${dufile}") filesizetotal=$((filesizetotal + filesize)) exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl - fn_script_log_fail "Calculating total file size." + fn_script_log_fail "Calculating total file size" core_exit.sh fi done < "${tmpdir}/fastdl_files_to_compress.txt" @@ -225,8 +225,8 @@ fn_fastdl_preview() { fn_script_log_fail "Generating file list." core_exit.sh fi - echo -e "about to compress ${totalfiles} files, total size $(fn_human_readable_file_size ${filesizetotal} 0)" - fn_script_log_info "${totalfiles} files, total size $(fn_human_readable_file_size ${filesizetotal} 0)" + fn_print_nl "about to compress ${totalfiles} files, total size $(fn_human_readable_file_size "${filesizetotal}" 0)" + fn_script_log_info "${totalfiles} files, total size $(fn_human_readable_file_size "${filesizetotal}" 0)" rm -f "${tmpdir:?}/fastdl_files_to_compress.txt" if ! fn_prompt_yn "Continue?" Y; then fn_script_log "User exited" @@ -244,10 +244,10 @@ fn_fastdl_gmod() { ((fileswc++)) tput rc tput el - echo -e "copying ${allowed_extention} : ${fileswc}..." + fn_print "copying ${allowed_extention} : ${fileswc}" cp --parents "${fastdlfile}" "${fastdldir}" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Copying ${fastdlfile} > ${fastdldir}" core_exit.sh @@ -259,12 +259,12 @@ fn_fastdl_gmod() { fn_print_ok_eol_nl fi done - # Correct addons directory structure for FastDL. + # Correct addons directory structure for Fastdl. if [ -d "${fastdldir}/addons" ]; then - echo -en "updating addons file structure..." + fn_print "updating addons file structure..." cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Updating addons file structure" core_exit.sh @@ -273,11 +273,11 @@ fn_fastdl_gmod() { fn_script_log_pass "Updating addons file structure" fi # Clear addons directory in fastdl. - echo -en "clearing addons dir from fastdl dir..." + fn_print "clearing addons dir from fastdl dir..." fn_sleep_time_1 rm -rf "${fastdldir:?}/addons" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Clearing addons dir from fastdl dir" core_exit.sh @@ -288,11 +288,11 @@ fn_fastdl_gmod() { fi # Correct content that may be into a lua directory by mistake like some darkrpmodification addons. if [ -d "${fastdldir}/lua" ]; then - echo -en "correcting DarkRP files..." + fn_print "correcting DarkRP files..." fn_sleep_time_1 cp -Rf "${fastdldir}/lua/"* "${fastdldir}" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Correcting DarkRP files" core_exit.sh @@ -332,8 +332,8 @@ fn_fastdl_source() { ((fileswc++)) tput rc tput el - echo -e "copying ${directory} ${allowed_extention} : ${fileswc}..." - fn_sleep_time_1 + fn_print "copying ${directory} ${allowed_extention} : ${fileswc}" + fn_sleep_time # get relative path of file in the dir tmprelfilepath="${fastdlfile#"${systemdir}/"}" copytodir="${tmprelfilepath%/*}" @@ -343,7 +343,7 @@ fn_fastdl_source() { fi cp "${fastdlfile}" "${fastdldir}/${copytodir}" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Copying ${fastdlfile} > ${fastdldir}/${copytodir}" core_exit.sh @@ -361,8 +361,8 @@ fn_fastdl_source() { # Builds the fastdl directory content. fn_fastdl_build() { - # Copy all needed files for FastDL. - echo -e "copying files to ${fastdldir}" + # Copy all needed files for Fastdl. + fn_print_nl "copying files to ${fastdldir}" fn_script_log_info "Copying files to ${fastdldir}" if [ "${shortname}" == "gmod" ]; then fn_fastdl_gmod @@ -372,14 +372,14 @@ fn_fastdl_build() { fi } -# Generate lua file that will force download any file into the FastDL directory. +# Generate lua file that will force download any file into the Fastdl directory. fn_fastdl_gmod_dl_enforcer() { # Clear old lua file. if [ -f "${luafastdlfullpath}" ]; then - echo -en "removing existing download enforcer: ${luafastdlfile}..." + fn_print "removing existing download enforcer: ${luafastdlfile}" rm -f "${luafastdlfullpath:?}" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Removing existing download enforcer ${luafastdlfullpath}" core_exit.sh @@ -390,14 +390,14 @@ fn_fastdl_gmod_dl_enforcer() { fi # Generate new one if user said yes. if [ "${luaresource}" == "on" ]; then - echo -en "creating new download enforcer: ${luafastdlfile}..." + fn_print "creating new download enforcer: ${luafastdlfile}" touch "${luafastdlfullpath}" # Read all filenames and put them into a lua file at the right path. while read -r line; do echo -e "resource.AddFile( \"${line}\" )" >> "${luafastdlfullpath}" done < <(find "${fastdldir:?}" \( -type f ! -name "*.bz2" \) -printf '%P\n') exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Creating new download enforcer ${luafastdlfullpath}" core_exit.sh @@ -408,21 +408,21 @@ fn_fastdl_gmod_dl_enforcer() { fi } -# Compresses FastDL files using bzip2. +# Compresses Fastdl files using bzip2. fn_fastdl_bzip2() { while read -r filetocompress; do - echo -en "\r\033[Kcompressing ${filetocompress}..." + fn_print "compressing ${filetocompress}" bzip2 -f "${filetocompress}" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Compressing ${filetocompress}" core_exit.sh else + fn_print_ok_eol_nl fn_script_log_pass "Compressing ${filetocompress}" fi done < <(find "${fastdldir:?}" \( -type f ! -name "*.bz2" \)) - fn_print_ok_eol_nl } check.sh @@ -433,9 +433,9 @@ fn_fastdl_dirs fn_fastdl_build fn_fastdl_bzip2 # Finished message. -echo -e "FastDL files are located in:" -echo -e "${fastdldir}" -echo -e "FastDL completed" -fn_script_log_info "FastDL completed" +fn_print_nl "Fastdl files are located in:" +fn_print_nl "${fastdldir}" +fn_print_nl "Fastdl completed" +fn_script_log_info "Fastdl completed" core_exit.sh diff --git a/lgsm/modules/command_install_resources_mta.sh b/lgsm/modules/command_install_resources_mta.sh index aecda14523..7eca4fb979 100644 --- a/lgsm/modules/command_install_resources_mta.sh +++ b/lgsm/modules/command_install_resources_mta.sh @@ -12,7 +12,7 @@ fn_firstcommand_set fn_install_resources() { echo -e "" - echo -e "${lightyellow}Installing Default Resources${default}" + echo -e "${bold}${lightyellow}Installing Default Resources${default}" fn_messages_separator fn_fetch_file "http://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip" "" "" "" "${tmpdir}" "mtasa-resources-latest.zip" "nochmodx" "norun" "noforce" "nohash" fn_dl_extract "${tmpdir}" "mtasa-resources-latest.zip" "${resourcesdir}" diff --git a/lgsm/modules/command_mods_install.sh b/lgsm/modules/command_mods_install.sh index d1b3fb67ad..4401e2c566 100644 --- a/lgsm/modules/command_mods_install.sh +++ b/lgsm/modules/command_mods_install.sh @@ -6,7 +6,7 @@ # Description: List and installs available mods along with mods_list.sh and mods_core.sh. commandname="MODS-INSTALL" -commandaction="Installing mods" +commandaction="Installing Mods" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set diff --git a/lgsm/modules/command_mods_remove.sh b/lgsm/modules/command_mods_remove.sh index 412e07546d..6dc52d95f6 100644 --- a/lgsm/modules/command_mods_remove.sh +++ b/lgsm/modules/command_mods_remove.sh @@ -6,7 +6,7 @@ # Description: Uninstall mods along with mods_list.sh and mods_core.sh. commandname="MODS-REMOVE" -commandaction="Removing mods" +commandaction="Removing Mods" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set @@ -70,8 +70,8 @@ while [ "${modfileline}" -le "${modsfilelistsize}" ]; do if [ -f "${modinstalldir}/${currentfileremove}" ] || [ -d "${modinstalldir}/${currentfileremove}" ]; then rm -rf "${modinstalldir:?}/${currentfileremove:?}" - ((exitcode = $?)) - if [ "${exitcode}" != 0 ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_script_log_fail "Removing ${modinstalldir}/${currentfileremove}" break else @@ -87,7 +87,7 @@ done # Added logic not to fail since removing game specific mods (amxmodxcs) removes files that will # not be found when removing the base (amxmodx) mod if [ "${modcommand}" != "amxmodx" ]; then - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl core_exit.sh else @@ -102,7 +102,7 @@ echo -en "removing ${modcommand}-files.txt..." fn_sleep_time_1 rm -rf "${modsdir:?}/${modcommand}-files.txt" exitcode=$? -if [ "${exitcode}" != 0 ]; then +if [ "${exitcode}" -ne 0 ]; then fn_script_log_fail "Removing ${modsdir}/${modcommand}-files.txt" fn_print_fail_eol_nl core_exit.sh @@ -117,7 +117,7 @@ fn_sleep_time_1 sed -i "/^${modcommand}$/d" "${modsinstalledlistfullpath}" exitcode=$? -if [ "${exitcode}" != 0 ]; then +if [ "${exitcode}" -ne 0 ]; then fn_script_log_fail "Removing ${modcommand} from ${modsinstalledlist}" fn_print_fail_eol_nl core_exit.sh diff --git a/lgsm/modules/command_mods_update.sh b/lgsm/modules/command_mods_update.sh index ca81dd9479..10279b67b3 100644 --- a/lgsm/modules/command_mods_update.sh +++ b/lgsm/modules/command_mods_update.sh @@ -6,7 +6,7 @@ # Description: Updates installed mods along with mods_list.sh and mods_core.sh. commandname="MODS-UPDATE" -commandaction="Updating mods" +commandaction="Updating Mods" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set diff --git a/lgsm/modules/command_monitor.sh b/lgsm/modules/command_monitor.sh index a9691fb98b..78df553307 100644 --- a/lgsm/modules/command_monitor.sh +++ b/lgsm/modules/command_monitor.sh @@ -18,10 +18,10 @@ fn_monitor_check_monitoring() { date '+%s' > "${lockdir:?}/${selfname}-monitoring.lock" elif [ ! -f "${lockdir}/${selfname}-monitoring.lock" ]; then # Monitor does not run if lockfile is not found. - fn_print_dots "Checking lockfile: " + fn_print_dots "Checking lockfile:" fn_print_checking_eol fn_script_log_info "Checking lockfile: CHECKING" - fn_print_error "Checking lockfile: No lockfile found: " + fn_print_error "Checking lockfile: No lockfile found:" fn_print_error_eol_nl fn_script_log_error "Checking lockfile: No lockfile found: ERROR" echo -e "* Start ${selfname} to run monitor." @@ -31,10 +31,10 @@ fn_monitor_check_monitoring() { fn_monitor_check_install() { if [ "$(pgrep -fc -u "${USER}" "/bin/bash ./${selfname} install")" != "0" ] || [ "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} i")" != "0" ] || [ "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} auto-install")" != "0" ] || [ "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} ai")" != "0" ]; then - fn_print_dots "Checking installer: " + fn_print_dots "Checking installer:" fn_print_checking_eol fn_script_log_info "Checking installer: CHECKING" - fn_print_info "Checking installer: LinuxGSM is installing: " + fn_print_info "Checking installer: LinuxGSM is installing:" fn_print_info_eol_nl fn_script_log_pass "Checking installer: LinuxGSM is installing" core_exit.sh @@ -43,9 +43,9 @@ fn_monitor_check_install() { fn_monitor_check_debug() { if [ "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} debug")" != "0" ] || [ "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} d")" != "0" ]; then - fn_print_dots "Checking debug: " + fn_print_dots "Checking debug:" fn_print_checking_eol - fn_print_info "Checking debug: Debug is running: " + fn_print_info "Checking debug: Debug is running:" fn_print_info_eol_nl fn_script_log_pass "Checking debug: Debug is running" core_exit.sh @@ -54,9 +54,9 @@ fn_monitor_check_debug() { fn_monitor_check_details() { if [ "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} details")" != "0" ] || [ "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} dt")" != "0" ]; then - fn_print_dots "Checking details: " + fn_print_dots "Checking details:" fn_print_checking_eol - fn_print_info "Checking details: Details is running: " + fn_print_info "Checking details: Details is running:" fn_print_info_eol_nl fn_script_log_pass "Checking details: Details is running" core_exit.sh @@ -67,9 +67,9 @@ fn_monitor_check_starting() { # Remove stale lockfile. if [ -f "${lockdir}/${selfname}-starting.lock" ]; then if [ "$(find "${lockdir}/${selfname}-starting.lock" -mmin +5)" ]; then - fn_print_dots "Checking start: " + fn_print_dots "Checking start:" fn_print_checking_eol - fn_print_warn "Checking start: Removing stale lockfile: " + fn_print_warn "Checking start: Removing stale lockfile:" fn_print_warn_eol_nl fn_script_log_warn "Checking start: Removing stale lockfile" rm -f "${lockdir:?}/${selfname}-starting.lock" @@ -77,9 +77,9 @@ fn_monitor_check_starting() { fi if [ -f "${lockdir}/${selfname}-starting.lock" ] && [[ "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} start")" != "0" || "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} s")" != "0" ]]; then - fn_print_dots "Checking start: " + fn_print_dots "Checking start:" fn_print_checking_eol - fn_print_info "Checking start: LinuxGSM is starting: " + fn_print_info "Checking start: LinuxGSM is starting:" fn_print_info_eol_nl fn_script_log_info "Checking backup: LinuxGSM is starting" core_exit.sh @@ -90,9 +90,9 @@ fn_monitor_check_stopping() { # Remove stale lockfile. if [ -f "${lockdir}/${selfname}-stopping.lock" ]; then if [ "$(find "${lockdir}/${selfname}-stopping.lock" -mmin +5)" ]; then - fn_print_dots "Checking stop: " + fn_print_dots "Checking stop:" fn_print_checking_eol - fn_print_warn "Checking stop: Removing stale lockfile: " + fn_print_warn "Checking stop: Removing stale lockfile:" fn_print_warn_eol_nl fn_script_log_warn "Checking stop: Removing stale lockfile" rm -f "${lockdir:?}/${selfname}-stopping.lock" @@ -100,9 +100,9 @@ fn_monitor_check_stopping() { fi if [ -f "${lockdir}/${selfname}-stopping.lock" ] && [[ "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} stop")" != "0" || "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} s")" != "0" ]]; then - fn_print_dots "Checking stop: " + fn_print_dots "Checking stop:" fn_print_checking_eol - fn_print_info "Checking stop: LinuxGSM is stopping: " + fn_print_info "Checking stop: LinuxGSM is stopping:" fn_print_info_eol_nl fn_script_log_info "Checking backup: LinuxGSM is stopping" core_exit.sh @@ -113,9 +113,9 @@ fn_monitor_check_backup() { # Remove stale lockfile. if [ -f "${lockdir}/backup.lock" ]; then if [ "$(find "${lockdir}/backup.lock" -mmin +60)" ]; then - fn_print_dots "Checking backup: " + fn_print_dots "Checking backup:" fn_print_checking_eol - fn_print_warn "Checking backup: Removing stale lockfile: " + fn_print_warn "Checking backup: Removing stale lockfile:" fn_print_warn_eol fn_script_log_warn "Checking backup: Removing stale lockfile" rm -f "${lockdir:?}/backup.lock" @@ -123,9 +123,9 @@ fn_monitor_check_backup() { fi if [ -f "${lockdir}/backup.lock" ] && [[ "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} backup")" != "0" || "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} b")" != "0" ]]; then - fn_print_dots "Checking backup: " + fn_print_dots "Checking backup:" fn_print_checking_eol - fn_print_info "Checking backup: Backup is running: " + fn_print_info "Checking backup: Backup is running:" fn_print_info_eol_nl fn_script_log_info "Checking backup: Backup is running" core_exit.sh @@ -136,9 +136,9 @@ fn_monitor_check_update() { # Remove stale lockfile. if [ -f "${lockdir}/update.lock" ]; then if [ "$(find "${lockdir}/update.lock" -mmin +15)" ]; then - fn_print_dots "Checking update: " + fn_print_dots "Checking update:" fn_print_checking_eol - fn_print_warn "Checking update: Removing stale lockfile: " + fn_print_warn "Checking update: Removing stale lockfile:" fn_print_warn_eol_nl fn_script_log_warn "Checking update: Removing stale lockfile" rm -f "${lockdir:?}/update.lock" @@ -146,9 +146,9 @@ fn_monitor_check_update() { fi if [ -f "${lockdir}/update.lock" ] && [[ "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} update")" != "0" || "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} validate")" != "0" || "$(pgrep -fcx -u "${USER}" "/bin/bash ./${selfname} v")" != "0" || "$(pgrep -fc force-update "${USER}" "/bin/bash ./${selfname} fu")" != "0" ]]; then - fn_print_dots "Checking update: " + fn_print_dots "Checking update:" fn_print_checking_eol - fn_print_info "Checking update: LinuxGSM is updating the game server: " + fn_print_info "Checking update: LinuxGSM is updating the game server:" fn_print_info_eol_nl fn_script_log_pass "Checking update: LinuxGSM is updating the game server" core_exit.sh @@ -159,10 +159,10 @@ fn_monitor_check_update() { fn_monitor_check_update_source() { if [ -f "${consolelogdir}/${selfname}-console.log" ] && [ "${engine}" == "source" ]; then if grep -q "Your server needs to be restarted in order to receive the latest update." "${consolelogdir}/${selfname}-console.log"; then - fn_print_dots "Checking update: " + fn_print_dots "Checking update:" fn_print_checking_eol fn_script_log_info "Checking update: CHECKING" - fn_print_ok "Checking update: " + fn_print_ok "Checking update:" fn_print_ok_eol_nl fn_script_log_info "Checking update: ${selfname} has requested an update and needs to be restarted" alert="update-request" @@ -174,7 +174,7 @@ fn_monitor_check_update_source() { } fn_monitor_check_session() { - fn_print_dots "Checking session: " + fn_print_dots "Checking session" fn_print_checking_eol fn_script_log_info "Checking session: CHECKING" # Tmux session width and height needs to be reviewed as may no longer be required. @@ -182,7 +182,7 @@ fn_monitor_check_session() { sessionheight="23" # Check for PIDS with identical tmux sessions running. if [ "$(pgrep -fcx "tmux -L ${socketname} new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}")" -ge "2" ]; then - fn_print_error "Checking session: There are PIDS with identical tmux sessions running: " + fn_print_error "Checking session: There are PIDS with identical tmux sessions running:" fn_print_error_eol_nl fn_script_log_error "Checking session: ERROR" fn_script_log_error "Checking session: There are PIDS with identical tmux sessions running" @@ -192,7 +192,7 @@ fn_monitor_check_session() { core_exit.sh # Check for tmux pids with the same tmux session and socket names. This will reduce issues with migration to release v23.5.0. #4296 elif [ "$(pgrep -fc -u "${USER}" "tmux -L ${sessionname} new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}")" != "0" ]; then - fn_print_error "Checking session: PIDS with the same tmux session and socket names are running: " + fn_print_error "Checking session: PIDS with the same tmux session and socket names are running:" fn_print_error_eol_nl fn_script_log_error "Checking session: ERROR" fn_script_log_error "Checking session: PIDS with the same tmux session and socket names are running" @@ -202,7 +202,7 @@ fn_monitor_check_session() { core_exit.sh # Check for tmux pids that are using the old type of tmux session. This will reduce issues with migration to release v23.5.0. #4296 elif [ "$(pgrep -fc -u "${USER}" "tmux new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}")" != "0" ]; then - fn_print_error "Checking session: PIDS with old type tmux session are running: " + fn_print_error "Checking session: PIDS with old type tmux session are running:" fn_print_error_eol_nl fn_script_log_error "Checking session: ERROR" fn_script_log_error "Checking session: PIDS with old type tmux session are running" @@ -211,7 +211,7 @@ fn_monitor_check_session() { command_restart.sh core_exit.sh elif [ "${status}" != "0" ]; then - fn_print_ok "Checking session: " + fn_print_ok "Checking session" fn_print_ok_eol_nl fn_script_log_pass "Checking session: OK" # send LinuxGSM stats if monitor is OK. @@ -219,7 +219,7 @@ fn_monitor_check_session() { info_stats.sh fi else - fn_print_error "Checking session: " + fn_print_error "Checking session" fn_print_fail_eol_nl fn_script_log_fail "Checking session: FAIL" alert="monitor-session" @@ -233,7 +233,7 @@ fn_monitor_check_session() { # Monitor will check queryport is set before continuing. fn_monitor_check_queryport() { if [ -z "${queryport}" ] || [ "${queryport}" == "0" ]; then - fn_print_dots "Checking port: " + fn_print_dots "Checking port:" fn_print_checking_eol fn_script_log_info "Checking port: CHECKING" if [ -n "${rconenabled}" ] && [ "${rconenabled}" != "true" ] && [ "${shortname}" == "av" ]; then @@ -266,12 +266,12 @@ fn_monitor_query() { totalseconds=0 for queryattempt in {1..5}; do for queryip in "${queryips[@]}"; do - fn_print_dots "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}: " + fn_print_dots "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}" fn_print_querying_eol fn_script_log_info "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt} : QUERYING" # querydelay if [ "$(head -n 1 "${lockdir}/${selfname}-started.lock")" -gt "$(date "+%s" -d "${querydelay} mins ago")" ]; then - fn_print_ok "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: " + fn_print_ok "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}" fn_print_delay_eol_nl fn_script_log_info "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt} : DELAY" fn_script_log_info "Query bypassed: ${gameservername} started less than ${querydelay} minutes ago" @@ -293,7 +293,7 @@ fn_monitor_query() { if [ "${querystatus}" == "0" ]; then # Server query OK. - fn_print_ok "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}: " + fn_print_ok "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}" fn_print_ok_eol_nl fn_script_log_pass "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt} : OK" monitorpass=1 @@ -323,14 +323,14 @@ fn_monitor_query() { core_exit.sh else # Server query FAIL. - fn_print_fail "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}: " + fn_print_fail "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}" fn_print_fail_eol fn_script_log_warn "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt} : FAIL" # Monitor will try gamedig (if supported) for first 30s then gsquery before restarting. # gsquery will fail if longer than 60s if [ "${totalseconds}" -ge "59" ]; then # Monitor will FAIL if over 60s and trigger gane server reboot. - fn_print_fail "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}: " + fn_print_fail "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}" fn_print_fail_eol_nl fn_script_log_warn "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt} : FAIL" # Send alert if enabled. diff --git a/lgsm/modules/command_postdetails.sh b/lgsm/modules/command_postdetails.sh index 6626d51a7e..f9e93be4a0 100644 --- a/lgsm/modules/command_postdetails.sh +++ b/lgsm/modules/command_postdetails.sh @@ -6,20 +6,20 @@ # Description: Strips sensitive information out of Details output. commandname="POST-DETAILS" -commandaction="Posting details" +commandaction="Post Details" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set -posttarget="https://termbin.com" - -# source all of the modules defined in the details command. -info_messages.sh - fn_bad_postdetailslog() { fn_print_fail_nl "Unable to create temporary file ${postdetailslog}." core_exit.sh } +fn_print_header + +# source all of the modules defined in the details command. +info_messages.sh + # Remove any existing postdetails.log file. if [ -f "${postdetailslog}" ]; then rm -f "${postdetailslog:?}" @@ -68,7 +68,7 @@ pdurl="${link}" if [ "${firstcommandname}" == "POST-DETAILS" ]; then echo -e "" echo -e "Please share the following url for support: " - echo -e "${pdurl}" + echo -e "${italic}${pdurl}${default}" fi fn_script_log_info "${pdurl}" alerturl="${pdurl}" diff --git a/lgsm/modules/command_send.sh b/lgsm/modules/command_send.sh index e314527078..de021599d3 100644 --- a/lgsm/modules/command_send.sh +++ b/lgsm/modules/command_send.sh @@ -26,8 +26,8 @@ if [ "${status}" != "0" ]; then fi echo "" fn_print_dots "Sending command to console: \"${commandtosend}\"" - tmux -L "${socketname}" send-keys -t "${sessionname}" "${commandtosend}" ENTER fn_print_ok_nl "Sending command to console: \"${commandtosend}\"" + tmux -L "${socketname}" send-keys -t "${sessionname}" "${commandtosend}" ENTER fn_script_log_pass "Command \"${commandtosend}\" sent to console" else fn_print_error_nl "Server not running" diff --git a/lgsm/modules/command_skeleton.sh b/lgsm/modules/command_skeleton.sh index ca32610e9f..b9f51205af 100644 --- a/lgsm/modules/command_skeleton.sh +++ b/lgsm/modules/command_skeleton.sh @@ -16,7 +16,7 @@ check.sh # Find all directorys and create them in the skel directory find "${rootdir}" -type d -not \( -path ./skel -prune \) | cpio -pdvm skel 2> /dev/null exitcode=$? -if [ "${exitcode}" != 0 ]; then +if [ "${exitcode}" -ne 0 ]; then fn_print_fail_nl "Creating skeleton directory" fn_script_log_fail "Creating skeleton directory" else diff --git a/lgsm/modules/command_sponsor.sh b/lgsm/modules/command_sponsor.sh index e7aeeda957..1915aa3289 100755 --- a/lgsm/modules/command_sponsor.sh +++ b/lgsm/modules/command_sponsor.sh @@ -11,7 +11,7 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set fn_print_ascii_logo -echo -e "${lightyellow}Support LinuxGSM${default}" +echo -e "${bold}${lightyellow}Support LinuxGSM${default}" fn_messages_separator echo -e "" echo -e "Been using LinuxGSM?" diff --git a/lgsm/modules/command_start.sh b/lgsm/modules/command_start.sh index c2be7ed2f4..a4e07b44b3 100644 --- a/lgsm/modules/command_start.sh +++ b/lgsm/modules/command_start.sh @@ -127,12 +127,12 @@ fn_start_tmux() { echo -e "" echo -e " usermod -G tty $(whoami)" echo -e "" - echo -e "https://linuxgsm.com/tmux-op-perm" + echo -e "${italic}https://linuxgsm.com/tmux-op-perm" fn_script_log_info "https://linuxgsm.com/tmux-op-perm" else echo -e "No known fix currently. Please log an issue." fn_script_log_info "No known fix currently. Please log an issue." - echo -e "https://linuxgsm.com/support" + echo -e "${italic}https://linuxgsm.com/support" fn_script_log_info "https://linuxgsm.com/support" fi fi @@ -176,7 +176,7 @@ check.sh # If the server already started dont start again. if [ "${status}" != "0" ]; then fn_print_dots "${servername}" - fn_print_info_nl "${servername} is already running" + fn_print_skip_nl "${servername} is already running" fn_script_log_error "${servername} is already running" if [ -z "${exitbypass}" ]; then # Remove starting lockfile when command ends. diff --git a/lgsm/modules/command_stop.sh b/lgsm/modules/command_stop.sh index 84f5998cdd..f1edc35444 100644 --- a/lgsm/modules/command_stop.sh +++ b/lgsm/modules/command_stop.sh @@ -20,7 +20,7 @@ fn_stop_graceful_ctrlc() { for seconds in {1..30}; do check_status.sh if [ "${status}" == "0" ]; then - fn_print_ok "Graceful: CTRL+c: ${seconds}: " + fn_print_ok "Graceful: CTRL+c: ${seconds}" fn_print_ok_eol_nl fn_script_log_pass "Graceful: CTRL+c: OK: ${seconds} seconds" if [ "${statusalert}" == "on" ] && [ "${firstcommandname}" == "STOP" ]; then @@ -52,7 +52,7 @@ fn_stop_graceful_cmd() { for ((seconds = 1; seconds <= ${2}; seconds++)); do check_status.sh if [ "${status}" == "0" ]; then - fn_print_ok "Graceful: sending \"${1}\": ${seconds}: " + fn_print_ok "Graceful: sending \"${1}\": ${seconds}" fn_print_ok_eol_nl fn_script_log_pass "Graceful: sending \"${1}\": OK: ${seconds} seconds" if [ "${statusalert}" == "on" ] && [ "${firstcommandname}" == "STOP" ]; then @@ -85,7 +85,7 @@ fn_stop_graceful_goldsrc() { fn_sleep_time_1 fn_print_dots "Graceful: sending \"quit\": ${seconds}" done - fn_print_ok "Graceful: sending \"quit\": ${seconds}: " + fn_print_ok "Graceful: sending \"quit\": ${seconds}" fn_print_ok_eol_nl fn_script_log_pass "Graceful: sending \"quit\": OK: ${seconds} seconds" if [ "${statusalert}" == "on" ] && [ "${firstcommandname}" == "STOP" ]; then @@ -297,7 +297,7 @@ fn_stop_graceful_avorion() { for seconds in {1..30}; do check_status.sh if [ "${status}" == "0" ]; then - fn_print_ok "Graceful: /save /stop: ${seconds}: " + fn_print_ok "Graceful: /save /stop: ${seconds}" fn_print_ok_eol_nl fn_script_log_pass "Graceful: /save /stop: OK: ${seconds} seconds" if [ "${statusalert}" == "on" ] && [ "${firstcommandname}" == "STOP" ]; then @@ -370,7 +370,7 @@ fn_stop_tmux() { # Checks if the server is already stopped. fn_stop_pre_check() { if [ "${status}" == "0" ]; then - fn_print_info_nl "${servername} is already stopped" + fn_print_skip_nl "${servername} is already stopped" fn_script_log_info "${servername} is already stopped" else # Select graceful shutdown. diff --git a/lgsm/modules/command_ts3_server_pass.sh b/lgsm/modules/command_ts3_server_pass.sh index 807d025b7c..f5fad684e8 100644 --- a/lgsm/modules/command_ts3_server_pass.sh +++ b/lgsm/modules/command_ts3_server_pass.sh @@ -6,7 +6,7 @@ # Description: Changes TS3 serveradmin password. commandname="CHANGE-PASSWORD" -commandaction="Changing password" +commandaction="Changing Password" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set diff --git a/lgsm/modules/command_update_linuxgsm.sh b/lgsm/modules/command_update_linuxgsm.sh index eb4226ab88..3299be5094 100644 --- a/lgsm/modules/command_update_linuxgsm.sh +++ b/lgsm/modules/command_update_linuxgsm.sh @@ -27,10 +27,11 @@ fn_script_log_info "Selecting repo" # Select remotereponame curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null - -if [ $? != "0" ]; then - curl curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null - if [ $? != "0" ]; then +exitcode=$? +if [ "${exitcode}" -ne "0" ]; then + curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null + exitcode=$? + if [ "${exitcode}" -ne "0" ]; then fn_print_fail_nl "Selecting repo: Unable to to access GitHub or Bitbucket repositories" fn_script_log_fail "Selecting repo: Unable to to access GitHub or Bitbucket repositories" core_exit.sh @@ -44,16 +45,17 @@ else fi # Check linuxsm.sh -echo -en "checking ${remotereponame} linuxgsm.sh...\c" +echo -en "checking ${remotereponame} script [ ${italic}linuxgsm.sh${default} ]\c" if [ "${remotereponame}" == "GitHub" ]; then curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh" 1> /dev/null else curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/linuxgsm.sh" 1> /dev/null fi -if [ $? != "0" ]; then +exitcode=$? +if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Checking ${remotereponame} linuxgsm.sh" - fn_script_log_fail "Curl returned error: $?" + fn_script_log_fail "Curl returned error: ${exitcode}" core_exit.sh fi @@ -65,41 +67,42 @@ fi if [ "${tmp_script_diff}" != "" ]; then fn_print_update_eol_nl - fn_script_log_update "Checking ${remotereponame} linuxgsm.sh" + fn_script_log "Checking ${remotereponame} script linuxgsm.sh" rm -f "${tmpdir:?}/linuxgsm.sh" fn_fetch_file_github "" "linuxgsm.sh" "${tmpdir}" "nochmodx" "norun" "noforcedl" "nohash" else - fn_print_ok_eol_nl - fn_script_log_pass "Checking ${remotereponame} linuxgsm.sh" + fn_print_skip_eol_nl + fn_script_log_pass "Checking ${remotereponame} script linuxgsm.sh" fi # Check gameserver.sh # Compare gameserver.sh against linuxgsm.sh in the tmp dir. # Ignoring server specific vars. -echo -en "checking ${selfname}...\c" +echo -en "checking script [ ${italic}${selfname}${default} ]\c" fn_script_log_info "Checking ${selfname}" script_diff=$(diff <(sed '\/shortname/d;\/gameservername/d;\/gamename/d;\/githubuser/d;\/githubrepo/d;\/githubbranch/d' "${tmpdir}/linuxgsm.sh") <(sed '\/shortname/d;\/gameservername/d;\/gamename/d;\/githubuser/d;\/githubrepo/d;\/githubbranch/d' "${rootdir}/${selfname}")) if [ "${script_diff}" != "" ]; then fn_print_update_eol_nl - fn_script_log_update "Checking ${selfname}" - echo -en "backup ${selfname}...\c" - fn_script_log_info "Backup ${selfname}" + fn_script_log "Checking script ${selfname}" + echo -en "backup ${selfname}\c" + fn_script_log_info "Backup script ${selfname}" if [ ! -d "${backupdir}/script" ]; then mkdir -p "${backupdir}/script" fi cp "${rootdir}/${selfname}" "${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak" - if [ $? != 0 ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Backup ${selfname}" core_exit.sh else fn_print_ok_eol_nl - fn_script_log_pass "Backup ${selfname}" - echo -e "backup location ${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak" + fn_script_log_pass "Backup script${selfname}" + echo -e "backup location [ ${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak ]" fn_script_log_pass "Backup location ${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak" fi - echo -en "copying ${selfname}...\c" + echo -en "copying ${selfname}" fn_script_log_info "Copying ${selfname}" cp "${tmpdir}/linuxgsm.sh" "${rootdir}/${selfname}" sed -i "s+shortname=\"core\"+shortname=\"${shortname}\"+g" "${rootdir}/${selfname}" @@ -109,7 +112,8 @@ if [ "${script_diff}" != "" ]; then sed -i "s+githubrepo=\"LinuxGSM\"+githubrepo=\"${githubrepo}\"+g" "${rootdir}/${selfname}" sed -i "s+githubbranch=\"master\"+githubbranch=\"${githubbranch}\"+g" "${rootdir}/${selfname}" - if [ $? != "0" ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "copying ${selfname}" core_exit.sh @@ -118,22 +122,23 @@ if [ "${script_diff}" != "" ]; then fn_script_log_pass "copying ${selfname}" fi else - fn_print_ok_eol_nl + fn_print_skip_eol_nl fn_script_log_info "Checking ${selfname}" fi # Check _default.cfg. -echo -en "checking ${remotereponame} config _default.cfg...\c" +echo -en "checking ${remotereponame} config [ ${italic}_default.cfg${default} ]\c" fn_script_log_info "Checking ${remotereponame} config _default.cfg" if [ "${remotereponame}" == "GitHub" ]; then curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg" 1> /dev/null else curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg" 1> /dev/null fi -if [ $? != "0" ]; then +exitcode=$? +if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Checking ${remotereponame} config _default.cfg" - fn_script_log_fail "Curl returned error: $?" + fn_script_log_fail "Curl returned error: ${exitcode}" core_exit.sh fi @@ -145,29 +150,30 @@ fi if [ "${config_file_diff}" != "" ]; then fn_print_update_eol_nl - fn_script_log_update "Checking ${remotereponame} config _default.cfg" + fn_script_log "Checking ${remotereponame} config _default.cfg" rm -f "${configdirdefault:?}/config-lgsm/${gameservername:?}/_default.cfg" fn_fetch_file_github "lgsm/config-default/config-lgsm/${gameservername}" "_default.cfg" "${configdirdefault}/config-lgsm/${gameservername}" "nochmodx" "norun" "noforce" "nohash" alert="config" alert.sh else - fn_print_ok_eol_nl + fn_print_skip_eol_nl fn_script_log_pass "Checking ${remotereponame} config _default.cfg" fi # Check distro csv. ${datadir}/${distroid}-${distroversioncsv}.csv if [ -f "${datadir}/${distroid}-${distroversioncsv}.csv" ]; then - echo -en "checking ${remotereponame} config ${distroid}-${distroversioncsv}.csv...\c" + echo -en "checking ${remotereponame} config [ ${italic}${distroid}-${distroversioncsv}.csv${default} ]\c" fn_script_log_info "Checking ${remotereponame} ${distroid}-${distroversioncsv}.csv" if [ "${remotereponame}" == "GitHub" ]; then curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv" 1> /dev/null else curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/lgsm/data/${distroid}-${distroversioncsv}.csv" 1> /dev/null fi - if [ $? != "0" ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Checking ${remotereponame} ${distroid}-${distroversioncsv}.csv" - fn_script_log_fail "Curl returned error: $?" + fn_script_log_fail "Curl returned error: ${exitcode}" core_exit.sh fi @@ -179,11 +185,11 @@ if [ -f "${datadir}/${distroid}-${distroversioncsv}.csv" ]; then if [ "${config_file_diff}" != "" ]; then fn_print_update_eol_nl - fn_script_log_update "Checking ${remotereponame} ${distroid}-${distroversioncsv}.csv" + fn_script_log "Checking ${remotereponame} ${distroid}-${distroversioncsv}.csv" rm -f "${datadir:?}/${distroid}-${distroversioncsv}.csv" fn_fetch_file_github "${datadir}" "${distroid}-${distroversioncsv}.csv" "${datadir}" "nochmodx" "norun" "noforce" "nohash" else - fn_print_ok_eol_nl + fn_print_skip_eol_nl fn_script_log_pass "Checking ${remotereponame} ${distroid}-${distroversioncsv}.csv" fi fi @@ -195,14 +201,15 @@ if [ -n "${modulesdir}" ]; then for modulefile in *; do # check if module exists in the repo and remove if missing. # commonly used if module names change. - echo -en "checking ${remotereponame} module ${modulefile}...\c" + echo -en "checking ${remotereponame} module [ ${italic}${modulefile}${default} ]\c" github_file_url_dir="lgsm/modules" if [ "${remotereponame}" == "GitHub" ]; then curl ${nocache} --connect-timeout 3 -IsfL "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${modulefile}" 1> /dev/null else curl ${nocache} --connect-timeout 3 -IsfL "https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${modulefile}" 1> /dev/null fi - if [ $? != 0 ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_print_error_eol_nl fn_script_log_error "Checking ${remotereponame} module ${modulefile}" echo -en "removing module ${modulefile}...\c" @@ -225,11 +232,11 @@ if [ -n "${modulesdir}" ]; then # results if [ "${module_file_diff}" != "" ]; then fn_print_update_eol_nl - fn_script_log_update "Checking ${remotereponame} module ${modulefile}" + fn_script_log "Checking ${remotereponame} module ${modulefile}" rm -rf "${modulesdir:?}/${modulefile}" fn_update_module else - fn_print_ok_eol_nl + fn_print_skip_eol_nl fn_script_log_pass "Checking ${remotereponame} module ${modulefile}" fi fi diff --git a/lgsm/modules/command_validate.sh b/lgsm/modules/command_validate.sh index e35749924b..30c20e96ea 100644 --- a/lgsm/modules/command_validate.sh +++ b/lgsm/modules/command_validate.sh @@ -11,18 +11,18 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set fn_validate() { - fn_print_warn "Validate might overwrite some customised files" + fn_print_warn ": SteamCMD: Validate might overwrite some customised files" fn_script_log_warn "${commandaction} server: Validate might overwrite some customised files" totalseconds=3 for seconds in {3..1}; do - fn_print_warn "Validate might overwrite some customised files: ${totalseconds}" + fn_print_warn ": SteamCMD: Validate might overwrite some customised files: ${totalseconds}" totalseconds=$((totalseconds - 1)) fn_sleep_time_1 if [ "${seconds}" == "0" ]; then break fi done - fn_print_warn_nl "Validate might overwrite some customised files" + fn_print_warn_nl ": SteamCMD: Validate might overwrite some customised files" date '+%s' > "${lockdir:?}/update.lock" fn_dl_steamcmd } diff --git a/lgsm/modules/command_wipe.sh b/lgsm/modules/command_wipe.sh index daf9270e6c..21023d17db 100644 --- a/lgsm/modules/command_wipe.sh +++ b/lgsm/modules/command_wipe.sh @@ -13,7 +13,7 @@ fn_firstcommand_set # Provides an exit code upon error. fn_wipe_exit_code() { exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl core_exit.sh else @@ -29,14 +29,14 @@ fn_wipe_files() { # Remove Map files if [ -n "${serverwipe}" ] || [ -n "${mapwipe}" ]; then if [ -n "$(find "${serveridentitydir}" -type f -name "*.map")" ]; then - echo -en "removing .map file(s)..." + fn_print "removing .map file(s)..." fn_script_log_info "Removing *.map file(s)" fn_sleep_time find "${serveridentitydir:?}" -type f -name "*.map" -printf "%f\n" >> "${lgsmlog}" find "${serveridentitydir:?}" -type f -name "*.map" -delete | tee -a "${lgsmlog}" fn_wipe_exit_code else - echo -e "no .map file(s) to remove" + fn_print_nl "no .map file(s) to remove" fn_sleep_time fn_script_log_pass "no .map file(s) to remove" fi @@ -44,14 +44,14 @@ fn_wipe_files() { # Remove Save files. if [ -n "${serverwipe}" ] || [ -n "${mapwipe}" ]; then if [ -n "$(find "${serveridentitydir}" -type f -name "*.sav*")" ]; then - echo -en "removing .sav file(s)..." + fn_print "removing .sav file(s)..." fn_script_log_info "Removing .sav file(s)" fn_sleep_time find "${serveridentitydir:?}" -type f -name "*.sav*" -printf "%f\n" >> "${lgsmlog}" find "${serveridentitydir:?}" -type f -name "*.sav*" -delete fn_wipe_exit_code else - echo -e "no .sav file(s) to remove" + fn_print_nl "no .sav file(s) to remove" fn_script_log_pass "no .sav file(s) to remove" fn_sleep_time fi @@ -60,14 +60,14 @@ fn_wipe_files() { # Excluding player.tokens.db for Rust+. if [ -n "${serverwipe}" ]; then if [ -n "$(find "${serveridentitydir}" -type f ! -name 'player.tokens.db' -name "*.db")" ]; then - echo -en "removing .db file(s)..." + fn_print "removing .db file(s)..." fn_script_log_info "Removing .db file(s)" fn_sleep_time find "${serveridentitydir:?}" -type f ! -name 'player.tokens.db' -name "*.db" -printf "%f\n" >> "${lgsmlog}" find "${serveridentitydir:?}" -type f ! -name 'player.tokens.db' -name "*.db" -delete fn_wipe_exit_code else - echo -e "no .db file(s) to remove" + fn_print_nl "no .db file(s) to remove" fn_sleep_time fn_script_log_pass "no .db file(s) to remove" fi @@ -104,13 +104,13 @@ fn_full_wipe_warning() { fn_print_warn_nl "Server wipe will reset the map data and remove blueprint data" } -# Will change the seed if the seed is not defined by the user. +# If the seed is not defined by the user, generate a seed file. fn_wipe_random_seed() { if [ -f "${datadir}/${selfname}-seed.txt" ] && [ -n "${randomseed}" ]; then shuf -i 1-2147483647 -n 1 > "${datadir}/${selfname}-seed.txt" seed=$(cat "${datadir}/${selfname}-seed.txt") randomseed=1 - echo -en "generating new random seed (${cyan}${seed}${default})..." + fn_print "generating new random seed (${cyan}${seed}${default})..." fn_script_log_pass "Generating new random seed (${cyan}${seed}${default})" fn_sleep_time fn_print_ok_eol_nl @@ -120,21 +120,21 @@ fn_wipe_random_seed() { # A summary of what wipe is going to do. fn_wipe_details() { fn_print_information_nl "Wipe does not remove Rust+ data." - echo -en "* Wipe map data: " + fn_print "* Wipe map data " if [ -n "${serverwipe}" ] || [ -n "${mapwipe}" ]; then fn_print_yes_eol_nl else fn_print_no_eol_nl fi - echo -en "* Wipe blueprint data: " + fn_print "* Wipe blueprint data " if [ -n "${serverwipe}" ]; then fn_print_yes_eol_nl else fn_print_no_eol_nl fi - echo -en "* Change Procedural Map seed: " + fn_print "* Change Procedural Map seed " if [ -n "${randomseed}" ]; then fn_print_yes_eol_nl else @@ -142,10 +142,9 @@ fn_wipe_details() { fi } -fn_print_dots "" check.sh fix_rust.sh - +fn_print_dots "" # Check if there is something to wipe. if [ -n "$(find "${serveridentitydir}" -type f -name "*.map")" ] || [ -n "$(find "${serveridentitydir}" -type f -name "*.sav*")" ] && [ -n "$(find "${serveridentitydir}" -type f ! -name 'player.tokens.db' -name "*.db")" ]; then if [ -n "${serverwipe}" ]; then @@ -165,7 +164,7 @@ if [ -n "$(find "${serveridentitydir}" -type f -name "*.map")" ] || [ -n "$(find fn_firstcommand_reset fn_wipe_files fn_wipe_random_seed - fn_print_complete_nl "${wipetype}" + fn_print_success_nl "${wipetype}" fn_script_log_pass "${wipetype}" alert="wipe" alert.sh @@ -175,7 +174,7 @@ if [ -n "$(find "${serveridentitydir}" -type f -name "*.map")" ] || [ -n "$(find else fn_wipe_files fn_wipe_random_seed - fn_print_complete_nl "${wipetype}" + fn_print_success_nl "${wipetype}" fn_script_log_pass "${wipetype}" alert="wipe" alert.sh diff --git a/lgsm/modules/compress_unreal2_maps.sh b/lgsm/modules/compress_unreal2_maps.sh index 4469aca40b..58824cbc73 100644 --- a/lgsm/modules/compress_unreal2_maps.sh +++ b/lgsm/modules/compress_unreal2_maps.sh @@ -6,7 +6,7 @@ # Description: Compresses unreal maps. commandname="MAP-COMPRESSOR" -commandaction="Compressing maps" +commandaction="Compressing Maps" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set diff --git a/lgsm/modules/compress_ut99_maps.sh b/lgsm/modules/compress_ut99_maps.sh index 23a93b3b73..885c32d9aa 100644 --- a/lgsm/modules/compress_ut99_maps.sh +++ b/lgsm/modules/compress_ut99_maps.sh @@ -6,7 +6,7 @@ # Description: Compresses unreal maps. commandname="MAP-COMPRESSOR" -commandaction="Compressing maps" +commandaction="Compressing Maps" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set diff --git a/lgsm/modules/core_dl.sh b/lgsm/modules/core_dl.sh index 68d0cf576f..72d50d69a0 100644 --- a/lgsm/modules/core_dl.sh +++ b/lgsm/modules/core_dl.sh @@ -20,6 +20,7 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_dl_steamcmd() { + remotelocation="SteamCMD" fn_print_start_nl "${remotelocation}" fn_script_log_info "${commandaction} ${selfname}: ${remotelocation}" if [ -n "${branch}" ]; then @@ -53,7 +54,7 @@ fn_dl_steamcmd() { rm -f "${steamcmdlog:?}" fi counter=0 - while [ "${counter}" == "0" ] || [ "${exitcode}" != "0" ]; do + while [ "${counter}" -eq 0 ] || [ "${exitcode}" -ne 0 ]; do counter=$((counter + 1)) # Select SteamCMD parameters # If GoldSrc (appid 90) servers. GoldSrc (appid 90) require extra commands. @@ -129,14 +130,14 @@ fn_dl_steamcmd() { fn_script_log_error "${commandaction} ${selfname}: ${remotelocation}: Missing update files" else fn_print_error2_nl "${commandaction} ${selfname}: ${remotelocation}: Unknown error occured" - echo -en "Please provide content log to LinuxGSM developers https://linuxgsm.com/steamcmd-error" + fn_print_nl "Please provide content log to LinuxGSM developers https://linuxgsm.com/steamcmd-error" fn_script_log_error "${commandaction} ${selfname}: ${remotelocation}: Unknown error occured" fi - elif [ "${exitcode}" != 0 ]; then + elif [ "${exitcode}" -ne 0 ]; then fn_print_error2_nl "${commandaction} ${selfname}: ${remotelocation}: Exit code: ${exitcode}" fn_script_log_error "${commandaction} ${selfname}: ${remotelocation}: Exit code: ${exitcode}" else - fn_print_complete_nl "${commandaction} ${selfname}: ${remotelocation}" + fn_print_success_nl "${commandaction} ${selfname}: ${remotelocation}" fn_script_log_pass "${commandaction} ${selfname}: ${remotelocation}" fi @@ -150,16 +151,16 @@ fn_dl_steamcmd() { # Emptys contents of the LinuxGSM tmpdir. fn_clear_tmp() { - echo -en "clearing LinuxGSM tmp directory..." + echo -en "clearing tmp directory [ ${italic}${tmpdir}${default} ]" if [ -d "${tmpdir}" ]; then rm -rf "${tmpdir:?}/"* - local exitcode=$? - if [ "${exitcode}" != 0 ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_print_error_eol_nl - fn_script_log_error "clearing LinuxGSM tmp directory" + fn_script_log_error "clearing tmp directory ${tmpdir}" else fn_print_ok_eol_nl - fn_script_log_pass "clearing LinuxGSM tmp directory" + fn_script_log_pass "clearing tmp directory ${tmpdir}" fi fi } @@ -259,8 +260,8 @@ fn_dl_extract() { extractcmd=$(unzip -qo -d "${extractdest}" "${local_filedir}/${local_filename}") fi fi - local exitcode=$? - if [ "${exitcode}" != 0 ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Extracting ${local_filename}" if [ -f "${lgsmlog}" ]; then @@ -277,11 +278,11 @@ fn_dl_extract() { # Trap to remove file download if canceled before completed. fn_fetch_trap() { echo -e "" - echo -en "downloading ${local_filename}..." + echo -en "downloading ${local_filename}" fn_print_canceled_eol_nl fn_script_log_info "Downloading ${local_filename}...CANCELED" rm -f "${local_filedir:?}/${local_filename}" - echo -en "downloading ${local_filename}..." + echo -en "downloading ${local_filename}" fn_print_removed_eol_nl fn_script_log_info "Downloading ${local_filename}...REMOVED" core_exit.sh @@ -313,12 +314,12 @@ fn_check_file() { fileurl_name="${remote_fileurl_backup_name}" fi counter=$((counter + 1)) - echo -en "checking ${fileurl_name} ${remote_filename}...\c" + echo -e "checking ${fileurl_name} ${remote_filename}\c" curlcmd=$(curl --output /dev/null --silent --head --fail "${fileurl}" 2>&1) - local exitcode=$? + exitcode=$? # On first try will error. On second try will fail. - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then if [ ${counter} -ge 2 ]; then fn_print_fail_eol_nl if [ -f "${lgsmlog}" ]; then @@ -379,6 +380,7 @@ fn_fetch_file() { counter=1 remote_fileurls_array=(remote_fileurl) fi + for remote_fileurl_array in "${remote_fileurls_array[@]}"; do if [ "${remote_fileurl_array}" == "remote_fileurl" ]; then fileurl="${remote_fileurl}" @@ -399,15 +401,15 @@ fn_fetch_file() { local exitcode="" large_files=("bz2" "gz" "zip" "jar" "xz") if grep -qE "(^|\s)${local_filename##*.}(\s|$)" <<< "${large_files[@]}"; then - echo -en "downloading ${local_filename}..." + echo -e "downloading file [ ${italic}${local_filename}${default} ]" fn_sleep_time - echo -en "\033[1K" "${curlcmd[@]}" --progress-bar "${fileurl}" 2>&1 - exitcode="$?" + exitcode=$? + echo -en "downloading file [ ${italic}${local_filename}${default} ]" else - echo -en "fetching ${fileurl_name} ${local_filename}...\c" + echo -en "fetching ${fileurl_name} [ ${italic}${local_filename}${default} ]\c" "${curlcmd[@]}" --silent --show-error "${fileurl}" 2>&1 - exitcode="$?" + exitcode=$? fi # Download will fail if downloads a html file. @@ -419,7 +421,7 @@ fn_fetch_file() { fi # On first try will error. On second try will fail. - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then if [ ${counter} -ge 2 ]; then fn_print_fail_eol_nl if [ -f "${lgsmlog}" ]; then diff --git a/lgsm/modules/core_exit.sh b/lgsm/modules/core_exit.sh index fd76454629..5f55dfcd1b 100644 --- a/lgsm/modules/core_exit.sh +++ b/lgsm/modules/core_exit.sh @@ -27,14 +27,14 @@ fi if [ "${exitbypass}" ]; then unset exitbypass -elif [ "${exitcode}" != "0" ]; then +elif [ "${exitcode}" -ne 0 ]; then # List LinuxGSM version in logs fn_script_log_info "LinuxGSM version: ${version}" - if [ "${exitcode}" == "1" ]; then + if [ "${exitcode}" -eq 1 ]; then fn_script_log_fail "${moduleselfname} exiting with code: ${exitcode}" - elif [ "${exitcode}" == "2" ]; then + elif [ "${exitcode}" -eq 2 ]; then fn_script_log_error "${moduleselfname} exiting with code: ${exitcode}" - elif [ "${exitcode}" == "3" ]; then + elif [ "${exitcode}" -eq 3 ]; then fn_script_log_warn "${moduleselfname} exiting with code: ${exitcode}" else # if exit code is not set assume error. @@ -45,7 +45,7 @@ elif [ "${exitcode}" != "0" ]; then # remove trap. trap - INT exit "${exitcode}" -elif [ "${exitcode}" ] && [ "${exitcode}" == "0" ]; then +elif [ "${exitcode}" ] && [ "${exitcode}" -eq 0 ]; then # List LinuxGSM version in logs fn_script_log_info "LinuxGSM version: ${version}" fn_script_log_pass "${moduleselfname} exiting with code: ${exitcode}" diff --git a/lgsm/modules/core_getopt.sh b/lgsm/modules/core_getopt.sh index 688dcdc9c9..9a5704663e 100644 --- a/lgsm/modules/core_getopt.sh +++ b/lgsm/modules/core_getopt.sh @@ -56,6 +56,7 @@ cmd_dev_detect_deps=("dd;detect-deps" "command_dev_detect_deps.sh" "Detect requi cmd_dev_detect_glibc=("dg;detect-glibc" "command_dev_detect_glibc.sh" "Detect required glibc.") cmd_dev_detect_ldd=("dl;detect-ldd" "command_dev_detect_ldd.sh" "Detect required dynamic dependencies.") cmd_dev_query_raw=("qr;query-raw" "command_dev_query_raw.sh" "The raw output of gamedig and gsquery.") +cmd_dev_ui=("ui;ui" "command_dev_ui.sh" "Assist with UI development.") cmd_dev_clear_modules=("cm;clear-modules" "command_dev_clear_modules.sh" "Delete the contents of the modules dir.") ### Set specific opt here. @@ -147,7 +148,7 @@ currentopt+=("${cmd_install[@]}" "${cmd_auto_install[@]}") ## Developer commands. currentopt+=("${cmd_dev_debug[@]}") if [ -f ".dev-debug" ]; then - currentopt+=("${cmd_dev_parse_game_details[@]}" "${cmd_dev_parse_distro_details[@]}" "${cmd_dev_detect_deps[@]}" "${cmd_dev_detect_glibc[@]}" "${cmd_dev_detect_ldd[@]}" "${cmd_dev_query_raw[@]}" "${cmd_dev_clear_modules[@]}") + currentopt+=("${cmd_dev_parse_game_details[@]}" "${cmd_dev_parse_distro_details[@]}" "${cmd_dev_detect_deps[@]}" "${cmd_dev_detect_glibc[@]}" "${cmd_dev_detect_ldd[@]}" "${cmd_dev_query_raw[@]}" "${cmd_dev_ui[@]}" "${cmd_dev_clear_modules[@]}") fi ## Sponsor. @@ -165,19 +166,19 @@ done # Shows LinuxGSM usage. fn_opt_usage() { - echo -e "Usage: $0 [option]" - echo -e "" - echo -e "LinuxGSM - ${gamename} - Version ${version}" - echo -e "https://linuxgsm.com/${gameservername}" - echo -e "" - echo -e "${lightyellow}Commands${default}" + fn_print_nl "Usage: $0 [option]" + fn_print_nl "" + fn_print_nl "LinuxGSM - ${gamename} - Version ${version}" + fn_print_nl "https://linuxgsm.com/${gameservername}" + fn_print_nl "" + fn_print_nl "${bold}${lightyellow}Commands${default}" # Display available commands. index="0" { for ((index = "0"; index < ${#currentopt[@]}; index += 3)); do # Hide developer commands. if [ "${currentopt[index + 2]}" != "DEVCOMMAND" ]; then - echo -e "${cyan}$(echo -e "${currentopt[index]}" | awk -F ';' '{ print $2 }')\t${default}$(echo -e "${currentopt[index]}" | awk -F ';' '{ print $1 }')\t| ${currentopt[index + 2]}" + fn_print_nl "${cyan}$(echo -e "${currentopt[index]}" | awk -F ';' '{ print $2 }')\t${default}$(echo -e "${currentopt[index]}" | awk -F ';' '{ print $1 }')\t| ${currentopt[index + 2]}" fi done } | column -s $'\t' -t diff --git a/lgsm/modules/core_messages.sh b/lgsm/modules/core_messages.sh index 80ef293d8b..37c2e98b5d 100644 --- a/lgsm/modules/core_messages.sh +++ b/lgsm/modules/core_messages.sh @@ -34,6 +34,14 @@ fn_ansi_loader() { # erase to end of line. creeol+="\033[K" fi + # carriage return & erase to end of line. + creeol="\r\033[K" + + bold="\e[1m" + dim="\e[2m" + italic="\e[3m" + underline="\e[4m" + reverse="\e[7m" } fn_sleep_time() { @@ -71,216 +79,141 @@ fn_script_log() { ## Feb 28 14:56:58 ut99-server: Monitor: PASS: fn_script_log_pass() { - if [ -d "${lgsmlogdir}" ]; then - - if [ -n "${commandname}" ]; then - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandname}: PASS: ${1}" >> "${lgsmlog}" - else - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: PASS: ${1}" >> "${lgsmlog}" - fi - fi + fn_script_log "PASS: ${1}" exitcode=0 } ## Feb 28 14:56:58 ut99-server: Monitor: FATAL: fn_script_log_fail() { - if [ -d "${lgsmlogdir}" ]; then - if [ -n "${commandname}" ]; then - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandname}: FATAL: ${1}" >> "${lgsmlog}" - else - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: FATAL: ${1}" >> "${lgsmlog}" - fi - fi + fn_script_log "FAIL: ${1}" exitcode=1 } ## Feb 28 14:56:58 ut99-server: Monitor: ERROR: fn_script_log_error() { - if [ -d "${lgsmlogdir}" ]; then - if [ -n "${commandname}" ]; then - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandname}: ERROR: ${1}" >> "${lgsmlog}" - else - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ERROR: ${1}" >> "${lgsmlog}" - fi - fi + fn_script_log "ERROR: ${1}" exitcode=2 } ## Feb 28 14:56:58 ut99-server: Monitor: WARN: fn_script_log_warn() { - if [ -d "${lgsmlogdir}" ]; then - if [ -n "${commandname}" ]; then - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandname}: WARN: ${1}" >> "${lgsmlog}" - else - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: WARN: ${1}" >> "${lgsmlog}" - fi - fi + fn_script_log "WARN: ${1}" exitcode=3 } ## Feb 28 14:56:58 ut99-server: Monitor: INFO: fn_script_log_info() { - if [ -d "${lgsmlogdir}" ]; then - if [ -n "${commandname}" ]; then - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandname}: INFO: ${1}" >> "${lgsmlog}" - else - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: INFO: ${1}" >> "${lgsmlog}" - fi - fi -} - -## Feb 28 14:56:58 ut99-server: Monitor: UPDATE: -fn_script_log_update() { - if [ -d "${lgsmlogdir}" ]; then - if [ -n "${commandname}" ]; then - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: ${commandname}: UPDATE: ${1}" >> "${lgsmlog}" - else - echo -e "$(date '+%b %d %H:%M:%S.%3N') ${selfname}: UPDATE: ${1}" >> "${lgsmlog}" - fi - fi + fn_script_log "INFO: ${1}" } # On-Screen - Automated functions ################################## -# [ .... ] -fn_print_dots() { +fn_print() { + echo -en "$*${default}" +} + +fn_print_nl() { + echo -e "$*${default}" +} + +# Helper function to print messages with a specific format and color +fn_print_message() { + local type="$1" + local color="$2" + local message="$3" if [ "${commandaction}" ]; then - echo -en "${creeol}[ .... ] ${commandaction} ${selfname}: $*" + echo -en "${bold}${creeol}[${color} ${type} ${default}]${default} ${commandaction} ${selfname}: ${message}${default}" else - echo -en "${creeol}[ .... ] $*" + echo -en "${bold}${cree}[${color} ${type} ${default}]${default} ${message}${default}" fi - fn_sleep_time_05 + fn_sleep_time } -fn_print_dots_nl() { +fn_print_message_nl() { + local type="$1" + local color="$2" + local message="$3" if [ "${commandaction}" ]; then - echo -e "${creeol}[ .... ] ${commandaction} ${selfname}: $*" + echo -e "${bold}${creeol}[${color} ${type} ${default}]${default} ${commandaction} ${selfname}: ${message}${default}" else - echo -e "${creeol}[ .... ] $*" + echo -e "${bold}${creeol}[${color} ${type} ${default}]${default} ${message}${default}" fi + fn_sleep_time +} + +# [ .... ] +fn_print_dots() { + fn_print_message "...." "${default}" "$*" + fn_sleep_time_05 +} + +fn_print_dots_nl() { + fn_print_message_nl "...." "${default}" "$*" fn_sleep_time_05 - echo -en "\n" } # [ OK ] fn_print_ok() { - if [ "${commandaction}" ]; then - echo -en "${creeol}[${green} OK ${default}] ${commandaction} ${selfname}: $*" - else - echo -en "${creeol}[${green} OK ${default}] $*" - fi - fn_sleep_time + fn_print_message " OK " "${green}" "$*" } fn_print_ok_nl() { - if [ "${commandaction}" ]; then - echo -en "${creeol}[${green} OK ${default}] ${commandaction} ${selfname}: $*" - else - echo -en "${creeol}[${green} OK ${default}] $*" - fi - fn_sleep_time - echo -en "\n" + fn_print_message_nl " OK " "${green}" "$*" } # [ FAIL ] fn_print_fail() { - if [ "${commandaction}" ]; then - echo -en "${creeol}[${red} FAIL ${default}] ${commandaction} ${selfname}: $*" - else - echo -en "${creeol}[${red} FAIL ${default}] $*" - fi - fn_sleep_time + fn_print_message "FAIL" "${red}" "$*" } fn_print_fail_nl() { - if [ "${commandaction}" ]; then - echo -en "${creeol}[${red} FAIL ${default}] ${commandaction} ${selfname}: $*" - else - echo -en "${creeol}[${red} FAIL ${default}] $*" - fi - fn_sleep_time - echo -en "\n" + fn_print_message_nl "FAIL" "${red}" "$*" } # [ ERROR ] fn_print_error() { - if [ "${commandaction}" ]; then - echo -en "${creeol}[${red} ERROR ${default}] ${commandaction} ${selfname}: $*" - else - echo -en "${creeol}[${red} ERROR ${default}] $*" - fi - fn_sleep_time + fn_print_message "ERROR" "${red}" "$*" } fn_print_error_nl() { - if [ "${commandaction}" ]; then - echo -en "${creeol}[${red} ERROR ${default}] ${commandaction} ${selfname}: $*" - else - echo -en "${creeol}[${red} ERROR ${default}] $*" - fi - fn_sleep_time - echo -en "\n" + fn_print_message_nl "ERROR" "${red}" "$*" } # [ WARN ] fn_print_warn() { - if [ "${commandaction}" ]; then - echo -en "${creeol}[${lightyellow} WARN ${default}] ${commandaction} ${selfname}: $*" - else - echo -en "${creeol}[${lightyellow} WARN ${default}] $*" - fi - fn_sleep_time + fn_print_message "WARN" "${lightyellow}" "$*" } fn_print_warn_nl() { - if [ "${commandaction}" ]; then - echo -en "${creeol}[${lightyellow} WARN ${default}] ${commandaction} ${selfname}: $*" - else - echo -en "${creeol}[${lightyellow} WARN ${default}] $*" - fi - fn_sleep_time - echo -en "\n" + fn_print_message_nl "WARN" "${lightyellow}" "$*" } # [ INFO ] fn_print_info() { - if [ "${commandaction}" ]; then - echo -en "${creeol}[${cyan} INFO ${default}] ${commandaction} ${selfname}: $*" - else - echo -en "${creeol}[${cyan} INFO ${default}] $*" - fi - fn_sleep_time + fn_print_message "INFO" "${cyan}" "$*" } fn_print_info_nl() { - if [ "${commandaction}" ]; then - echo -en "${creeol}[${cyan} INFO ${default}] ${commandaction} ${selfname}: $*" - else - echo -en "${creeol}[${cyan} INFO ${default}] $*" - fi - fn_sleep_time - echo -en "\n" + fn_print_message_nl "INFO" "${cyan}" "$*" +} + +# [ SKIP ] +fn_print_skip() { + fn_print_message "SKIP" "${cyan}" "$*" +} + +fn_print_skip_nl() { + fn_print_message_nl "SKIP" "${cyan}" "$*" } # [ START ] fn_print_start() { - if [ "${commandaction}" ]; then - echo -en "${creeol}[${lightgreen} START ${default}] ${commandaction} ${selfname}: $*" - else - echo -en "${creeol}[${lightgreen} START ${default}] $*" - fi - fn_sleep_time + fn_print_message "START" "${lightgreen}" "$*" } fn_print_start_nl() { - if [ "${commandaction}" ]; then - echo -en "${creeol}[${lightgreen} START ${default}] ${commandaction} ${selfname}: $*" - else - echo -en "${creeol}[${lightgreen} START ${default}] $*" - fi - fn_sleep_time - echo -en "\n" + fn_print_message_nl "START" "${lightgreen}" "$*" } # On-Screen - Interactive messages @@ -304,63 +237,75 @@ fn_print_header() { fn_messages_separator } -# Complete! -fn_print_complete() { - echo -en "${green}Complete!${default} $*" +# Success! +fn_print_success() { + echo -en "${green}Success!${default} $*${default}" fn_sleep_time } -fn_print_complete_nl() { - echo -e "${green}Complete!${default} $*" +fn_print_success_nl() { + echo -e "${green}Success!${default} $*${default}" fn_sleep_time } # Failure! fn_print_failure() { - echo -en "${red}Failure!${default} $*" + echo -en "${red}Failure!${default} $*${default}" fn_sleep_time } fn_print_failure_nl() { - echo -e "${red}Failure!${default} $*" + echo -e "${red}Failure!${default} $*${default}" fn_sleep_time } # Error! fn_print_error2() { - echo -en "${red}Error!${default} $*" + echo -en "${red}Error!${default} $*${default}" fn_sleep_time } fn_print_error2_nl() { - echo -e "${red}Error!${default} $*" + echo -e "${red}Error!${default} $*${default}" fn_sleep_time } # Warning! fn_print_warning() { - echo -en "${lightyellow}Warning!${default} $*" + echo -en "${lightyellow}Warning!${default} $*${default}" fn_sleep_time } fn_print_warning_nl() { - echo -e "${lightyellow}Warning!${default} $*" + echo -e "${lightyellow}Warning!${default} $*${default}" fn_sleep_time } # Information! fn_print_information() { - echo -en "${cyan}Information!${default} $*" + echo -en "${cyan}Information!${default} $*${default}" fn_sleep_time } fn_print_information_nl() { - echo -e "${cyan}Information!${default} $*" + echo -e "${cyan}Information!${default} $*${default}" + fn_sleep_time +} + +# Skip! +fn_print_skip2() { + echo -en "${cyan}Skip!${default} $*${default}" + fn_sleep_time +} + +fn_print_skip2_nl() { + echo -e "${cyan}Skip!${default} $*${default}" fn_sleep_time } # Y/N Prompt fn_prompt_yn() { + echo -e "" local prompt="$1" local initial="$2" @@ -400,155 +345,166 @@ fn_prompt_message() { # YES fn_print_yes_eol() { - echo -en "${cyan}YES${default}" + echo -en " ... ${cyan}YES${default}" fn_sleep_time } fn_print_yes_eol_nl() { - echo -e "${cyan}YES${default}" + echo -e " ... ${cyan}YES${default}" fn_sleep_time } # NO fn_print_no_eol() { - echo -en "${red}NO${default}" + echo -en " ... ${red}NO${default}" fn_sleep_time } fn_print_no_eol_nl() { - echo -e "${red}NO${default}" + echo -e " ... ${red}NO${default}" fn_sleep_time } # OK fn_print_ok_eol() { - echo -en "${green}OK${default}" + echo -en " ... ${green}OK${default}" fn_sleep_time } fn_print_ok_eol_nl() { - echo -e "${green}OK${default}" + echo -e " ... ${green}OK${default}" fn_sleep_time } # FAIL fn_print_fail_eol() { - echo -en "${red}FAIL${default}" + echo -en " ... ${red}FAIL${default}" fn_sleep_time } fn_print_fail_eol_nl() { - echo -e "${red}FAIL${default}" + echo -e " ... ${red}FAIL${default}" fn_sleep_time } # ERROR fn_print_error_eol() { - echo -en "${red}ERROR${default}" + echo -en " ... ${red}ERROR${default}" fn_sleep_time } fn_print_error_eol_nl() { - echo -e "${red}ERROR${default}" + echo -e " ... ${red}ERROR${default}" fn_sleep_time } # WAIT fn_print_wait_eol() { - echo -en "${cyan}WAIT${default}" + echo -en " ... ${cyan}WAIT${default}" fn_sleep_time } fn_print_wait_eol_nl() { - echo -e "${cyan}WAIT${default}" + echo -e " ... ${cyan}WAIT${default}" fn_sleep_time } # WARN fn_print_warn_eol() { - echo -en "${lightyellow}WARN${default}" + echo -en " ... ${lightyellow}WARN${default}" fn_sleep_time } fn_print_warn_eol_nl() { - echo -e "${lightyellow}WARN${default}" + echo -e " ... ${lightyellow}WARN${default}" fn_sleep_time } # INFO fn_print_info_eol() { - echo -en "${cyan}INFO${default}" + echo -en " ... ${cyan}INFO${default}" fn_sleep_time } fn_print_info_eol_nl() { - echo -e "${cyan}INFO${default}" + echo -e " ... ${cyan}INFO${default}" fn_sleep_time } # QUERYING fn_print_querying_eol() { - echo -en "${cyan}QUERYING${default}" + echo -en " ... ${cyan}QUERYING${default}" fn_sleep_time_1 } fn_print_querying_eol_nl() { - echo -e "${cyan}QUERYING${default}" + echo -e " ... ${cyan}QUERYING${default}" fn_sleep_time_1 } # CHECKING fn_print_checking_eol() { - echo -en "${cyan}CHECKING${default}" + echo -en " ... ${cyan}CHECKING${default}" fn_sleep_time_1 } fn_print_checking_eol_nl() { - echo -e "${cyan}CHECKING${default}" + echo -e " ... ${cyan}CHECKING${default}" fn_sleep_time_1 } # DELAY fn_print_delay_eol() { - echo -en "${green}DELAY${default}" + echo -en " ... ${green}DELAY${default}" fn_sleep_time_1 } fn_print_delay_eol_nl() { - echo -e "${green}DELAY${default}" + echo -e " ... ${green}DELAY${default}" fn_sleep_time_1 } # CANCELED fn_print_canceled_eol() { - echo -en "${lightyellow}CANCELED${default}" + echo -en " ... ${lightyellow}CANCELED${default}" fn_sleep_time_1 } fn_print_canceled_eol_nl() { - echo -e "${lightyellow}CANCELED${default}" + echo -e " ... ${lightyellow}CANCELED${default}" fn_sleep_time_1 } # REMOVED fn_print_removed_eol() { - echo -en "${red}REMOVED${default}" + echo -en " ... ${red}REMOVED${default}" fn_sleep_time_1 } fn_print_removed_eol_nl() { - echo -e "${red}REMOVED${default}" + echo -e " ... ${red}REMOVED${default}" fn_sleep_time_1 } # UPDATE fn_print_update_eol() { - echo -en "${cyan}UPDATE${default}" + echo -en " ... ${lightblue}UPDATE${default}" fn_sleep_time } fn_print_update_eol_nl() { - echo -e "${cyan}UPDATE${default}" + echo -e " ... ${lightblue}UPDATE${default}" + fn_sleep_time +} + +# SKIP +fn_print_skip_eol() { + echo -en " ... ${cyan}SKIP${default}" + fn_sleep_time +} + +fn_print_skip_eol_nl() { + echo -e " ... ${cyan}SKIP${default}" fn_sleep_time } diff --git a/lgsm/modules/core_modules.sh b/lgsm/modules/core_modules.sh index e4fa35b328..2371a550ca 100644 --- a/lgsm/modules/core_modules.sh +++ b/lgsm/modules/core_modules.sh @@ -42,6 +42,11 @@ core_legacy.sh() { core_exit.sh() { modulefile="${FUNCNAME[0]}" fn_fetch_module + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then + echo "fn_fetch_module failed, using fn_bootstrap_fetch_module instead." + fn_bootstrap_fetch_module + fi } core_getopt.sh() { @@ -324,6 +329,11 @@ command_dev_detect_ldd.sh() { fn_fetch_module } +command_dev_ui.sh() { + modulefile="${FUNCNAME[0]}" + fn_fetch_module +} + command_dev_query_raw.sh() { modulefile="${FUNCNAME[0]}" fn_fetch_module diff --git a/lgsm/modules/core_steamcmd.sh b/lgsm/modules/core_steamcmd.sh index e08c921dd5..5ee14a7428 100644 --- a/lgsm/modules/core_steamcmd.sh +++ b/lgsm/modules/core_steamcmd.sh @@ -23,7 +23,7 @@ fn_check_steamcmd_user() { # Checks if steamuser is setup. if [ "${steamuser}" == "username" ]; then fn_print_fail_nl "Steam login not set. Update steamuser in ${configdirserver}" - echo -e " * Change steamuser=\"username\" to a valid steam login." + fn_print_nl " * Change steamuser=\"username\" to a valid steam login." if [ -d "${lgsmlogdir}" ]; then fn_script_log_fail "Steam login not set. Update steamuser in ${configdirserver}" fi @@ -44,15 +44,16 @@ fn_check_steamcmd() { # Only install if steamcmd package is missing or steamcmd dir is missing. if [ ! -f "${steamcmddir}/steamcmd.sh" ] && [ -z "$(command -v steamcmd 2> /dev/null)" ]; then if [ "${commandname}" == "INSTALL" ]; then + fn_print_nl "install SteamCMD" fn_install_steamcmd else - fn_print_warn_nl "SteamCMD is missing" - fn_script_log_warn "SteamCMD is missing" + fn_print_warn_nl "SteamCMD is not installed" + fn_script_log_warn "SteamCMD is not installed" fn_install_steamcmd fi elif [ "${commandname}" == "INSTALL" ]; then - fn_print_information "SteamCMD is already installed..." - fn_print_ok_eol_nl + fn_print "install SteamCMD" + fn_print_skip_eol_nl fi } @@ -128,7 +129,7 @@ fn_check_steamcmd_clear() { if [ "$(command -v steamcmd 2> /dev/null)" ] && [ -d "${rootdir}/steamcmd" ]; then rm -rf "${steamcmddir:?}" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_script_log_fail "Removing ${rootdir}/steamcmd" else fn_script_log_pass "Removing ${rootdir}/steamcmd" @@ -213,18 +214,18 @@ fn_update_steamcmd_compare() { # Create update lockfile. date '+%s' > "${lockdir:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "Update available" - echo -e "* Local build: ${red}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}Update${default} available" + fn_print_nl "* Local build: ${red}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuildversion}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi if [ -n "${betapassword}" ]; then - echo -e "* Branch password: ${betapassword}" + fn_print_nl "* Branch password: ${betapassword}" fi - echo -e "https://steamdb.info/app/${appid}/" - echo -en "\n" + fn_print_nl "${italic}https://steamdb.info/app/${appid}/history" + fn_print "\n" fn_script_log_info "Update available" fn_script_log_info "Local build: ${localbuild}" fn_script_log_info "Remote build: ${remotebuildversion}" @@ -263,18 +264,18 @@ fn_update_steamcmd_compare() { alert.sh else fn_print_ok_nl "Checking for update: ${remotelocation}" - echo -en "\n" - echo -e "No update available" - echo -e "* Local build: ${green}${localbuild}${default}" - echo -e "* Remote build: ${green}${remotebuildversion}${default}" + fn_print "\n" + fn_print_nl "${bold}${underline}No update${default} available" + fn_print_nl "* Local build: ${green}${localbuild}${default}" + fn_print_nl "* Remote build: ${green}${remotebuildversion}${default}" if [ -n "${branch}" ]; then - echo -e "* Branch: ${branch}" + fn_print_nl "* Branch: ${branch}" fi if [ -n "${betapassword}" ]; then - echo -e "* Branch password: ${betapassword}" + fn_print_nl "* Branch password: ${betapassword}" fi - echo -e "https://steamdb.info/app/${appid}/" - echo -en "\n" + fn_print_nl "https://steamdb.info/app/${appid}/history" + fn_print "\n" fn_script_log_info "No update available" fn_script_log_info "Local build: ${localbuild}" fn_script_log_info "Remote build: ${remotebuildversion}" @@ -308,9 +309,9 @@ fn_check_steamcmd_appmanifest() { if [ "${appmanifestfilewc}" -ge "2" ]; then fn_print_fail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" fn_script_log_fail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" - echo -e "* Check user permissions" + fn_print_nl "* Check user permissions" for appfile in ${appmanifestfile}; do - echo -e " ${appfile}" + fn_print_nl " ${appfile}" done core_exit.sh else diff --git a/lgsm/modules/fix.sh b/lgsm/modules/fix.sh index f9628a3350..f31030779c 100644 --- a/lgsm/modules/fix.sh +++ b/lgsm/modules/fix.sh @@ -22,7 +22,8 @@ fn_fix_msg_start_nl() { } fn_fix_msg_end() { - if [ $? != 0 ]; then + exirtcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_print_error_nl "Applying ${fixname} fix: ${gamename}" fn_script_log_error "Applying ${fixname} fix: ${gamename}" else @@ -79,7 +80,7 @@ fi if [ "${commandname}" == "INSTALL" ]; then if grep -qEe "(^|\s)${shortname}(\s|$)" <<< "${apply_post_install_fix[@]}"; then echo -e "" - echo -e "${lightyellow}Applying Post-Install Fixes${default}" + echo -e "${bold}${lightyellow}Applying Post-Install Fixes${default}" fn_messages_separator postinstall=1 fn_apply_fix "post install" "${shortname}" diff --git a/lgsm/modules/fix_bt.sh b/lgsm/modules/fix_bt.sh index 51fc3d5054..107c844582 100755 --- a/lgsm/modules/fix_bt.sh +++ b/lgsm/modules/fix_bt.sh @@ -5,7 +5,7 @@ # Website: https://linuxgsm.com # Description: Resolves issues with Barotrauma. -module_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" # Fixes: Missing user data directory error. if [ ! -d "${XDG_DATA_HOME:="${HOME}/.local/share"}/Daedalic Entertainment GmbH/Barotrauma" ]; then diff --git a/lgsm/modules/fix_rust.sh b/lgsm/modules/fix_rust.sh index af995a2fa7..80c790a590 100644 --- a/lgsm/modules/fix_rust.sh +++ b/lgsm/modules/fix_rust.sh @@ -11,7 +11,7 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${serverfiles}:${serverfiles}/RustDedicated_Data/Plugins/x86_64" # Part of random seed feature. -# If seed is not defined by user generate a seed file. +# If the seed is not defined by the user, generate a seed file. if [ -z "${seed}" ] || [ "${seed}" == "0" ]; then if [ ! -f "${datadir}/${selfname}-seed.txt" ]; then shuf -i 1-2147483647 -n 1 > "${datadir}/${selfname}-seed.txt" diff --git a/lgsm/modules/info_distro.sh b/lgsm/modules/info_distro.sh index 0813554dcb..67a9fd5dfb 100644 --- a/lgsm/modules/info_distro.sh +++ b/lgsm/modules/info_distro.sh @@ -188,13 +188,10 @@ if [ "$(command -v numfmt 2> /dev/null)" ]; then else # Older distros will need to use free. # Older versions of free do not support -h option. - if [ "$( - free -h > /dev/null 2>&1 - echo $? - )" -ne "0" ]; then - humanreadable="-m" - else + if free -h > /dev/null 2>&1; then humanreadable="-h" + else + humanreadable="-m" fi physmemtotalmb="$(free -m | awk '/Mem:/ {print $2}')" # integer physmemtotalgb="$(free -m | awk '/Mem:/ {print $2}')" # integer diff --git a/lgsm/modules/info_messages.sh b/lgsm/modules/info_messages.sh index ff4b5d870e..91d78e6701 100644 --- a/lgsm/modules/info_messages.sh +++ b/lgsm/modules/info_messages.sh @@ -132,7 +132,7 @@ fn_info_messages_server_resource() { echo -e "${bold}${lightyellow}Server Resource${default}" fn_messages_separator { - echo -e "${lightyellow}CPU\t${default}" + echo -e "${bold}${lightyellow}CPU\t${default}" echo -e "${lightblue}Model:\t${default}${cpumodel}" echo -e "${lightblue}Cores:\t${default}${cpucores}" echo -e "${lightblue}Frequency:\t${default}${cpufreqency}MHz" @@ -140,14 +140,14 @@ fn_info_messages_server_resource() { } | column -s $'\t' -t echo -e "" { - echo -e "${lightyellow}Memory\t${default}" + echo -e "${bold}${lightyellow}Memory\t${default}" echo -e "${lightblue}Mem:\t${lightblue}total\tused\tfree\tcached\tavailable${default}" echo -e "${lightblue}Physical:\t${default}${physmemtotal}\t${physmemused}\t${physmemfree}\t${physmemcached}\t${physmemavailable}${default}" echo -e "${lightblue}Swap:\t${default}${swaptotal}\t${swapused}\t${swapfree}${default}" } | column -s $'\t' -t echo -e "" { - echo -e "${lightyellow}Storage${default}" + echo -e "${bold}${lightyellow}Storage${default}" echo -e "${lightblue}Filesystem:\t${default}${filesystem}" echo -e "${lightblue}Total:\t${default}${totalspace}" echo -e "${lightblue}Used:\t${default}${usedspace}" @@ -155,7 +155,7 @@ fn_info_messages_server_resource() { } | column -s $'\t' -t echo -e "" { - echo -e "${lightyellow}Network${default}" + echo -e "${bold}${lightyellow}Network${default}" if [ -n "${netint}" ]; then echo -e "${lightblue}Interface:\t${default}${netint}" fi @@ -203,7 +203,7 @@ fn_info_messages_gameserver_resource() { } | column -s $'\t' -t echo -e "" { - echo -e "${lightyellow}Storage${default}" + echo -e "${bold}${lightyellow}Storage${default}" echo -e "${lightblue}Total:\t${default}${rootdirdu}" echo -e "${lightblue}Serverfiles:\t${default}${serverfilesdu}" if [ -d "${backupdir}" ]; then @@ -292,7 +292,7 @@ fn_info_messages_gameserver() { echo -e "${lightblue}Server password:\t${default}${serverpassword}" fi - # Query enabled (Starbound) + # Query enabled (Starbound, Minecraft) if [ -n "${queryenabled}" ]; then echo -e "${lightblue}Query enabled:\t${default}${queryenabled}" fi @@ -553,23 +553,39 @@ fn_info_messages_script() { fi # Discord alert - echo -e "${lightblue}Discord alert:\t${default}${discordalert}" + if [ "${discordalert}" == "on" ]; then + echo -e "${lightblue}Discord alert:\t${default}${discordalert}" + fi # Email alert - echo -e "${lightblue}Email alert:\t${default}${emailalert}" + if [ "${emailalert}" == "on" ]; then + echo -e "${lightblue}Email alert:\t${default}${emailalert}" + fi # Gotify alert - echo -e "${lightblue}Gotify alert:\t${default}${gotifyalert}" + if [ "${gotifyalert}" == "on" ]; then + echo -e "${lightblue}Gotify alert:\t${default}${gotifyalert}" + fi # IFTTT alert echo -e "${lightblue}IFTTT alert:\t${default}${iftttalert}" # Pushbullet alert - echo -e "${lightblue}Pushbullet alert:\t${default}${pushbulletalert}" + if [ "${pushbulletalert}" == "on" ]; then + echo -e "${lightblue}Pushbullet alert:\t${default}${pushbulletalert}" + fi # Pushover alert - echo -e "${lightblue}Pushover alert:\t${default}${pushoveralert}" + if [ "${pushoveralert}" == "on" ]; then + echo -e "${lightblue}Pushover alert:\t${default}${pushoveralert}" + fi # Rocketchat alert - echo -e "${lightblue}Rocketchat alert:\t${default}${rocketchatalert}" + if [ "${rocketchatalert}" == "on" ]; then + echo -e "${lightblue}Rocketchat alert:\t${default}${rocketchatalert}" + fi # Slack alert - echo -e "${lightblue}Slack alert:\t${default}${slackalert}" + if [ "${slackalert}" == "on" ]; then + echo -e "${lightblue}Slack alert:\t${default}${slackalert}" + fi # Telegram alert - echo -e "${lightblue}Telegram alert:\t${default}${telegramalert}" + if [ "${telegramalert}" == "on" ]; then + echo -e "${lightblue}Telegram alert:\t${default}${telegramalert}" + fi # Update on start if [ -n "${updateonstart}" ]; then diff --git a/lgsm/modules/install_complete.sh b/lgsm/modules/install_complete.sh index 0ee01954ad..c84e35fe01 100644 --- a/lgsm/modules/install_complete.sh +++ b/lgsm/modules/install_complete.sh @@ -8,25 +8,24 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" echo -e "" -fn_messages_separator -if [ "${exitcode}" == "1" ]; then +if [ "${exitcode}" -eq 1 ]; then echo -e "${bold}${red}Install Failed!${default}" fn_script_log_fail "Install Failed!" -elif [ "${exitcode}" == "2" ]; then +elif [ "${exitcode}" -eq 2 ]; then echo -e "${bold}${red}Install Completed with Errors!${default}}" fn_script_log_error "Install Completed with Errors!" -elif [ "${exitcode}" == "3" ]; then +elif [ "${exitcode}" -eq 3 ]; then echo -e "${bold}${lightyellow}Install Completed with Warnings!${default}}" fn_script_log_warn "Install Completed with Warnings!" -elif [ -z "${exitcode}" ] || [ "${exitcode}" == "0" ]; then +elif [ -z "${exitcode}" ] || [ "${exitcode}" -eq 0 ]; then echo -e "${bold}${green}Install Complete!${default}" fn_script_log_pass "Install Complete!" fi +fn_messages_separator -fn_script_log_info "Install Complete!" echo -e "" -echo -e "To start server type:" -echo -e "./${selfname} start" +echo -e "To start the ${gamename} server type:" +echo -e "${italic}./${selfname} start${default}" echo -e "" core_exit.sh diff --git a/lgsm/modules/install_config.sh b/lgsm/modules/install_config.sh index f4005c6f89..ae395c2057 100644 --- a/lgsm/modules/install_config.sh +++ b/lgsm/modules/install_config.sh @@ -16,43 +16,76 @@ fn_check_cfgdir() { fi } -# Downloads default configs from Game-Server-Configs repo to lgsm/config-default. -fn_fetch_default_config() { +# Copys default configs from Game-Server-Configs repo to server config location. +fn_default_config_remote() { echo -e "" echo -e "${bold}${lightyellow}Downloading ${gamename} Configs${default}" fn_messages_separator - echo -e "Downloading default configs from:" - echo -e "" - echo -e "${italic}https://github.com/GameServerManagers/Game-Server-Configs${default}" + echo -e "Downloading default configs from: ${italic}https://github.com/GameServerManagers/Game-Server-Configs${default}" echo -e "" fn_sleep_time_1 mkdir -p "${lgsmdir}/config-default/config-game" githuburl="https://raw.githubusercontent.com/GameServerManagers/Game-Server-Configs/main" for config in "${array_configs[@]}"; do + # Downloads default configs from Game-Server-Configs repo to lgsm/config-default. fn_fetch_file "${githuburl}/${shortname}/${config}" "${remote_fileurl_backup}" "GitHub" "Bitbucket" "${lgsmdir}/config-default/config-game" "${config}" "nochmodx" "norun" "forcedl" "nohash" - done -} -# Copys default configs from Game-Server-Configs repo to server config location. -fn_default_config_remote() { - for config in "${array_configs[@]}"; do - # every config is copied - echo -e "copying ${config} config file." - fn_script_log_info "Copying ${servercfg} config file." + # Every config is copied. if [ "${config}" == "${servercfgdefault}" ]; then mkdir -p "${servercfgdir}" - cp -nv "${lgsmdir}/config-default/config-game/${config}" "${servercfgfullpath}" + echo -en "copying config file [ ${italic}${servercfgfullpath}${default} ]" + changes+=$(cp -nv "${lgsmdir}/config-default/config-game/${config}" "${servercfgfullpath}") + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then + fn_print_fail_eol_nl + fn_script_log_fail "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 elif [ "${shortname}" == "arma3" ] && [ "${config}" == "${networkcfgdefault}" ]; then mkdir -p "${servercfgdir}" - cp -nv "${lgsmdir}/config-default/config-game/${config}" "${networkcfgfullpath}" + echo -en "copying config file [ ${italic}${networkcfgfullpath}${default} ]" + changes+=$(cp -nv "${lgsmdir}/config-default/config-game/${config}" "${networkcfgfullpath}") + if [ "${exitcode}" -ne 0 ]; then + fn_print_fail_eol_nl + fn_script_log_fail "copying config file ${networkcfgdefault}" + elif [ "${changes}" != "" ]; then + fn_print_ok_eol_nl + fn_script_log_pass "copying config file ${networkcfgdefault}" + else + fn_print_skip_eol_nl + fi elif [ "${shortname}" == "dst" ] && [ "${config}" == "${clustercfgdefault}" ]; then - cp -nv "${lgsmdir}/config-default/config-game/${clustercfgdefault}" "${clustercfgfullpath}" + echo -en "copying config file [ ${italic}${clustercfgfullpath}${default} ]" + changes+=$(cp -nv "${lgsmdir}/config-default/config-game/${clustercfgdefault}" "${clustercfgfullpath}") + if [ "${exitcode}" -ne 0 ]; then + fn_print_fail_eol_nl + fn_script_log_fail "copying config file ${clustercfgfullpath}" + elif [ "${changes}" != "" ]; then + fn_print_ok_eol_nl + fn_script_log_pass "copying config file ${clustercfgfullpath}" + else + fn_print_skip_eol_nl + fi else - mkdir -p "${servercfgdir}" - cp -nv "${lgsmdir}/config-default/config-game/${config}" "${servercfgdir}/${config}" + echo -en "copying config file [ ${italic}${servercfgdir}/${config}${default} ]" + changes+=$(cp -nv "${lgsmdir}/config-default/config-game/${config}" "${servercfgdir}/${config}") + if [ "${exitcode}" -ne 0 ]; then + fn_print_fail_eol_nl + fn_script_log_fail "copying config file ${servercfgdir}/${config}" + elif [ "${changes}" != "" ]; then + fn_print_ok_eol_nl + fn_script_log_pass "copying config file ${servercfgdir}/${config}" + else + fn_print_skip_eol_nl + fi fi + + unset changes done - fn_sleep_time } # Copys local default config to server config location. @@ -71,7 +104,7 @@ fn_default_config_local() { echo -en "copying config file [ ${italic}${servercfgdefault}${default} ]: " cp --update=none "${servercfgdir}/${servercfgdefault}" "${servercfgfullpath}" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol fn_script_log_fail "copying config file [ ${servercfgdefault} ]: " else @@ -88,29 +121,47 @@ fn_set_config_vars() { randomstring=$(tr -dc 'A-Za-z0-9_' < /dev/urandom 2> /dev/null | head -c 8 | xargs) servername="LinuxGSM" rconpass="admin${randomstring}" - echo -e "changing hostname." - fn_script_log_info "Changing hostname." + echo -en "setting hostname\c" + fn_script_log_info "setting 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 - sed -i "s/SERVERNAME=SERVERNAME/SERVERNAME=${servername}/g" "${servercfgfullpath}" + changes+=$(sed -i "s/SERVERNAME=SERVERNAME/SERVERNAME=${servername}/g w /dev/stdout" "${servercfgfullpath}") elif grep -q "SERVERNAME=\"SERVERNAME\"" "${lgsmdir}/config-default/config-game/${config}" 2> /dev/null; then - sed -i "s/SERVERNAME=\"SERVERNAME\"/SERVERNAME=\"${servername}\"/g" "${servercfgfullpath}" + changes+=$(sed -i "s/SERVERNAME=\"SERVERNAME\"/SERVERNAME=\"${servername}\"/g w /dev/stdout" "${servercfgfullpath}") else - sed -i "s/SERVERNAME/${servername}/g" "${servercfgfullpath}" + changes+=$(sed -i "s/SERVERNAME/${servername}/g w /dev/stdout" "${servercfgfullpath}") fi - 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" + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then + fn_print_fail_eol + fn_script_log_fail "setting hostname" + elif [ "${changes}" != "" ]; then + fn_print_ok_eol_nl + fn_script_log_pass "setting hostname" else - sed -i "s/ADMINPASSWORD/${rconpass}/g" "${servercfgfullpath}" + fn_print_skip_eol_nl fi + + echo -en "generating admin/rcon password\c" + fn_script_log_info "generating admin/rcon password" 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 + if [ "${shortname}" == "squad" ]; then + changes+=$(sed -i "s/ADMINPASSWORD/${adminpass}/g w /dev/stdout" "${servercfgdir}/Rcon.cfg") + else + changes+=$(sed -i "s/ADMINPASSWORD/${adminpass}/g w /dev/stdout" "${servercfgfullpath}") + fi + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then + fn_print_fail_eol + fn_script_log_fail "generating admin/rcon password" + elif [ "${changes}" != "" ]; then + fn_print_ok_eol_nl + fn_script_log_pass "generating admin/rcon password" + else + fn_print_skip_eol_nl + fi + unset changes fi } @@ -164,22 +215,22 @@ fn_set_dst_config_vars() { echo -e "" } -# Lists local config file locations +# Lists local config locations fn_list_config_locations() { echo -e "" echo -e "${bold}${lightyellow}Config Locations${default}" fn_messages_separator if [ -n "${servercfgfullpath}" ]; then if [ -f "${servercfgfullpath}" ]; then - echo -e "Game Server Config File: ${servercfgfullpath}" + echo -e "${gamename} config file: ${italic}${servercfgfullpath}${default}" elif [ -d "${servercfgfullpath}" ]; then - echo -e "Game Server Config Dir: ${servercfgfullpath}" + echo -e "${gamename} config directory: ${italic}${servercfgfullpath}" else - echo -e "Config file: ${red}${servercfgfullpath}${default} (${red}FILE MISSING${default})" + echo -e "${gamename} config: ${italic}${red}${servercfgfullpath}${default} (${red}CONFIG IS MISSING${default})" fi fi - echo -e "LinuxGSM Config: ${lgsmdir}/config-lgsm/${gameservername}" - echo -e "Documentation: https://docs.linuxgsm.com/configuration/game-server-config" + echo -e "LinuxGSM config: ${italic}${lgsmdir}/config-lgsm/${gameservername}${default}" + echo -e "Config documentation: ${italic}https://docs.linuxgsm.com/configuration${default}" } if [ "${shortname}" == "sdtd" ]; then @@ -187,66 +238,51 @@ if [ "${shortname}" == "sdtd" ]; then fn_list_config_locations elif [ "${shortname}" == "ac" ]; then array_configs+=(server_cfg.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ahl" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ahl2" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ark" ]; then - fn_check_cfgdir array_configs+=(GameUserSettings.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "arma3" ]; then - fn_check_cfgdir array_configs+=(server.cfg network.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "armar" ]; then - fn_check_cfgdir array_configs+=(server.json) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ats" ]; then - fn_check_cfgdir array_configs+=(server_config.sii) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "bo" ]; then array_configs+=(config.txt) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "bd" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "bt" ]; then - fn_check_cfgdir array_configs+=(serversettings.xml) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -259,91 +295,76 @@ elif [ "${shortname}" == "btl" ]; then fn_list_config_locations elif [ "${shortname}" == "bf1942" ]; then array_configs+=(serversettings.con) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "bfv" ]; then array_configs+=(serversettings.con) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "bs" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "bb" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "bb2" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "bmdm" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ck" ]; then array_configs+=(ServerConfig.json) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "cod" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "coduo" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "cod2" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "cod4" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "codwaw" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "cc" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "col" ]; then array_configs+=(colserver.json) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "cs" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -355,86 +376,70 @@ elif [ "${shortname}" == "cs2" ]; then fn_list_config_locations elif [ "${shortname}" == "cscz" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "csgo" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "css" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ct" ]; then array_configs+=(ServerSetting.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "dayz" ]; then - fn_check_cfgdir array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "dod" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "dodr" ]; then array_configs+=(Game.ini) - fn_fetch_default_config fn_default_config_remote fn_list_config_locations elif [ "${shortname}" == "dods" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "doi" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "dmc" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "dst" ]; then - fn_check_cfgdir array_configs+=(cluster.ini server.ini) - fn_fetch_default_config fn_default_config_remote fn_set_dst_config_vars fn_list_config_locations elif [ "${shortname}" == "dab" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "dys" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "eco" ]; then array_configs+=(Network.eco) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -443,44 +448,36 @@ elif [ "${shortname}" == "em" ]; then fn_list_config_locations elif [ "${shortname}" == "etl" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ets2" ]; then - fn_check_cfgdir array_configs+=(server_config.sii) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "fctr" ]; then array_configs+=(server-settings.json) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "fof" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "gmod" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "hldm" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "hldms" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -492,13 +489,11 @@ elif [ "${shortname}" == "ohd" ]; then fn_list_config_locations elif [ "${shortname}" == "opfor" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "hl2dm" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -507,104 +502,84 @@ elif [ "${shortname}" == "hz" ]; then : elif [ "${shortname}" == "ins" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ios" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "jc2" ]; then array_configs+=(config.lua) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "jc3" ]; then array_configs+=(config.json) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "kf" ]; then array_configs+=(Default.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "l4d" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "l4d2" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "mc" ] || [ "${shortname}" == "pmc" ]; then array_configs+=(server.properties) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "mcb" ]; then array_configs+=(server.properties) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "mohaa" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "mh" ]; then - fn_check_cfgdir array_configs+=(Game.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ns" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "nmrih" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "nd" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "mta" ]; then - fn_check_cfgdir array_configs+=(acl.xml mtaserver.conf vehiclecolors.conf) - fn_fetch_default_config fn_default_config_remote fn_list_config_locations elif [ "${shortname}" == "pvr" ]; then - fn_check_cfgdir array_configs+=(Game.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars elif [ "${shortname}" == "pvkii" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -615,22 +590,17 @@ elif [ "${shortname}" == "pw" ]; then fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "pz" ]; then - fn_check_cfgdir array_configs+=(server.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "nec" ]; then - fn_check_cfgdir array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "pc" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -639,7 +609,6 @@ elif [ "${shortname}" == "pc2" ]; then fn_list_config_locations elif [ "${shortname}" == "q2" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -657,48 +626,39 @@ elif [ "${shortname}" == "q4" ]; then fn_list_config_locations elif [ "${shortname}" == "ql" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "jk2" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars elif [ "${shortname}" == "qw" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ricochet" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "rtcw" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "rust" ]; then - fn_check_cfgdir array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_list_config_locations elif [ "${shortname}" == "scpsl" ] || [ "${shortname}" == "scpslsm" ]; then array_configs+=(config_gameplay.txt config_localadmin.txt) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "sf" ]; then array_configs+=(GameUserSettings.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -707,109 +667,90 @@ elif [ "${shortname}" == "sm" ]; then fn_list_config_locations elif [ "${shortname}" == "sol" ]; then array_configs+=(soldat.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "sof2" ]; then array_configs+=(server.cfg mapcycle.txt) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "sfc" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "squad" ]; then array_configs+=(Admins.cfg Bans.cfg License.cfg Server.cfg Rcon.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "sb" ]; then array_configs+=(starbound_server.config) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "stn" ]; then array_configs+=(ServerConfig.txt ServerUsers.txt TpPresets.json UserPermissions.json) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "sven" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "tf2" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "tfc" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ti" ]; then array_configs+=(Game.ini Engine.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ts" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ts3" ]; then array_configs+=(ts3server.ini) - fn_fetch_default_config fn_default_config_remote fn_list_config_locations elif [ "${shortname}" == "tw" ]; then array_configs+=(server.cfg ctf.cfg dm.cfg duel.cfg tdm.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "terraria" ]; then array_configs+=(serverconfig.txt) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "tu" ]; then - fn_check_cfgdir array_configs+=(TowerServer.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ut" ]; then array_configs+=(Game.ini Engine.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ut2k4" ]; then array_configs+=(UT2004.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "ut99" ]; then array_configs+=(Default.ini) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -821,25 +762,21 @@ elif [ "${shortname}" == "vints" ]; then : elif [ "${shortname}" == "vs" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "wet" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "wf" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "wmc" ]; then array_configs+=(config.yml) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations @@ -851,19 +788,16 @@ elif [ "${shortname}" == "xnt" ]; then fn_list_config_locations elif [ "${shortname}" == "wurm" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "zmr" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations elif [ "${shortname}" == "zps" ]; then array_configs+=(server.cfg) - fn_fetch_default_config fn_default_config_remote fn_set_config_vars fn_list_config_locations diff --git a/lgsm/modules/install_dst_token.sh b/lgsm/modules/install_dst_token.sh index fd0b4727bd..93ac1b8a4b 100644 --- a/lgsm/modules/install_dst_token.sh +++ b/lgsm/modules/install_dst_token.sh @@ -12,7 +12,7 @@ echo -e "${bold}${lightyellow}Enter ${gamename} Cluster Token${default}" fn_messages_separator echo -e "A cluster token is required to run this server!" echo -e "Follow the instructions in this link to obtain this key:" -echo -e "https://linuxgsm.com/dst-auth-token" +echo -e "${italic}https://linuxgsm.com/dst-auth-token" echo -e "" if [ -z "${autoinstall}" ]; then overwritetoken="true" diff --git a/lgsm/modules/install_eula.sh b/lgsm/modules/install_eula.sh index 272ff205a5..f32a1931e1 100644 --- a/lgsm/modules/install_eula.sh +++ b/lgsm/modules/install_eula.sh @@ -19,11 +19,11 @@ echo -e "" echo -e "${bold}${lightyellow}Accept ${gamename} EULA${default}" fn_messages_separator echo -e "You are required to accept the EULA:" -echo -e "${eulaurl}" +echo -e "" +echo -e "${italic}${eulaurl}${default}" echo -e "" if [ -z "${autoinstall}" ]; then echo -e "By continuing you are indicating your agreement to the EULA." - echo -e "" if ! fn_prompt_yn "Continue?" Y; then exitcode=0 core_exit.sh diff --git a/lgsm/modules/install_gslt.sh b/lgsm/modules/install_gslt.sh index 960b1e20c7..e4e4dbad72 100644 --- a/lgsm/modules/install_gslt.sh +++ b/lgsm/modules/install_gslt.sh @@ -11,17 +11,16 @@ echo -e "" echo -e "${bold}${lightyellow}Game Server Login Token${default}" fn_messages_separator if [ "${shortname}" == "csgo" ] || [ "${shortname}" == "css" ] || [ "${shortname}" == "nmrih" ] || [ "${shortname}" == "bs" ]; then - echo -e "GSLT is required to run a public ${gamename} server" + echo -e "GSLT is required to run a public ${gamename} server." fn_script_log_info "GSLT is required to run a public ${gamename} server" else - echo -e "GSLT is an optional feature for ${gamename} server" + echo -e "GSLT is an optional feature for ${gamename} server." fn_script_log_info "GSLT is an optional feature for ${gamename} server" fi -echo -e "Get more info and a token here:" -echo -e "https://docs.linuxgsm.com/steamcmd/gslt" -fn_script_log_info "Get more info and a token here:" -fn_script_log_info "https://docs.linuxgsm.com/steamcmd/gslt" +echo -e "" +echo -e "More info: ${italic}https://docs.linuxgsm.com/steamcmd/gslt${default}" +fn_script_log_info "More info: https://docs.linuxgsm.com/steamcmd/gslt" echo -e "" if [ -z "${autoinstall}" ]; then if [ "${shortname}" != "tu" ]; then @@ -37,11 +36,10 @@ if [ -z "${autoinstall}" ]; then fi 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}." + echo -e "The GSLT can be changed by editing: ${italic}${servercfgdir}/${servercfg}${default}" + 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." + echo -e "The GSLT can be changed by editing: ${italic}${configdirserver}/${selfname}.cfg${default}" + fn_script_log_info "The GSLT can be changed by editing: ${configdirserver}/${selfname}.cfg." fi fn_sleep_time_1 -echo -e "" diff --git a/lgsm/modules/install_logs.sh b/lgsm/modules/install_logs.sh index 3e522a0824..9e1b89dbdf 100644 --- a/lgsm/modules/install_logs.sh +++ b/lgsm/modules/install_logs.sh @@ -7,93 +7,117 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" -if [ "${checklogs}" != "1" ]; then +if [ -z "${checklogs}" ]; then echo -e "" echo -e "${bold}${lightyellow}Creating Log Directories${default}" fn_messages_separator fi -# Create LinuxGSM logs. -echo -en "installing log dir: ${logdir}..." -mkdir -p "${logdir}" -if [ $? != 0 ]; then - fn_print_fail_eol_nl - core_exit.sh -else - fn_print_ok_eol_nl -fi -echo -en "installing LinuxGSM log dir: ${lgsmlogdir}..." -mkdir -p "${lgsmlogdir}" -if [ $? != 0 ]; then - fn_print_fail_eol_nl - core_exit.sh +echo -en "creating log directory [ ${italic}${logdir}${default} ]" +if [ ! -d "${logdir}" ]; then + if ! mkdir -p "${logdir}"; then + fn_print_fail_eol_nl + core_exit.sh + else + fn_print_ok_eol_nl + fi else - fn_print_ok_eol_nl + fn_print_skip_eol_nl fi -echo -en "creating LinuxGSM log: ${lgsmlog}..." -touch "${lgsmlog}" -if [ $? != 0 ]; then - fn_print_fail_eol_nl - core_exit.sh + +echo -en "creating script log directory [ ${italic}${lgsmlogdir}${default} ]" +if [ ! -d "${lgsmlogdir}" ]; then + if ! mkdir -p "${lgsmlogdir}"; then + fn_print_fail_eol_nl + core_exit.sh + else + fn_print_ok_eol_nl + fi else - fn_print_ok_eol_nl + fn_print_skip_eol_nl fi -# Create Console logs. -if [ "${consolelogdir}" ]; then - echo -en "installing console log dir: ${consolelogdir}..." - mkdir -p "${consolelogdir}" - if [ $? != 0 ]; then + +echo -en "creating script log [ ${italic}${lgsmlog}${default} ]" +if [ ! -f "${lgsmlog}" ]; then + if ! touch "${lgsmlog}"; then fn_print_fail_eol_nl core_exit.sh else fn_print_ok_eol_nl fi - echo -en "creating console log: ${consolelog}..." - if ! touch "${consolelog}"; then +else + fn_print_skip_eol_nl +fi + +echo -en "creating console log directory [ ${italic}${consolelogdir}${default} ]" +if [ ! -d "${consolelogdir}" ]; then + if ! mkdir -p "${consolelogdir}"; then fn_print_fail_eol_nl core_exit.sh else fn_print_ok_eol_nl fi +else + fn_print_skip_eol_nl fi -# Create Game logs. -if [ "${gamelogdir}" ] && [ ! -d "${gamelogdir}" ]; then - echo -en "installing game log dir: ${gamelogdir}..." - if ! mkdir -p "${gamelogdir}"; then +echo -en "creating console log [ ${italic}${consolelog}${default} ]" +if [ ! -f "${consolelog}" ]; then + if ! touch "${consolelog}"; then fn_print_fail_eol_nl core_exit.sh else fn_print_ok_eol_nl fi +else + fn_print_skip_eol_nl +fi + +if [ -n "${gamelogdir}" ]; then + echo -en "creating game log directory [ ${italic}${gamelogdir}${default} ]" + if [ ! -d "${gamelogdir}" ]; then + if ! mkdir -p "${gamelogdir}"; then + fn_print_fail_eol_nl + core_exit.sh + else + fn_print_ok_eol_nl + fi + else + fn_print_skip_eol_nl + fi fi # Symlink to gamelogdir # unless gamelogdir is within logdir. # e.g serverfiles/log is not within log/: symlink created # log/server is in log/: symlink not created -if [ "${gamelogdir}" ]; then - if [ "${gamelogdir:0:${#logdir}}" != "${logdir}" ]; then - echo -en "creating symlink to game log dir: ${logdir}/server -> ${gamelogdir}..." +if [ -n "${gamelogdir}" ] && [ "${gamelogdir:0:${#logdir}}" != "${logdir}" ]; then + echo -en "creating symlink to game log directory [ ${italic}${logdir}/server -> ${gamelogdir}${default} ]" + # if path does not exist or does not match gamelogdir + if [ ! -h "${logdir}/server" ] || [ "$(readlink -f "${logdir}/server")" != "${gamelogdir}" ]; then if ! ln -nfs "${gamelogdir}" "${logdir}/server"; then fn_print_fail_eol_nl core_exit.sh else fn_print_ok_eol_nl fi + else + fn_print_skip_eol_nl fi fi # If server uses SteamCMD create a symbolic link to the Steam logs. if [ -d "${HOME}/.steam/steam/logs" ]; then + echo -en "creating symlink to steam log directory [ ${italic}${logdir}/steam -> ${HOME}/.steam/steam/logs${default} ]" if [ ! -L "${logdir}/steam" ]; then - echo -en "creating symlink to steam log dir: ${logdir}/steam -> ${HOME}/.steam/steam/logs..." if ! ln -nfs "${HOME}/.steam/steam/logs" "${logdir}/steam"; then fn_print_fail_eol_nl core_exit.sh else fn_print_ok_eol_nl fi + else + fn_print_skip_eol_nl fi fi fn_script_log_info "Logs installed" diff --git a/lgsm/modules/install_server_dir.sh b/lgsm/modules/install_server_dir.sh index 2922f397ae..318e4bc800 100644 --- a/lgsm/modules/install_server_dir.sh +++ b/lgsm/modules/install_server_dir.sh @@ -10,10 +10,16 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" echo -e "" echo -e "${bold}${lightyellow}Server Directory${default}" fn_messages_separator +echo -en "creating serverfiles directory [ ${italic}${serverfiles}${default} ]" + if [ -d "${serverfiles}" ]; then - fn_print_warning_nl "A server is already installed here." + fn_print_skip_eol_nl + echo -e "" + echo -e "${italic}A game server is already exists at this location.${default}" +else + fn_print_ok_eol_nl fi -pwd + if [ -z "${autoinstall}" ]; then if ! fn_prompt_yn "Continue?" Y; then exitcode=0 @@ -21,5 +27,5 @@ if [ -z "${autoinstall}" ]; then fi fi if [ ! -d "${serverfiles}" ]; then - mkdir -v "${serverfiles}" + mkdir "${serverfiles}" fi diff --git a/lgsm/modules/install_server_files.sh b/lgsm/modules/install_server_files.sh index baa18aef73..c667a7fe49 100644 --- a/lgsm/modules/install_server_files.sh +++ b/lgsm/modules/install_server_files.sh @@ -241,6 +241,10 @@ fn_install_server_files() { fn_clear_tmp } +if [ "${shortname}" == "mc" ] || [ "${shortname}" == "pmc" ] || [ "${shortname}" == "ut" ]; then + install_eula.sh +fi + echo -e "" echo -e "${bold}${lightyellow}Installing ${gamename} Server${default}" fn_messages_separator @@ -255,12 +259,10 @@ fi if [ "${shortname}" == "ts3" ]; then update_ts3.sh elif [ "${shortname}" == "mc" ]; then - install_eula.sh update_mc.sh elif [ "${shortname}" == "mcb" ]; then update_mcb.sh elif [ "${shortname}" == "pmc" ]; then - install_eula.sh update_pmc.sh elif [ "${shortname}" == "wmc" ] || [ "${shortname}" == "vpmc" ]; then update_pmc.sh @@ -287,7 +289,6 @@ fi if [ -z "${autoinstall}" ]; then echo -e "" - fn_messages_separator if ! fn_prompt_yn "Was the install successful?" Y; then install_retry.sh fi diff --git a/lgsm/modules/install_squad_license.sh b/lgsm/modules/install_squad_license.sh index 0bb71c4a85..7b7d2ca664 100644 --- a/lgsm/modules/install_squad_license.sh +++ b/lgsm/modules/install_squad_license.sh @@ -14,7 +14,7 @@ echo -e "Server license is an optional feature for ${gamename} server" fn_script_log_info "Server license is an optional feature for ${gamename} server" echo -e "Get more info and a server license here:" -echo -e "https://squad.fandom.com/wiki/Server_licensing" +echo -e "${italic}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 "" diff --git a/lgsm/modules/install_stats.sh b/lgsm/modules/install_stats.sh index fa43c280f5..16653578bc 100644 --- a/lgsm/modules/install_stats.sh +++ b/lgsm/modules/install_stats.sh @@ -13,6 +13,7 @@ fn_messages_separator 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}" +echo -e "" echo -e "The following info will be sent: " echo -e "* game server" echo -e "* distro" @@ -24,5 +25,6 @@ if [ -z "${autoinstall}" ]; then fn_print_information_nl "Stats setting is now enabled in common.cfg." fi else - fn_print_information_nl "auto-install leaves stats off by default. Stats can be enabled in common.cfg" + echo -e "" + echo -e "auto-install leaves stats off by default. Stats can be enabled in ${italic}common.cfg${default}" fi diff --git a/lgsm/modules/install_ts3db.sh b/lgsm/modules/install_ts3db.sh index c8f90a9cf0..584fbd7c09 100644 --- a/lgsm/modules/install_ts3db.sh +++ b/lgsm/modules/install_ts3db.sh @@ -11,8 +11,8 @@ fn_install_ts3db_mariadb() { if [ ! -f "${serverfiles}/libts3db_mariadb.so" ]; then echo -e "copying libmariadb.so.2...\c" cp "${serverfiles}/redist/libmariadb.so.2" "${serverfiles}" - local exitcode=$? - if [ "${exitcode}" != "0" ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "copying libmariadb.so.2" core_exit.sh diff --git a/lgsm/modules/install_ut2k4_key.sh b/lgsm/modules/install_ut2k4_key.sh index 7ffbba20c5..2829da8d64 100644 --- a/lgsm/modules/install_ut2k4_key.sh +++ b/lgsm/modules/install_ut2k4_key.sh @@ -12,7 +12,7 @@ echo -e "${bold}${lightyellow}Enter ${gamename} CD Key${default}" fn_messages_separator echo -e "To get your server listed on the Master Server list" echo -e "you must get a free CD key. Get a key here:" -echo -e "https://www.epicgames.com/unrealtournament/forums/cdkey.php?2004" +echo -e "${italic}https://www.epicgames.com/unrealtournament/forums/cdkey.php?2004" echo -e "" if [ -z "${autoinstall}" ]; then echo -e "Once you have the key enter it below" diff --git a/lgsm/modules/mods_core.sh b/lgsm/modules/mods_core.sh index 47bef26f72..b88e0c05eb 100644 --- a/lgsm/modules/mods_core.sh +++ b/lgsm/modules/mods_core.sh @@ -57,8 +57,8 @@ fn_mod_lowercase() { # Finally we can rename the file mv "${src}" "${dst}" # Exit if it fails for any reason - local exitcode=$? - if [ "${exitcode}" != 0 ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl core_exit.sh fi @@ -74,8 +74,8 @@ fn_mod_create_filelist() { fn_sleep_time # ${modsdir}/${modcommand}-files.txt. find "${extractdest}" -mindepth 1 -printf '%P\n' > "${modsdir}/${modcommand}-files.txt" - local exitcode=$? - if [ "${exitcode}" != 0 ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Building ${modsdir}/${modcommand}-files.txt" core_exit.sh @@ -94,8 +94,8 @@ fn_mod_copy_destination() { echo -en "copying ${modprettyname} to ${modinstalldir}..." fn_sleep_time cp -Rf "${extractdest}/." "${modinstalldir}/" - local exitcode=$? - if [ "${exitcode}" != 0 ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Copying ${modprettyname} to ${modinstalldir}" else @@ -132,8 +132,8 @@ fn_mod_tidy_files_list() { # Delete line(s) matching exactly. sed -i "/^${removefilevar}$/d" "${modsdir}/${modcommand}-files.txt" # Exit on error. - local exitcode=$? - if [ "${exitcode}" != 0 ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Error while tidying line: ${removefilevar} from: ${modsdir}/${modcommand}-files.txt" core_exit.sh @@ -388,7 +388,7 @@ fn_create_mods_dir() { echo -en "creating LinuxGSM mods data directory ${modsdir}..." mkdir -p "${modsdir}" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Creating mod download dir ${modsdir}" core_exit.sh @@ -402,7 +402,7 @@ fn_create_mods_dir() { echo -en "creating mods install directory ${modinstalldir}..." mkdir -p "${modinstalldir}" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Creating mod install directory ${modinstalldir}" core_exit.sh @@ -425,7 +425,7 @@ fn_mods_create_tmp_dir() { mkdir -p "${modstmpdir}" exitcode=$? echo -en "creating mod download directory ${modstmpdir}..." - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Creating mod download directory ${modstmpdir}" core_exit.sh @@ -442,7 +442,7 @@ fn_mods_clear_tmp_dir() { echo -en "clearing mod download directory ${modstmpdir}..." rm -rf "${modstmpdir:?}" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Clearing mod download directory ${modstmpdir}" core_exit.sh @@ -580,7 +580,7 @@ fn_mod_install_liblist_gam_file() { grep -q "addons/metamod/dlls/metamod.dll" "${modinstalldir}/liblist.gam" exitcode=$? # if replacement back didn't happen, error out. - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_script_log_fail "${logentry}" fn_print_fail_eol_nl else @@ -596,7 +596,7 @@ fn_mod_install_liblist_gam_file() { grep -q "addons/metamod/dlls/metamod.so" "${modinstalldir}/liblist.gam" exitcode=$? # if replacement back didn't happen, error out - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_script_log_fail "${logentry}" fn_print_fail_eol_nl else @@ -614,11 +614,11 @@ fn_mod_install_liblist_gam_file() { grep -q "addons/metamod/dlls/metamod.dylib" "${modinstalldir}/liblist.gam" exitcode=$? # if replacement back didn't happen, error out. - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_script_log_fail "${logentry}" fn_print_fail_eol_nl else - fn_script_log_pass ${logentry} + fn_script_log_pass "${logentry}" fn_print_ok_eol_nl fi fi @@ -638,11 +638,11 @@ fn_mod_remove_liblist_gam_file() { grep -q "${moddll}" "${modinstalldir}/liblist.gam" exitcode=$? # if replacement back didn't happen, error out. - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_script_log_fail "${logentry}" fn_print_fail_eol_nl else - fn_script_log_pass ${logentry} + fn_script_log_pass "${logentry}" fn_print_ok_eol_nl fi @@ -654,11 +654,11 @@ fn_mod_remove_liblist_gam_file() { grep -q "${modso}" "${modinstalldir}/liblist.gam" exitcode=$? # if replacement back didn't happen, error out - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_script_log_fail "${logentry}" fn_print_fail_eol_nl else - fn_script_log_pass ${logentry} + fn_script_log_pass "${logentry}" fn_print_ok_eol_nl fi @@ -672,11 +672,11 @@ fn_mod_remove_liblist_gam_file() { grep -q "${moddylib}" "${modinstalldir}/liblist.gam" # if replacement back didn't happen, error out. exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_script_log_fail "${logentry}" fn_print_fail_eol_nl else - fn_script_log_pass ${logentry} + fn_script_log_pass "${logentry}" fn_print_ok_eol_nl fi fi @@ -691,15 +691,15 @@ fn_mod_install_amxmodx_file() { echo -en "adding amxmodx_mm_i386.so in plugins.ini..." grep -q "amxmodx_mm_i386.so" "${modinstalldir}/addons/metamod/plugins.ini" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then # file exists but the entry does not, let's add it echo "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" >> "${modinstalldir}/addons/metamod/plugins.ini" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_script_log_fail "${logentry}" fn_print_fail_eol_nl else - fn_script_log_pass ${logentry} + fn_script_log_pass "${logentry}" fn_print_ok_eol_nl fi fi @@ -707,12 +707,12 @@ fn_mod_install_amxmodx_file() { # create new file and add the mod to it echo "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" > "${modinstalldir}/addons/metamod/plugins.ini" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_script_log_fail "${logentry}" fn_print_fail_eol_nl core_exit.sh else - fn_script_log_pass ${logentry} + fn_script_log_pass "${logentry}" fn_print_ok_eol_nl fi fi @@ -726,17 +726,17 @@ fn_mod_remove_amxmodx_file() { grep -q "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" "${modinstalldir}/addons/metamod/plugins.ini" # iIs it found? If so remove it and clean up exitcode=$? - if [ "${exitcode}" == 0 ]; then + if [ "${exitcode}" -eq 0 ]; then # delete the line we inserted sed -i '/linux addons\/amxmodx\/dlls\/amxmodx_mm_i386.so/d' "${modinstalldir}/addons/metamod/plugins.ini" # remove empty lines sed -i '/^$/d' "${modinstalldir}/addons/metamod/plugins.ini" exitcode=$? - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then fn_script_log_fail "${logentry}" fn_print_fail_eol_nl else - fn_script_log_pass ${logentry} + fn_script_log_pass "${logentry}" fn_print_ok_eol_nl fi diff --git a/lgsm/modules/update_mcb.sh b/lgsm/modules/update_mcb.sh index 65ebc2546b..e3a4776ce0 100644 --- a/lgsm/modules/update_mcb.sh +++ b/lgsm/modules/update_mcb.sh @@ -15,8 +15,8 @@ fn_update_dl() { else unzip -oq "${tmpdir}/bedrock_server.${remotebuildversion}.zip" -x "permissions.json" "server.properties" "allowlist.json" -d "${serverfiles}" fi - local exitcode=$? - if [ "${exitcode}" != 0 ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then fn_print_fail_eol_nl fn_script_log_fail "Extracting ${local_filename}" if [ -f "${lgsmlog}" ]; then @@ -27,7 +27,9 @@ fn_update_dl() { core_exit.sh else fn_print_ok_eol_nl - fn_script_log_pass "Extracting ${local_filename}" + if [ -f "${lgsmlog}" ]; then + fn_script_log_pass "Extracting ${local_filename}" + fi fn_clear_tmp fi } diff --git a/lgsm/modules/update_pmc.sh b/lgsm/modules/update_pmc.sh index b3c7d0dc26..325e795df6 100644 --- a/lgsm/modules/update_pmc.sh +++ b/lgsm/modules/update_pmc.sh @@ -5,7 +5,7 @@ # Website: https://linuxgsm.com # Description: Handles updating of PaperMC and Waterfall servers. -module_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_update_dl() { # Download and extract files to serverfiles. diff --git a/lgsm/modules/update_ut99.sh b/lgsm/modules/update_ut99.sh index cb74ec3b7a..58927fd181 100644 --- a/lgsm/modules/update_ut99.sh +++ b/lgsm/modules/update_ut99.sh @@ -5,7 +5,7 @@ # Website: https://linuxgsm.com # Description: Handles updating of Unreal Tournament 99 servers. -module_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_update_dl() { # Download and extract files to serverfiles. diff --git a/lgsm/modules/update_xnt.sh b/lgsm/modules/update_xnt.sh index f2cdbe3245..c0b0ddaebf 100644 --- a/lgsm/modules/update_xnt.sh +++ b/lgsm/modules/update_xnt.sh @@ -5,7 +5,7 @@ # Website: https://linuxgsm.com # Description: Handles updating of Unreal Tournament 99 servers. -module_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_update_dl() { # Download and extract files to serverfiles. diff --git a/linuxgsm.sh b/linuxgsm.sh index 9c35a6b840..9bb4ae8726 100755 --- a/linuxgsm.sh +++ b/linuxgsm.sh @@ -70,6 +70,42 @@ core_modules.sh() { # Bootstrap # Fetches the core modules required before passed off to core_dl.sh. +fn_bootstrap_fetch_trap() { + echo -e "" + echo -en "downloading ${local_filename}" + fn_print_canceled_eol_nl + fn_script_log_info "Downloading ${local_filename}...CANCELED" + rm -f "${local_filedir:?}/${local_filename}" + echo -en "downloading ${local_filename}" + fn_print_removed_eol_nl + fn_script_log_info "Downloading ${local_filename}...REMOVED" + core_exit.sh +} + +# Fetches modules from the Git repo during first download. +fn_bootstrap_fetch_module() { + github_file_url_dir="lgsm/modules" + github_file_url_name="${modulefile}" + # If master branch will currently running LinuxGSM version to prevent "version mixing". This is ignored if a fork. + if [ "${githubbranch}" == "master" ] && [ "${githubuser}" == "GameServerManagers" ] && [ "${commandname}" != "UPDATE-LGSM" ]; then + remote_fileurl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${version}/${github_file_url_dir}/${github_file_url_name}" + remote_fileurl_backup="https://bitbucket.org/${githubuser}/${githubrepo}/raw/${version}/${github_file_url_dir}/${github_file_url_name}" + else + remote_fileurl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" + remote_fileurl_backup="https://bitbucket.org/${githubuser}/${githubrepo}/raw/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" + fi + remote_fileurl_name="GitHub" + remote_fileurl_backup_name="Bitbucket" + local_filedir="${modulesdir}" + local_filename="${github_file_url_name}" + chmodx="chmodx" + run="run" + forcedl="noforce" + hash="nohash" + # Passes vars to the file download module. + fn_fetch_file "${remote_fileurl}" "${remote_fileurl_backup}" "${remote_fileurl_name}" "${remote_fileurl_backup_name}" "${local_filedir}" "${local_filename}" "${chmodx}" "${run}" "${forcedl}" "${hash}" +} + fn_bootstrap_fetch_file() { remote_fileurl="${1}" remote_fileurl_backup="${2}" @@ -80,7 +116,8 @@ fn_bootstrap_fetch_file() { chmodx="${7:-0}" run="${8:-0}" forcedl="${9:-0}" - md5="${10:-0}" + hash="${10:-0}" + # Download file if missing or download forced. if [ ! -f "${local_filedir}/${local_filename}" ] || [ "${forcedl}" == "forcedl" ]; then # If backup fileurl exists include it. @@ -107,44 +144,54 @@ fn_bootstrap_fetch_file() { mkdir -p "${local_filedir}" fi # Trap will remove part downloaded files if canceled. - trap fn_fetch_trap INT - # Larger files show a progress bar. - - echo -en "fetching ${fileurl_name} ${local_filename}...\c" - curlcmd=$(curl --connect-timeout 3 -s --fail -L -o "${local_filedir}/${local_filename}" "${fileurl}" 2>&1) - - local exitcode=$? + trap fn_bootstrap_fetch_trap INT + curlcmd=(curl --connect-timeout 3 --fail -L -o "${local_filedir}/${local_filename}" --retry 2 -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.${randomint}.212 Safari/537.36") + + # if is large file show progress, else be silent + local exitcode="" + large_files=("bz2" "gz" "zip" "jar" "xz") + if grep -qE "(^|\s)${local_filename##*.}(\s|$)" <<< "${large_files[@]}"; then + echo -e "downloading file [ ${local_filename} ]" + fn_sleep_time + "${curlcmd[@]}" --progress-bar "${fileurl}" 2>&1 + exitcode=$? + echo -en "downloading file [ ${local_filename} ]" + else + echo -en "fetching ${fileurl_name} [ ${local_filename} ]\c" + "${curlcmd[@]}" --silent --show-error "${fileurl}" 2>&1 + exitcode=$? + fi # Download will fail if downloads a html file. if [ -f "${local_filedir}/${local_filename}" ]; then - if [ -n "$(head "${local_filedir}/${local_filename}" | grep "DOCTYPE")" ]; then - rm -f "${local_filedir:?}/${local_filename:?}" + if head -n 1 "${local_filedir}/${local_filename}" | grep -q "DOCTYPE"; then + rm "${local_filedir:?}/${local_filename:?}" local exitcode=2 fi fi # On first try will error. On second try will fail. - if [ "${exitcode}" != 0 ]; then + if [ "${exitcode}" -ne 0 ]; then if [ ${counter} -ge 2 ]; then - echo -e "FAIL" + echo -e " ... FAIL" if [ -f "${lgsmlog}" ]; then - fn_script_log_fail "Downloading ${local_filename}" + fn_script_log_fail "Downloading ${local_filename}..." fn_script_log_fail "${fileurl}" fi core_exit.sh else - echo -e "ERROR" + echo -e " ... ERROR" if [ -f "${lgsmlog}" ]; then - fn_script_log_error "Downloading ${local_filename}" + fn_script_log_error "Downloading ${local_filename}..." fn_script_log_error "${fileurl}" fi fi else - echo -en "OK" - sleep 0.3 - echo -en "\033[2K\\r" + echo -en " ... OK" + sleep "0.1" + echo -e "\033\\r" if [ -f "${lgsmlog}" ]; then - fn_script_log_pass "Downloading ${local_filename}" + fn_script_log_pass "Downloading ${local_filename}..." fi # Make file executable if chmodx is set. @@ -246,7 +293,8 @@ fn_install_menu_whiptail() { menu_options+=("${val//\"/}" "${key//\"/}") done < "${options}" OPTION=$(${menucmd} --title "${title}" --menu "${caption}" "${height}" "${width}" "${menuheight}" "${menu_options[@]}" 3>&1 1>&2 2>&3) - if [ $? == 0 ]; then + exitcode=$? + if [ "${exitcode}" -eq 0 ]; then eval "$resultvar=\"${OPTION}\"" else eval "$resultvar=" @@ -395,13 +443,14 @@ else fi if [ ! -f "${configdirserver}/_default.cfg" ]; then mkdir -p "${configdirserver}" - echo -en "copying _default.cfg...\c" + echo -en "copying _default.cfg\c" cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg" - if [ $? != 0 ]; then - echo -e "FAIL" + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then + echo -e " ... FAIL" exit 1 else - echo -e "OK" + echo -e " ... OK" fi else config_file_diff=$(diff -q "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg") @@ -409,11 +458,12 @@ else fn_print_warn_nl "_default.cfg has altered. reloading config." echo -en "copying _default.cfg...\c" cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg" - if [ $? != 0 ]; then + exitcode=$? + if [ "${exitcode}" -ne 0 ]; then echo -e "FAIL" exit 1 else - echo -e "OK" + echo -e " ... OK" fi fi fi