Skip to content
Permalink
Browse files

feat: Refactor comments to follow standards (#2389)

  • Loading branch information...
dgibbs64 committed Jun 13, 2019
1 parent 5901f19 commit e0acffad80a880da6d4dfbbd8107e0418e82266c
Showing with 962 additions and 875 deletions.
  1. +2 −2 lgsm/functions/alert.sh
  2. +2 −2 lgsm/functions/alert_pushover.sh
  3. +2 −2 lgsm/functions/check.sh
  4. +39 −34 lgsm/functions/check_deps.sh
  5. +6 −6 lgsm/functions/check_ip.sh
  6. +3 −3 lgsm/functions/check_logs.sh
  7. +29 −29 lgsm/functions/check_permissions.sh
  8. +1 −1 lgsm/functions/check_steamcmd.sh
  9. +1 −1 lgsm/functions/check_system_requirements.sh
  10. +32 −32 lgsm/functions/command_backup.sh
  11. +9 −9 lgsm/functions/command_debug.sh
  12. +2 −2 lgsm/functions/command_dev_detect_deps.sh
  13. +27 −27 lgsm/functions/command_fastdl.sh
  14. +2 −2 lgsm/functions/command_install.sh
  15. +16 −16 lgsm/functions/command_mods_install.sh
  16. +15 −15 lgsm/functions/command_mods_remove.sh
  17. +16 −16 lgsm/functions/command_mods_update.sh
  18. +4 −4 lgsm/functions/command_postdetails.sh
  19. +18 −17 lgsm/functions/command_start.sh
  20. +30 −33 lgsm/functions/command_stop.sh
  21. +3 −3 lgsm/functions/command_ts3_server_pass.sh
  22. +2 −2 lgsm/functions/command_update_linuxgsm.sh
  23. +23 −23 lgsm/functions/command_wipe.sh
  24. +35 −35 lgsm/functions/core_getopt.sh
  25. +2 −2 lgsm/functions/core_legacy.sh
  26. +3 −3 lgsm/functions/core_messages.sh
  27. +2 −2 lgsm/functions/fix.sh
  28. +1 −2 lgsm/functions/fix_coduo.sh
  29. +1 −1 lgsm/functions/fix_dst.sh
  30. +1 −1 lgsm/functions/fix_rust.sh
  31. +2 −2 lgsm/functions/fix_ts3.sh
  32. +1 −1 lgsm/functions/fix_unt.sh
  33. +4 −4 lgsm/functions/fix_wurm.sh
  34. +1 −1 lgsm/functions/info_config.sh
  35. +9 −9 lgsm/functions/info_distro.sh
  36. +8 −8 lgsm/functions/install_config.sh
  37. +5 −5 lgsm/functions/install_logs.sh
  38. +5 −5 lgsm/functions/install_server_files.sh
  39. +0 −1 lgsm/functions/install_ts3db.sh
  40. +15 −15 lgsm/functions/logs.sh
  41. +92 −92 lgsm/functions/mods_core.sh
  42. +14 −14 lgsm/functions/query_gamedig.sh
  43. +41 −40 linuxgsm.sh
  44. +109 −87 tests/tests_fctrserver.sh
  45. +109 −88 tests/tests_jc2server.sh
  46. +109 −88 tests/tests_mcserver.sh
  47. +109 −88 tests/tests_ts3server.sh
@@ -93,10 +93,10 @@ elif [ "${alert}" == "config" ]; then
fn_alert_config
fi

# Generate alert log
# Generate alert log.
fn_alert_log

# Generates the more info link
# Generates the more info link.
if [ "${postalert}" == "on" ]&&[ -n "${postalert}" ]; then
alertflag=1
command_postdetails.sh
@@ -10,12 +10,12 @@ local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"

fn_print_dots "Sending Pushover alert"

# Different alerts are given different priorities and notification sounds
# Different alerts are given different priorities and notification sounds.
if [ "${alertsound}" == "1" ]; then
alertsound=""
alertpriority="0"
elif [ "${alertsound}" == "2" ]; then
# restarted
# restarted.
alertsound="siren"
alertpriority="1"
else
@@ -7,8 +7,8 @@

local commandname="CHECK"

# Every command that requires checks just references check.sh
# check.sh selects which checks to run by using arrays
# Every command that requires checks just references check.sh.
# check.sh selects which checks to run by using arrays.

if [ "${userinput}" != "install" ]&&[ "${userinput}" != "auto-install" ]&&[ "${userinput}" != "i" ]&&[ "${userinput}" != "ai" ]; then
check_root.sh
@@ -102,7 +102,7 @@ fn_install_mono_repo(){
}

fn_install_universe_repo(){
# Defensive coding - As this is an ubuntu only issue then check to make sure this fix is needed, and we are using ubuntu
# Defensive coding - As this is an ubuntu only issue then check to make sure this fix is needed, and we are using ubuntu.
if [ "${jquniversemissing}" != "0" ]&&[ "${distroid}" == "ubuntu" ]; then
fn_print_warning_nl "Ubuntu 18.04.1 contains a bug which means the sources.list file does not populate with the Ubuntu universe repository."
fn_print_information_nl "Attempting to add Universe Repo"
@@ -138,7 +138,7 @@ fn_install_universe_repo(){
}

fn_deps_detector(){
# Checks if dependency is missing
# Checks if dependency is missing.
if [ "${tmuxcheck}" == "1" ]; then
# Added for users compiling tmux from source to bypass check.
depstatus=0
@@ -152,16 +152,16 @@ fn_deps_detector(){
elif [ "${deptocheck}" == "jq" ]&&[ "${distroversion}" == "6" ]; then
jqstatus=1
elif [ "${deptocheck}" == "jq" ]&&[ "${distroid}" == "ubuntu" ]&&[ "${distroversion}" == "18.04" ]&& ! grep -qE "^deb .*universe" /etc/apt/sources.list; then
#1985 ubuntu 18.04.1 bug does not set sources.list correctly which means universe is not active by default
#If the universe repo does not exist, mark as dependency missing and universe missing
# #1985 ubuntu 18.04.1 bug does not set sources.list correctly which means universe is not active by default
# If the universe repo does not exist, mark as dependency missing and universe missing.
depstatus=1
jquniversemissing=1
elif [ "${deptocheck}" == "mono-complete" ]; then
if [ "$(command -v mono 2>/dev/null)" ]&&[ "$(mono --version 2>&1 | grep -Po '(?<=version )\d')" -ge 5 ]; then
# Mono >= 5.0.0 already installed
# Mono >= 5.0.0 already installed.
depstatus=0
else
# Mono not installed or installed Mono < 5.0.0
# Mono not installed or installed Mono < 5.0.0.
depstatus=1
monostatus=1
fi
@@ -174,35 +174,35 @@ fn_deps_detector(){
fi

if [ "${depstatus}" == "0" ]; then
# if dependency is found
# If dependency is found.
missingdep=0
if [ "${function_selfname}" == "command_install.sh" ]; then
echo -e "${green}${deptocheck}${default}"
fn_sleep_time
fi
else
# if dependency is not found
# If dependency is not found.
missingdep=1
if [ "${function_selfname}" == "command_install.sh" ]; then
echo -e "${red}${deptocheck}${default}"
fn_sleep_time
fi
# Define required dependencies for SteamCMD
# Define required dependencies for SteamCMD.
if [ -n "${appid}" ]; then
if [ "${deptocheck}" == "glibc.i686" ]||[ "${deptocheck}" == "libstdc++64.i686" ]||[ "${deptocheck}" == "lib32gcc1" ]||[ "${deptocheck}" == "libstdc++6:i386" ]; then
steamcmdfail=1
fi
fi
fi

# Missing dependencies are added to array_deps_missing
# Missing dependencies are added to array_deps_missing.
if [ "${missingdep}" == "1" ]; then
array_deps_missing+=("${deptocheck}")
fi
}

fn_deps_email(){
# Adds postfix to required dependencies if email alert is enabled
# Adds postfix to required dependencies if email alert is enabled.
if [ "${emailalert}" == "on" ]; then
if [ -f /usr/bin/mailx ]; then
if [ -d /etc/exim4 ]; then
@@ -316,25 +316,25 @@ fn_found_missing_deps(){
}

fn_check_loop(){
# Loop though required depenencies
# Loop though required depenencies.
for deptocheck in "${array_deps_required[@]}"
do
fn_deps_detector
done

# user to be informed of any missing dependencies
# user to be informed of any missing dependencies.
fn_found_missing_deps
}

# Generate require dependencies for debian based systems
# Generate require dependencies for debian based systems.
fn_deps_build_debian(){
# Generate array of missing deps
# Generate array of missing deps.
array_deps_missing=()

## LinuxGSM requirements
# LinuxGSM requirements.
array_deps_required=( curl wget ca-certificates file bsdmainutils util-linux python bzip2 gzip unzip binutils bc jq )

# All servers except ts3 require tmux
# All servers except ts3 require tmux.
if [ "${shortname}" != "ts3" ]; then
if [ "$(command -v tmux 2>/dev/null)" ]; then
tmuxcheck=1 # Added for users compiling tmux from source to bypass check.
@@ -343,7 +343,7 @@ fn_deps_build_debian(){
fi
fi

# All servers except ts3, mumble, GTA and minecraft servers require libstdc++6 and lib32gcc1
# All servers except ts3, mumble, GTA and minecraft servers require libstdc++6 and lib32gcc1.
if [ "${shortname}" != "ts3" ]&&[ "${shortname}" != "mumble" ]&&[ "${shortname}" != "mc" ]&&[ "${engine}" != "renderware" ]; then
if [ "${arch}" == "x86_64" ]; then
array_deps_required+=( lib32gcc1 libstdc++6:i386 )
@@ -352,9 +352,9 @@ fn_deps_build_debian(){
fi
fi

## Game Specific requirements
# Game Specific requirements.

# Natural Selection 2 - x64 only
# Natural Selection 2 - x64 only.
if [ "${shortname}" == "ns2" ]; then
array_deps_required+=( speex libtbb2 )
# NS2: Combat
@@ -392,14 +392,16 @@ fn_deps_build_debian(){
elif [ "${shortname}" == "mc" ]; then
javaversion=$(java -version 2>&1 | grep "version")
if [ "${javaversion}" ]; then
javacheck=1 # Added for users using Oracle JRE to bypass the check.
# Added for users using Oracle JRE to bypass the check.
javacheck=1
else
array_deps_required+=( openjdk-8-jre-headless )
fi
# Project Zomboid
elif [ "${shortname}" == "pz" ]; then
if [ -n "$(java -version 2>&1 | grep "version")" ]; then
javacheck=1 # Added for users using Oracle JRE to bypass the check.
# Added for users using Oracle JRE to bypass the check.
javacheck=1
array_deps_required+=( rng-tools )
else
array_deps_required+=( default-jre rng-tools )
@@ -415,10 +417,10 @@ fn_deps_build_debian(){
array_deps_required+=( libssl1.0.0:i386 zlib1g:i386 )
# Unreal Engine
elif [ "${executable}" == "./ucc-bin" ]; then
#UT2K4
# UT2K4
if [ -f "${executabledir}/ut2004-bin" ]; then
array_deps_required+=( libsdl1.2debian libstdc++5:i386 )
#UT99
# UT99
else
array_deps_required+=( libsdl1.2debian )
fi
@@ -437,11 +439,11 @@ fn_deps_build_debian(){
}

fn_deps_build_redhat(){
# Generate array of missing deps
# Generate array of missing deps.
array_deps_missing=()

# LinuxGSM requirements
## CentOS 6
# LinuxGSM requirements.
# CentOS 6
if [ "${distroversion}" == "6" ]; then
array_deps_required=( epel-release curl wget util-linux-ng python file gzip bzip2 unzip binutils bc jq )
elif [ "${distroversion}" == "7" ]; then
@@ -454,16 +456,17 @@ fn_deps_build_redhat(){
array_deps_required=( curl wget util-linux python file gzip bzip2 unzip binutils bc jq )
fi

# All servers except ts3 require tmux
# All servers except ts3 require tmux.
if [ "${shortname}" != "ts3" ]; then
if [ "$(command -v tmux 2>/dev/null)" ]; then
tmuxcheck=1 # Added for users compiling tmux from source to bypass check.
# Added for users compiling tmux from source to bypass check.
tmuxcheck=1
else
array_deps_required+=( tmux )
fi
fi

# All servers except ts3,mumble,multitheftauto and minecraft servers require glibc.i686 and libstdc++.i686
# All servers except ts3, mumble, multi theft auto and minecraft servers require glibc.i686 and libstdc++.i686.
if [ "${shortname}" != "ts3" ]&&[ "${shortname}" != "mumble" ]&&[ "${shortname}" != "mc" ]&&[ "${engine}" != "renderware" ]; then
if [[ "${distroname}" == *"Amazon Linux AMI"* ]]; then
array_deps_required+=( glibc.i686 libstdc++64.i686 )
@@ -472,7 +475,7 @@ fn_deps_build_redhat(){
fi
fi

# Game Specific requirements
# Game Specific requirements.

# Natural Selection 2 (x64 only)
if [ "${shortname}" == "ns2" ]; then
@@ -507,7 +510,8 @@ fn_deps_build_redhat(){
elif [ "${shortname}" == "mc" ]; then
javaversion=$(java -version 2>&1 | grep "version")
if [ "${javaversion}" ]; then
javacheck=1 # Added for users using Oracle JRE to bypass the check.
# Added for users using Oracle JRE to bypass the check.
javacheck=1
array_deps_required+=( rng-tools )
else
array_deps_required+=( java-1.8.0-openjdk rng-tools )
@@ -516,7 +520,8 @@ fn_deps_build_redhat(){
elif [ "${shortname}" == "pz" ]; then
javaversion=$(java -version 2>&1 | grep "version")
if [ "${javaversion}" ]; then
javacheck=1 # Added for users using Oracle JRE to bypass the check.
# Added for users using Oracle JRE to bypass the check.
javacheck=1
array_deps_required+=( rng-tools )
else
array_deps_required+=( java-1.8.0-openjdk rng-tools )
@@ -559,7 +564,7 @@ if [ "${function_selfname}" == "command_install.sh" ]; then
fi
fi

# Filter checking in to Debian or Red Hat Based
# Filter checking in to Debian or Red Hat Based.
info_distro.sh
if [ -f "/etc/debian_version" ]; then
fn_deps_build_debian
@@ -18,26 +18,26 @@ if [ "${shortname}" != "ts3" ]&&[ "${shortname}" != "mumble" ]&&[ "${travistest}
info_config.sh
info_parms.sh

# IP is not set to specific IP
# IP is not set to specific IP.
if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then
fn_print_dots "Check IP"
# Multiple interfaces
# Multiple interfaces.
if [ "${getipwc}" -ge "2" ]; then
if [ "${function_selfname}" == "command_details.sh" ]; then
fn_print_warn "Check IP: Multiple IP addresses found."
else
fn_print_fail "Check IP: Multiple IP addresses found."
fi
echo -en "\n"
# IP is set within game config
# IP is set within game config.
if [ "${ipsetinconfig}" == "1" ]; then
fn_print_information "Specify the IP you want to bind within ${servercfg}.\n"
echo -en " * location: ${servercfgfullpath}\n"
echo -en "\n"
echo -en "Set ${ipinconfigvar} to one of the following:\n"
fn_script_log_fatal "Multiple IP addresses found."
fn_script_log_fatal "Specify the IP you want to bind within: ${servercfgfullpath}."
# IP is set within LinuxGSM config
# IP is set within LinuxGSM config.
else
fn_print_information_nl "Specify the IP you want to bind within a LinuxGSM config file.\n"
echo -en " * location: ${configdirserver}\n"
@@ -54,14 +54,14 @@ if [ "${shortname}" != "ts3" ]&&[ "${shortname}" != "mumble" ]&&[ "${travistest}
echo -en "\n"
echo -en "https://linuxgsm.com/network-interfaces\n"
echo -en ""
# Do not exit for details and postdetails commands
# Do not exit for details and postdetails commands.
if [ "${function_selfname}" != "command_details.sh" ]||[ "${function_selfname}" != "command_postdetails.sh" ]; then
fn_script_log_fatal "https://linuxgsm.com/network-interfaces\n"
core_exit.sh
else
ip="NOT SET"
fi
# Single interface
# Single interface.
elif [ "${ipsetinconfig}" == "1" ]; then
fn_print_fail "Check IP: IP address not set in game config."
echo -en "\n"
@@ -14,13 +14,13 @@ fn_check_logs(){
install_logs.sh
}

# Create directories for the script and console logs
# Create directories for the script and console logs.
if [ ! -d "${lgsmlogdir}" ]||[ ! -d "${consolelogdir}" ]&&[ "${shortname}" != "ts3" ]; then
fn_check_logs
fi

# Create gamelogdir
# If variable exists gamelogdir exists and log/server does not
# Create gamelogdir.
# If variable exists gamelogdir exists and log/server does not.
if [ -n "${gamelogdir}" ]&&[ -d "${gamelogdir}" ]&&[ ! -d "${logdir}/server" ]; then
fn_check_logs
fi

0 comments on commit e0acffa

Please sign in to comment.
You can’t perform that action at this time.