Skip to content

Commit

Permalink
feat: improve console output formatting
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
dgibbs64 committed Oct 1, 2023
1 parent 1150b49 commit dfd9a24
Show file tree
Hide file tree
Showing 32 changed files with 115 additions and 114 deletions.
4 changes: 2 additions & 2 deletions lgsm/modules/check_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,14 @@ if [ "${commandname}" == "INSTALL" ]; then
if [ "$(whoami)" == "root" ]; then
echo -e ""
echo -e "${bold}${lightyellow}Checking ${gamename} Dependencies as root${default}"
echo -e "${bold}=================================${default}"
fn_messages_separator
fn_print_information_nl "Checking any missing dependencies for ${gamename} server only."
fn_print_information_nl "This will NOT install a ${gamename} server."
fn_sleep_time
else
echo -e ""
echo -e "${bold}${lightyellow}Checking ${gamename} Dependencies${default}"
echo -e "${bold}=================================${default}"
fn_messages_separator
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/command_debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ echo -e ""
echo -e "Use debug for identifying server issues only!"
echo -e "Press CTRL+c to drop out of debug mode."
fn_print_warning_nl "If ${selfname} is already running it will be stopped."
echo -e ""

if ! fn_prompt_yn "Continue?" Y; then
exitcode=0
core_exit.sh
Expand Down
6 changes: 3 additions & 3 deletions lgsm/modules/command_dev_clear_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ commandaction="Clearing modules"
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_firstcommand_set

echo -e "================================="
echo -e "Clear Modules"
echo -e "================================="
echo -e ""
echo -e "${bold}${lightyellow}Clear Modules${default}"
fn_messages_separator
echo -e ""
if fn_prompt_yn "Do you want to delete all modules?" Y; then
rm -rfv "${modulesdir:?}/"*
Expand Down
10 changes: 5 additions & 5 deletions lgsm/modules/command_dev_details.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ info_game.sh
carriagereturn=$(file -b "${servercfgfullpath}" | grep -q CRLF && echo "${red}CRLF${default}" || echo "${lightgreen}LF${default}")

echo -e ""
echo -e "${lightgreen}Server Details${default}"
echo -e "=================================================================="
echo -e "${bold}${lightgreen}Server Details${default}"
fn_messages_separator
echo -e ""

echo -e "Game: ${gamename}"
Expand Down Expand Up @@ -76,8 +76,8 @@ missing_details=""

# Loop through the server details and output them.
echo -e ""
echo -e "${lightgreen}Available Server Details${default}"
echo -e "================================="
echo -e "${bold}${lightgreen}Available Server Details${default}"
fn_messages_separator
for key in "${!server_details[@]}"; do
value=${server_details[$key]}
if [ -z "$value" ]; then
Expand All @@ -91,7 +91,7 @@ done
if [ -n "$missing_details" ]; then
echo -e ""
echo -e "${lightgreen}Missing Server Details${default}"
echo -e "================================="
fn_messages_separator
echo -e "${missing_details}"
fi

Expand Down
20 changes: 10 additions & 10 deletions lgsm/modules/command_dev_detect_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ commandaction="Developer detect deps"
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_firstcommand_set

echo -e "================================="
echo -e "Dependencies Checker"
echo -e "================================="
echo -e ""
echo -e "${bold}Dependencies Checker${default}"
fn_messages_separator
echo -e "Checking directory: "
echo -e "${serverfiles}"
if [ "$(command -v eu-readelf 2> /dev/null)" ]; then
Expand Down Expand Up @@ -182,33 +182,33 @@ awk -vORS='' '{ print $1,$2 }' "${tmpdir}/.depdetect_ubuntu_list_uniq" > "${tmpd
awk -vORS='' '{ print $1,$2 }' "${tmpdir}/.depdetect_debian_list_uniq" > "${tmpdir}/.depdetect_debian_line"
echo -e ""
echo -e ""
echo -e "Required Dependencies"
echo -e "================================="
echo -e "${bold}Required Dependencies${default}"
fn_messages_separator
echo -e "${executable}"
echo -e ""
echo -e "CentOS"
echo -e "================================="
fn_messages_separator
cat "${tmpdir}/.depdetect_centos_line"
echo -e ""
echo -e ""
echo -e "Ubuntu"
echo -e "================================="
fn_messages_separator
cat "${tmpdir}/.depdetect_ubuntu_line"
echo -e ""
echo -e ""
echo -e "Debian"
echo -e "================================="
fn_messages_separator
cat "${tmpdir}/.depdetect_debian_line"
echo -e ""
if [ "${unknownlib}" == "1" ]; then
echo -e ""
echo -e "Unknown shared Library"
echo -e "================================="
fn_messages_separator
cat "${tmpdir}/.depdetect_unknown"
fi
echo -e ""
echo -e "Required Librarys"
echo -e "================================="
fn_messages_separator
sort "${tmpdir}/.depdetect_readelf" | uniq
echo -en "\n"
rm -f "${tmpdir:?}/.depdetect_centos_line"
Expand Down
8 changes: 4 additions & 4 deletions lgsm/modules/command_dev_detect_glibc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ commandaction="Developer detect glibc"
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_firstcommand_set

echo -e "================================="
fn_messages_separator
echo -e "glibc Requirements Checker"
echo -e "================================="
fn_messages_separator

if [ ! "$(command -v objdump 2> /dev/null)" ]; then
fn_print_failure_nl "objdump is missing"
Expand Down Expand Up @@ -59,7 +59,7 @@ for glibc_check_var in "${glibc_check_dir_array[@]}"; do
echo -e ""
echo -e ""
echo -e "${glibc_check_name} glibc Requirements"
echo -e "================================="
fn_messages_separator
if [ -f "${tmpdir}/detect_glibc_files_${glibc_check_var}.tmp" ]; then
echo -e "Required glibc"
cat "${tmpdir}/detect_glibc_${glibc_check_var}.tmp" | sort | uniq | sort -r --version-sort | head -1 | tee -a "${tmpdir}/detect_glibc_highest.tmp"
Expand All @@ -81,7 +81,7 @@ for glibc_check_var in "${glibc_check_dir_array[@]}"; do
done
echo -e ""
echo -e "Final glibc Requirement"
echo -e "================================="
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
rm -f "${tmpdir:?}/detect_glibc_highest.tmp"
Expand Down
8 changes: 4 additions & 4 deletions lgsm/modules/command_dev_detect_ldd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ commandaction="Developer detect ldd"
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_firstcommand_set

echo -e "================================="
fn_messages_separator
echo -e "Shared Object dependencies Checker"
echo -e "================================="
fn_messages_separator

if [ -z "${serverfiles}" ]; then
dir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
Expand Down Expand Up @@ -47,12 +47,12 @@ find "${serverfiles}" -type f -print0 \
echo -e ""
echo -e ""
echo -e "All"
echo -e "================================="
fn_messages_separator
cat "${tmpdir}/detect_ldd.tmp"

echo -e ""
echo -e "Not Found"
echo -e "================================="
fn_messages_separator
cat "${tmpdir}/detect_ldd_not_found.tmp"

rm -f "${tmpdir:?}/detect_ldd.tmp"
Expand Down
20 changes: 10 additions & 10 deletions lgsm/modules/command_dev_query_raw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ info_messages.sh

echo -e ""
echo -e "${lightgreen}Query IP Addresses${default}"
echo -e "=================================================================="
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 "=================================================================="
fn_messages_separator
{
echo -e "${lightblue}Port Name \tPort Number \tStatus \tTCP \tUDP${default}"
if [ -v port ]; then
Expand Down Expand Up @@ -184,18 +184,18 @@ echo -e "=================================================================="
| column -s $'\t' -t
echo -e ""
echo -e "${lightgreen}SS Output${default}"
echo -e "================================="
fn_messages_separator
fn_info_message_ports
eval "${portcommand}"
echo -e ""
echo -e "${lightgreen}Query Port - Raw Output${default}"
echo -e "=================================================================="
fn_messages_separator
echo -e ""
echo -e "PORT: ${port}"
echo -e "QUERY PORT: ${queryport}"
echo -e ""
echo -e "${lightgreen}Gamedig Raw Output${default}"
echo -e "================================="
fn_messages_separator
echo -e ""
if [ ! "$(command -v gamedig 2> /dev/null)" ]; then
fn_print_failure_nl "gamedig not installed"
Expand All @@ -211,7 +211,7 @@ for queryip in "${queryips[@]}"; do
done
echo -e ""
echo -e "${lightgreen}gsquery Raw Output${default}"
echo -e "================================="
fn_messages_separator
echo -e ""
for queryip in "${queryips[@]}"; do
echo -e "./query_gsquery.py -a \"${queryip}\" -p \"${queryport}\" -e \"${querytype}\""
Expand All @@ -223,7 +223,7 @@ for queryip in "${queryips[@]}"; do
done
echo -e ""
echo -e "${lightgreen}TCP Raw Output${default}"
echo -e "================================="
fn_messages_separator
echo -e ""
for queryip in "${queryips[@]}"; do
echo -e "bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${queryport}''"
Expand All @@ -239,10 +239,10 @@ for queryip in "${queryips[@]}"; do
done
echo -e ""
echo -e "${lightgreen}Game Port - Raw Output${default}"
echo -e "=================================================================="
fn_messages_separator
echo -e ""
echo -e "${lightgreen}TCP Raw Output${default}"
echo -e "================================="
fn_messages_separator
echo -e ""
for queryip in "${queryips[@]}"; do
echo -e "bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${port}''"
Expand All @@ -258,7 +258,7 @@ for queryip in "${queryips[@]}"; do
done
echo -e ""
echo -e "${lightgreen}Steam Master Server Response${default}"
echo -e "=================================================================="
fn_messages_separator
echo -e ""
echo -e "curl -m 3 -s https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr=${publicip}"
echo -e ""
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/command_fastdl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ echo -e ""

# Prompts user for FastDL creation settings.
echo -e "${commandaction} setup"
echo -e "================================="
fn_messages_separator

# Prompt for clearing old files if directory was already here.
if [ -d "${fastdldir}" ]; then
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/command_install_resources_mta.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn_firstcommand_set
fn_install_resources() {
echo -e ""
echo -e "${lightyellow}Installing Default Resources${default}"
echo -e "================================="
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}"
echo -e "Default Resources Installed."
Expand Down
6 changes: 3 additions & 3 deletions lgsm/modules/command_mods_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn_print_header
fn_mods_installed_list
if [ "${installedmodscount}" -gt "0" ]; then
echo -e "Installed addons/mods"
echo -e "================================="
fn_messages_separator
# Go through all available commands, get details and display them to the user.
for ((llindex = 0; llindex < ${#installedmodslist[@]}; llindex++)); do
# Current mod is the "llindex" value of the array we're going through.
Expand All @@ -32,7 +32,7 @@ if [ "${installedmodscount}" -gt "0" ]; then
fi

echo -e "Available addons/mods"
echo -e "================================="
fn_messages_separator
# Display available mods from mods_list.sh.
# Set and reset vars
compatiblemodslistindex=0
Expand Down Expand Up @@ -78,7 +78,7 @@ fn_mod_get_info

echo -e ""
echo -e "Installing ${modprettyname}"
echo -e "================================="
fn_messages_separator
fn_script_log_info "${modprettyname} selected for install"

# Check if the mod is already installed and warn the user.
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/command_mods_remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn_mods_check_installed

fn_print_header
echo -e "Remove addons/mods"
echo -e "================================="
fn_messages_separator

# Displays list of installed mods.
# Generates list to display to user.
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/command_sponsor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn_firstcommand_set

fn_print_ascii_logo
echo -e "${lightyellow}Support LinuxGSM${default}"
echo -e "================================="
fn_messages_separator
echo -e ""
echo -e "Been using LinuxGSM?"
echo -e "Consider sponsoring to support development."
Expand Down
6 changes: 3 additions & 3 deletions lgsm/modules/command_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,18 @@ fn_start_tmux() {
fn_script_log_fatal "Unable to start ${servername}: tmux error:"
echo -e ""
echo -e "Command"
echo -e "================================="
fn_messages_separator
echo -e "tmux -L \"${sessionname}\" new-session -d -s \"${sessionname}\" \"${preexecutable} ${executable} ${startparameters}\"" | tee -a "${lgsmlog}"
echo -e ""
echo -e "Error"
echo -e "================================="
fn_messages_separator
tee -a "${lgsmlog}" < "${lgsmlogdir}/.${selfname}-tmux-error.tmp"

# Detected error https://linuxgsm.com/support
if grep -c "Operation not permitted" "${lgsmlogdir}/.${selfname}-tmux-error.tmp"; then
echo -e ""
echo -e "Fix"
echo -e "================================="
fn_messages_separator
if ! grep "tty:" /etc/group | grep "$(whoami)"; then
echo -e "$(whoami) is not part of the tty group."
fn_script_log_info "$(whoami) is not part of the tty group."
Expand Down
4 changes: 2 additions & 2 deletions lgsm/modules/core_messages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ fn_print_start_nl() {
# =================================
fn_print_header() {
echo -e ""
echo -e "${lightyellow}${gamename} ${commandaction}${default}"
echo -e "=================================${default}"
echo -e "${bold}${lightyellow}${gamename} ${commandaction}${default}"
fn_messages_separator
}

# Complete!
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/fix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ 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 "================================="
fn_messages_separator
fn_sleep_time
postinstall=1
fn_apply_fix "post install" "${shortname}"
Expand Down
Loading

0 comments on commit dfd9a24

Please sign in to comment.