Browse Source

Merge pull request #914 from dgibbs64/exitcodes

Exitcodes
pull/853/merge
Daniel Gibbs 9 years ago
committed by GitHub
parent
commit
1f65247624
  1. 8
      functions/command_update_functions.sh
  2. 6
      functions/core_functions.sh
  3. 29
      lgsm/functions/alert.sh
  4. 20
      lgsm/functions/alert_email.sh
  5. 12
      lgsm/functions/alert_pushbullet.sh
  6. 5
      lgsm/functions/check.sh
  7. 13
      lgsm/functions/check_config.sh
  8. 37
      lgsm/functions/check_deps.sh
  9. 22
      lgsm/functions/check_glibc.sh
  10. 16
      lgsm/functions/check_ip.sh
  11. 9
      lgsm/functions/check_logs.sh
  12. 102
      lgsm/functions/check_permissions.sh
  13. 8
      lgsm/functions/check_root.sh
  14. 7
      lgsm/functions/check_status.sh
  15. 17
      lgsm/functions/check_steamcmd.sh
  16. 8
      lgsm/functions/check_system_dir.sh
  17. 9
      lgsm/functions/check_tmux.sh
  18. 30
      lgsm/functions/command_backup.sh
  19. 25
      lgsm/functions/command_console.sh
  20. 39
      lgsm/functions/command_debug.sh
  21. 168
      lgsm/functions/command_details.sh
  22. 20
      lgsm/functions/command_dev_debug.sh
  23. 9
      lgsm/functions/command_dev_detect_deps.sh
  24. 67
      lgsm/functions/command_fastdl.sh
  25. 16
      lgsm/functions/command_install.sh
  26. 55
      lgsm/functions/command_monitor.sh
  27. 14
      lgsm/functions/command_restart.sh
  28. 64
      lgsm/functions/command_start.sh
  29. 153
      lgsm/functions/command_stop.sh
  30. 12
      lgsm/functions/command_test_alert.sh
  31. 18
      lgsm/functions/command_ts3_server_pass.sh
  32. 22
      lgsm/functions/command_update.sh
  33. 49
      lgsm/functions/command_update_functions.sh
  34. 35
      lgsm/functions/command_validate.sh
  35. 6
      lgsm/functions/compress_unreal2_maps.sh
  36. 6
      lgsm/functions/compress_ut99_maps.sh
  37. 59
      lgsm/functions/core_dl.sh
  38. 38
      lgsm/functions/core_exit.sh
  39. 43
      lgsm/functions/core_functions.sh
  40. 282
      lgsm/functions/core_getopt.sh
  41. 295
      lgsm/functions/core_messages.sh
  42. 13
      lgsm/functions/core_trap.sh
  43. 14
      lgsm/functions/fix.sh
  44. 6
      lgsm/functions/fix_arma3.sh
  45. 6
      lgsm/functions/fix_csgo.sh
  46. 6
      lgsm/functions/fix_dst.sh
  47. 6
      lgsm/functions/fix_glibc.sh
  48. 13
      lgsm/functions/fix_ins.sh
  49. 6
      lgsm/functions/fix_kf.sh
  50. 6
      lgsm/functions/fix_ro.sh
  51. 6
      lgsm/functions/fix_steamcmd.sh
  52. 6
      lgsm/functions/fix_ut2k4.sh
  53. 7
      lgsm/functions/fix_ut99.sh
  54. 2
      lgsm/functions/fn_functions
  55. 2
      lgsm/functions/fn_getopt
  56. 7
      lgsm/functions/fn_update_functions
  57. 4
      lgsm/functions/gsquery.py
  58. 8
      lgsm/functions/info_config.sh
  59. 88
      lgsm/functions/info_distro.sh
  60. 4
      lgsm/functions/info_glibc.sh
  61. 8
      lgsm/functions/info_parms.sh
  62. 8
      lgsm/functions/install_complete.sh
  63. 26
      lgsm/functions/install_config.sh
  64. 16
      lgsm/functions/install_gslt.sh
  65. 5
      lgsm/functions/install_gsquery.sh
  66. 5
      lgsm/functions/install_header.sh
  67. 7
      lgsm/functions/install_logs.sh
  68. 5
      lgsm/functions/install_retry.sh
  69. 7
      lgsm/functions/install_server_dir.sh
  70. 20
      lgsm/functions/install_server_files.sh
  71. 5
      lgsm/functions/install_steamcmd.sh
  72. 81
      lgsm/functions/install_ts3.sh
  73. 7
      lgsm/functions/install_ts3db.sh
  74. 7
      lgsm/functions/install_ut2k4_key.sh
  75. 12
      lgsm/functions/logs.sh
  76. 27
      lgsm/functions/monitor_gsquery.sh
  77. 342
      lgsm/functions/update_check.sh
  78. 83
      lgsm/functions/update_dl.sh
  79. 238
      lgsm/functions/update_steamcmd.sh
  80. 182
      lgsm/functions/update_ts3.sh
  81. 398
      tests/tests_jc2server.sh
  82. 355
      tests/tests_ts3server.sh

8
functions/command_update_functions.sh

@ -6,10 +6,10 @@ lgsm_version="210516"
# Description: Deletes the functions dir to allow re-downloading of functions from GitHub. # Description: Deletes the functions dir to allow re-downloading of functions from GitHub.
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
check.sh check.sh
fn_print_dots "Updating functions" fn_print_dots "Updating functions"
fn_scriptlog "Updating functions" fn_script_log "Updating functions"
sleep 1 sleep 1
echo -ne "\n" echo -ne "\n"
@ -30,9 +30,9 @@ fi
if [ "${exitcode}" == "0" ]; then if [ "${exitcode}" == "0" ]; then
fn_print_ok "Updating functions" fn_print_ok "Updating functions"
fn_scriptlog "Success! Updating functions" fn_script_log "Success! Updating functions"
else else
fn_print_fail "Updating functions" fn_print_fail "Updating functions"
fn_scriptlog "Failure! Updating functions" fn_script_log "Failure! Updating functions"
fi fi
echo -ne "\n" echo -ne "\n"

6
functions/core_functions.sh

@ -46,15 +46,15 @@ if [ ! -f "${filedir}/${filename}" ]; then
if [ "$(basename ${curlcmd})" == "curl" ]; then if [ "$(basename ${curlcmd})" == "curl" ]; then
curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo -e "\e[0;31mFAIL\e[0m\n" echo -e "${red}FAIL${default}\n"
echo "${curlfetch}" echo "${curlfetch}"
echo -e "${githuburl}\n" echo -e "${githuburl}\n"
exit 1 exit 1
else else
echo -e "\e[0;32mOK\e[0m" echo -e "${green}OK${default}"
fi fi
else else
echo -e "\e[0;31mFAIL\e[0m\n" echo -e "${red}FAIL${default}\n"
echo "Curl is not installed!" echo "Curl is not installed!"
echo -e "" echo -e ""
exit 1 exit 1

29
lgsm/functions/alert.sh

@ -2,30 +2,31 @@
# LGSM alert.sh function # LGSM alert.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Overall function for managing alerts. # Description: Overall function for managing alerts.
local commandname="ALERT"
local commandaction="Alert"
fn_alert_test(){ fn_alert_test(){
fn_scriptlog "Sending test alert" fn_script_log_info "Sending test alert"
alertsubject="LGSM - Test Alert - ${servername}" alertsubject="LGSM - Test Alert - ${servername}"
alertbody="LGSM test alert, how you read?" alertbody="LGSM test alert, how you read?"
} }
fn_alert_restart(){ fn_alert_restart(){
fn_scriptlog "Sending restart alert: ${executable} process not running" fn_script_log_info "Sending restart alert: ${executable} process not running"
alertsubject="LGSM - Restarted - ${servername}" alertsubject="LGSM - Restarted - ${servername}"
alertbody="${servicename} ${executable} process not running" alertbody="${servicename} ${executable} process not running"
} }
fn_alert_restart_query(){ fn_alert_restart_query(){
fn_scriptlog "Sending restart alert: ${gsquerycmd}" fn_script_log_info "Sending restart alert: ${gsquerycmd}"
alertsubject="LGSM - Restarted - ${servername}" alertsubject="LGSM - Restarted - ${servername}"
alertbody="gsquery.py failed to query: ${gsquerycmd}" alertbody="gsquery.py failed to query: ${gsquerycmd}"
} }
fn_alert_update(){ fn_alert_update(){
fn_scriptlog "Sending update alert" fn_script_log_info "Sending update alert"
alertsubject="LGSM - Updated - ${servername}" alertsubject="LGSM - Updated - ${servername}"
alertbody="${servicename} recieved update" alertbody="${servicename} recieved update"
} }
@ -43,19 +44,19 @@ fi
if [ "${emailnotification}" == "on" ]||[ "${emailalert}" == "on" ]&&[ -n "${email}" ]; then if [ "${emailnotification}" == "on" ]||[ "${emailalert}" == "on" ]&&[ -n "${email}" ]; then
alert_email.sh alert_email.sh
elif [ "${emailnotification}" != "on" ]||[ "${emailalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then elif [ "${emailnotification}" != "on" ]||[ "${emailalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_info_nl "Email alerts not enabled" fn_print_warn_nl "Email alerts not enabled"
fn_scriptlog "Email alerts not enabled" fn_script_log_warn "Email alerts not enabled"
elif [ -z "${email}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then elif [ -z "${email}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_fail_nl "Email not set" fn_print_error_nl "Email not set"
fn_scriptlog "Email not set" fn_script_log_error "Email not set"
fi fi
if [ "${pushbulletalert}" == "on" ]&&[ -n "${pushbullettoken}" ]; then if [ "${pushbulletalert}" == "on" ]&&[ -n "${pushbullettoken}" ]; then
alert_pushbullet.sh alert_pushbullet.sh
elif [ "${pushbulletalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then elif [ "${pushbulletalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_info_nl "Pushbullet alerts not enabled" fn_print_warn_nl "Pushbullet alerts not enabled"
fn_scriptlog "Pushbullet alerts not enabled" fn_script_log_warn "Pushbullet alerts not enabled"
elif [ -z "${pushbullettoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then elif [ -z "${pushbullettoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
fn_print_fail_nl "Pushbullet token not set" fn_print_error_nl "Pushbullet token not set"
fn_scriptlog "Pushbullet token not set" fn_script_error_warn "Pushbullet token not set"
fi fi

20
lgsm/functions/alert_email.sh

@ -1,13 +1,12 @@
#!/bin/bash #!/bin/bash
# LGSM email.sh function # LGSM alert_email.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Sends email alert if monitor picks up a failure. # Description: Sends email alert if monitor picks up a failure.
local modulename="Alert" local commandname="ALERT"
local commandaction="Alert"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_details_email(){ fn_details_email(){
# #
@ -214,7 +213,8 @@ fn_alert_email_template_logs(){
} | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"| tee -a "${emaillog}" > /dev/null 2>&1 } | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"| tee -a "${emaillog}" > /dev/null 2>&1
} }
fn_print_dots "Sending alert to ${email}" fn_print_dots "Sending alert: ${email}"
fn_script_log_info "Sending alert: ${email}"
info_distro.sh info_distro.sh
info_config.sh info_config.sh
info_glibc.sh info_glibc.sh
@ -233,9 +233,9 @@ fn_alert_email_template_logs
mail -s "${alertsubject}" "${email}" < "${emaillog}" mail -s "${alertsubject}" "${email}" < "${emaillog}"
exitcode=$? exitcode=$?
if [ "${exitcode}" == "0" ]; then if [ "${exitcode}" == "0" ]; then
fn_print_ok_nl "Sending alert to ${email}" fn_print_ok_nl "Sending alert: ${email}"
fn_scriptlog "Success! Sending alert to ${email}" fn_script_log_pass "Sending alert: ${email}"
else else
fn_print_fail_nl "Sending alert to ${email}" fn_print_fail_nl "Sending alert: ${email}"
fn_scriptlog "Failure! Sending alert to ${email}" fn_script_log_fatal "Sending alert: ${email}"
fi fi

12
lgsm/functions/alert_pushbullet.sh

@ -2,12 +2,12 @@
# LGSM alert_pushbullet.sh function # LGSM alert_pushbullet.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: alerts using pushbullet. # Description: alerts using pushbullet.
local modulename="Alert" local commandname="ALERT"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="Alert"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_print_dots "Sending Pushbullet alert" fn_print_dots "Sending Pushbullet alert"
sleep 1 sleep 1
@ -15,8 +15,8 @@ pushbulletsend=$(curl --silent -u """${pushbullettoken}"":" -d type="note" -d bo
if [ "${pushbulletsend}" == "invalid_access_token" ]; then if [ "${pushbulletsend}" == "invalid_access_token" ]; then
fn_print_fail_nl "Sending Pushbullet alert: invalid_access_token" fn_print_fail_nl "Sending Pushbullet alert: invalid_access_token"
fn_scriptlog "Failure! Sending Pushbullet alert: invalid_access_token" fn_script_log_fatal "Sending Pushbullet alert: invalid_access_token"
else else
fn_print_ok_nl "Sending Pushbullet alert" fn_print_ok_nl "Sending Pushbullet alert"
fn_scriptlog "Complete! Sent Pushbullet alert" fn_script_log_pass "Sent Pushbullet alert"
fi fi

5
lgsm/functions/check.sh

@ -1,12 +1,13 @@
#!/bin/bash #!/bin/bash
# LGSM fn_check function # LGSM check.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Overall function for managing checks. # Description: Overall function for managing checks.
# Runs checks that will either halt on or fix an issue. # Runs checks that will either halt on or fix an issue.
local commandname="CHECK"
# Every command that requires checks just references check.sh # Every command that requires checks just references check.sh
# check.sh selects which checks to run by using arrays # check.sh selects which checks to run by using arrays

13
lgsm/functions/check_config.sh

@ -2,16 +2,19 @@
# LGSM check_config.sh function # LGSM check_config.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: If server config missing warn user. # Description: If server config missing warn user.
local commandname="CHECK"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
if [ ! -e "${servercfgfullpath}" ]; then if [ ! -e "${servercfgfullpath}" ]; then
if [ "${gamename}" != "Hurtworld" ]; then if [ "${gamename}" != "Hurtworld" ]; then
fn_print_warn_nl "Config file missing!" fn_print_dots ""
sleep 0.5
fn_print_warn_nl "Configuration file missing!"
echo "${servercfgfullpath}" echo "${servercfgfullpath}"
fn_scriptlog "Configuration file missing!" fn_script_log_warn "Configuration file missing!"
fn_scriptlog "${servercfgfullpath}" fn_script_log_warn "${servercfgfullpath}"
sleep 2 sleep 2
fi fi
fi fi

37
lgsm/functions/check_deps.sh

@ -2,10 +2,9 @@
# LGSM check_deps.sh function # LGSM check_deps.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="090616"
# Description: Checks that the requires dependencies are installed for LGSM. # Description: Checks that the requires dependencies are installed for LGSM.
local commandname="CHECK"
fn_deps_detector(){ fn_deps_detector(){
# Checks if dependency is missing # Checks if dependency is missing
@ -19,14 +18,14 @@ fn_deps_detector(){
if [ "${depstatus}" == "0" ]; then if [ "${depstatus}" == "0" ]; then
missingdep=0 missingdep=0
if [ "${function_selfname}" == "command_install.sh" ]; then if [ "${function_selfname}" == "command_install.sh" ]; then
echo -e "\e[0;32m${deptocheck}\e[0m" echo -e "${green}${deptocheck}${default}"
sleep 0.5 sleep 0.5
fi fi
else else
# if missing dependency is found # if missing dependency is found
missingdep=1 missingdep=1
if [ "${function_selfname}" == "command_install.sh" ]; then if [ "${function_selfname}" == "command_install.sh" ]; then
echo -e "\e[0;31m${deptocheck}\e[0m" echo -e "${red}${deptocheck}${default}"
sleep 0.5 sleep 0.5
fi fi
fi fi
@ -63,14 +62,14 @@ fn_deps_email(){
fn_found_missing_deps(){ fn_found_missing_deps(){
if [ "${#array_deps_missing[@]}" != "0" ]; then if [ "${#array_deps_missing[@]}" != "0" ]; then
fn_print_dots "Checking dependencies" fn_print_dots "Checking dependencies"
sleep 2 sleep 0.5
fn_print_warn "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m" fn_print_error "Checking dependencies: missing: ${red}${array_deps_missing[@]}${default}"
fn_scriptlog "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m" fn_script_log_error "Checking dependencies: missing: ${red}${array_deps_missing[@]}${default}"
sleep 1 sleep 1
echo -e ""
sudo -n true > /dev/null 2>&1 sudo -n true > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
fn_print_info_nl "Attempting to install missing dependencies automatically" fn_print_infomation_nl "Automatically installing missing dependencies."
fn_script_log_info "Automatically installing missing dependencies."
echo -en ".\r" echo -en ".\r"
sleep 1 sleep 1
echo -en "..\r" echo -en "..\r"
@ -80,20 +79,26 @@ fn_found_missing_deps(){
echo -en " \r" echo -en " \r"
if [ -n "$(command -v dpkg-query)" ]; then if [ -n "$(command -v dpkg-query)" ]; then
cmd="sudo dpkg --add-architecture i386; sudo apt-get -y install ${array_deps_missing[@]}" cmd="sudo dpkg --add-architecture i386; sudo apt-get -y install ${array_deps_missing[@]}"
eval $cmd eval ${cmd}
elif [ -n "$(command -v yum)" ]; then elif [ -n "$(command -v yum)" ]; then
cmd="sudo yum -y install ${array_deps_missing[@]}" cmd="sudo yum -y install ${array_deps_missing[@]}"
eval $cmd eval ${cmd}
fi
if [ $? != 0 ]; then
fn_print_failure_nl "Unable to install dependencies"
fn_script_log_fail "Unable to install dependencies"
else
fn_print_success_nl "Install dependencies completed"
fn_script_log_pass "Install dependencies completed"
fi fi
else else
echo "" echo ""
fn_print_infomation_nl "$(whoami) does not have sudo access. Please manually install dependencies" fn_print_warning_nl "$(whoami) does not have sudo access. Manually install dependencies."
fn_scriptlog "$(whoami) does not have sudo access. Please manually install dependencies" fn_script_log_warn "$(whoami) does not have sudo access. Manually install dependencies."
echo ""
if [ -n "$(command -v dpkg-query)" ]; then if [ -n "$(command -v dpkg-query)" ]; then
echo "sudo dpkg --add-architecture i386; sudo apt-get install ${array_deps_missing[@]}" echo " sudo dpkg --add-architecture i386; sudo apt-get install ${array_deps_missing[@]}"
elif [ -n "$(command -v yum)" ]; then elif [ -n "$(command -v yum)" ]; then
echo "sudo yum install ${array_deps_missing[@]}" echo " sudo yum install ${array_deps_missing[@]}"
fi fi
echo "" echo ""
fi fi

22
lgsm/functions/check_glibc.sh

@ -2,32 +2,38 @@
# LGSM check_glibc.sh function # LGSM check_glibc.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Checks if server has correct glibc or has a fix available. # Description: Checks if server has correct glibc or has a fix available.
local commandname="CHECK"
info_glibc.sh info_glibc.sh
info_distro.sh info_distro.sh
if [ "${glibcrequired}" == "NOT REQUIRED" ]; then if [ "${glibcrequired}" == "NOT REQUIRED" ]; then
: :
elif [ "${glibcrequired}" == "UNKNOWN" ]; then elif [ "${glibcrequired}" == "UNKNOWN" ]; then
fn_print_info_nl "Glibc fix: \e[0;31m${glibcrequired}\e[0m" fn_print_dots "Glibc fix"
echo -e " * glibc required: \e[0;31m${glibcrequired}\e[0m" sleep 0.5
fn_print_error_nl "Glibc fix: ${red}${glibcrequired}${default}"
echo -e " * glibc required: ${red}${glibcrequired}${default}"
echo -e " * glibc installed: ${glibcversion}" echo -e " * glibc installed: ${glibcversion}"
elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibcrequired}" ]; then elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibcrequired}" ]; then
if [ "${glibcfix}" == "yes" ]; then if [ "${glibcfix}" == "yes" ]; then
if [ "${function_selfname}" != "command_install.sh" ]; then if [ "${function_selfname}" != "command_install.sh" ]; then
fn_print_info_nl "Glibc fix: \e[0;32mUsing Glibc fix\e[0m" fn_print_dots "Glibc fix"
echo -e " * glibc required: \e[0;31m${glibcrequired}\e[0m" sleep 0.5
fn_print_info_nl "Glibc fix: ${green}Using Glibc fix${default}"
echo -e " * glibc required: ${red}${glibcrequired}${default}"
echo -e " * glibc installed: ${glibcversion}" echo -e " * glibc installed: ${glibcversion}"
fix_glibc.sh fix_glibc.sh
fi fi
else else
fn_print_warn_nl "Glibc fix: \e[0;31mNo Glibc fix available!\e[0m" fn_print_dots "Glibc fix"
sleep 0.5
fn_print_error_nl "Glibc fix: ${red}No Glibc fix available!${default}"
echo -en "\n" echo -en "\n"
echo -e " * glibc required: ${glibcrequired}" echo -e " * glibc required: ${glibcrequired}"
echo -e " * glibc installed: \e[0;31m${glibcversion}\e[0m" echo -e " * glibc installed: ${red}${glibcversion}${default}"
echo -en "\n" echo -en "\n"
fn_print_infomation "The game server will probably not work. A distro upgrade is required!" fn_print_infomation "The game server will probably not work. A distro upgrade is required!"
sleep 5 sleep 5

16
lgsm/functions/check_ip.sh

@ -2,11 +2,12 @@
# LGSM check_ip.sh function # LGSM check_ip.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Automatically identifies the server interface IP. # Description: Automatically identifies the server interface IP.
# If multiple interfaces are detected the user will need to manualy set using ip="0.0.0.0". # If multiple interfaces are detected the user will need to manualy set using ip="0.0.0.0".
local commandname="CHECK"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
if [ "${gamename}" != "Teamspeak 3" ]; then if [ "${gamename}" != "Teamspeak 3" ]; then
if [ ! -f "/bin/ip" ]; then if [ ! -f "/bin/ip" ]; then
ipcommand="/sbin/ip" ipcommand="/sbin/ip"
@ -18,14 +19,19 @@ if [ "${gamename}" != "Teamspeak 3" ]; then
if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then
if [ "${getipwc}" -ge "2" ]; then if [ "${getipwc}" -ge "2" ]; then
fn_print_warn "Multiple active network interfaces found.\n\n" fn_print_dots ""
echo -en "Manually specify the IP you want to use within the ${selfname} script.\n" sleep 0.5
fn_print_fail "Multiple active network interfaces found.\n\n"
fn_print_infomation "Specify the IP you want to use within the ${selfname} script.\n"
echo -en "Set ip=\"0.0.0.0\" to one of the following:\n" echo -en "Set ip=\"0.0.0.0\" to one of the following:\n"
echo -en "${getip}\n" echo -en "${getip}\n"
echo -en "" echo -en ""
echo -en "https://gameservermanagers.com/network-interfaces\n" echo -en "https://gameservermanagers.com/network-interfaces\n"
echo -en "" echo -en ""
exit 1 fn_script_log_fatal "Multiple active network interfaces found."
fn_script_log_fatal "Manually specify the IP you want to use within the ${selfname} script."
fn_script_log_fatal "https://gameservermanagers.com/network-interfaces\n"
core_exit.sh
else else
ip=${getip} ip=${getip}
fi fi

9
lgsm/functions/check_logs.sh

@ -2,14 +2,15 @@
# LGSM check_logs.sh function # LGSM check_logs.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Checks that log files exist on server start # Description: Checks that log files exist on server start
local commandname="CHECK"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
# Create dir's for the script and console logs # Create dir's for the script and console logs
if [ ! -d "${scriptlogdir}" ]; then if [ ! -d "${scriptlogdir}" ]||[ ! -d "${consolelogdir}" ]&&[ "${gamename}" != "Teamspeak 3" ]; then
fn_print_dots "Checking for log files" fn_print_dots "Checking for log files"
sleep 1 sleep 0.5
fn_print_info_nl "Checking for log files: Creating log files" fn_print_info_nl "Checking for log files: Creating log files"
checklogs=1 checklogs=1
install_logs.sh install_logs.sh

102
lgsm/functions/check_permissions.sh

@ -3,53 +3,40 @@
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Contributor: UltimateByte # Contributor: UltimateByte
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Checks script, files and folders ownership and permissions. # Description: Checks script, files and folders ownership and permissions.
# Useful variables local commandname="CHECK"
currentuser="$(whoami)" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
currentgroups="$(groups)"
scriptfullpath="${rootdir}/${selfname}"
conclusionpermissionerror="0"
fn_check_ownership(){ fn_check_ownership(){
# Check script ownership if [ $(find "${rootdir}" -not -user $(whoami)|wc -l) -ne "0" ]; then
if [ ! -O "${scriptfullpath}" ] && [ ! -G "${scriptfullpath}" ]; then fn_print_fail_nl "Permissions issues found"
fn_print_fail_nl "Oops ! Ownership issue..." fn_script_log_fatal "Permissions issues found"
echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own \"${selfname}\"" fn_print_infomation_nl "The current user ($(whoami)) does not have ownership of the following files:"
echo " * To check the owner and allowed groups, run ls -l \"${selfname}\"" fn_script_log_info "The current user ($(whoami)) does not have ownership of the following files:"
exit 1 {
fi echo -e "User\tGroup\tFile\n"
find "${rootdir}" -not -user $(whoami) -printf "%u\t\t%g\t%p\n"
# Check rootdir ownership } | column -s $'\t' -t | tee -a "${scriptlog}"
if [ ! -O "${rootdir}" ] && [ ! -G "${rootdir}" ]; then core_exit.sh
fn_print_fail_nl "Oops ! Ownership issue..."
echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own \"${rootdir}\""
echo " * To check the owner and allowed groups, run ls -dl \"${rootdir}\""
exit 1
fi fi
}
# Check functions ownership fn_check_permissions(){
funownfail="0"
if [ -n "${functionsdir}" ]; then if [ -n "${functionsdir}" ]; then
while read -r filename if [ $(find "${functionsdir}" -type f -not -executable|wc -l) -ne "0" ]; then
do fn_print_fail_nl "Permissions issues found"
if [ ! -O "${filename}" ] && [ ! -G "${filename}" ]; then fn_script_log_fatal "Permissions issues found"
funownfail="1" fn_print_infomation_nl "The following files are not executable:"
conclusionpermissionerror="1" fn_script_log_info "The following files are not executable:"
fi {
done <<< "$(find "${functionsdir}" -name "*.sh")" echo -e "File\n"
find "${functionsdir}" -type f -not -executable -printf "%p\n"
if [ "${funownfail}" == "1" ]; then } | column -s $'\t' -t | tee -a "${scriptlog}"
fn_print_fail_nl "Oops ! Ownership issue..." core_exit.sh
echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own all scripts in \"${functionsdir}\""
echo " * To check the owner and allowed groups, run ls -l \"${functionsdir}\""
fi fi
fi fi
}
fn_check_permissions(){
# Check rootdir permissions # Check rootdir permissions
if [ -n "${rootdir}" ]; then if [ -n "${rootdir}" ]; then
# Get permission numbers on folder under the form 775 # Get permission numbers on folder under the form 775
@ -58,42 +45,15 @@ fn_check_permissions(){
userrootdirperm="${rootdirperm:0:1}" userrootdirperm="${rootdirperm:0:1}"
grouprootdirperm="${rootdirperm:1:1}" grouprootdirperm="${rootdirperm:1:1}"
if [ "${userrootdirperm}" != "7" ] && [ "${grouprootdirperm}" != "7" ]; then if [ "${userrootdirperm}" != "7" ] && [ "${grouprootdirperm}" != "7" ]; then
fn_print_fail_nl "Oops ! Permission issue..." fn_print_fail_nl "Permissions issues found"
echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} need full control of \"${rootdir}\"" fn_script_log_fatal "Permissions issues found"
echo " * You might wanna run : chmod -R 770 \"${rootdir}\"" fn_print_infomation_nl "The following directorys does not have the correct permissions:"
conclusionpermissionerror="1" fn_script_log_info "The following directorys does not have the correct permissions:"
ls -l "${rootdir}"
core_exit.sh
fi fi
fi fi
# Check functions permissions
funcpermfail="0"
if [ -n "${functionsdir}" ]; then
while read -r filename
do
funcperm="$(stat -c %a "${filename}")"
userfuncdirperm="${funcperm:0:1}"
groupfuncdirperm="${funcperm:1:1}"
if [ "${userfuncdirperm}" != "7" ] && [ "${groupfuncdirperm}" != "7" ]; then
funcpermfail="1"
conclusionpermissionerror="1"
fi
done <<< "$(find "${functionsdir}" -name "*.sh")"
if [ "${funcpermfail}" == "1" ]; then
fn_print_fail_nl "Oops ! Permission issue..."
echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} need full control on scripts in \"${functionsdir}\""
echo " * You might wanna run : chmod -R 770 \"${functionsdir}\""
fi
fi
}
fn_check_permissions_conclusion(){
# Exit if errors found
if [ "${conclusionpermissionerror}" == "1" ]; then
exit 1
fi
} }
fn_check_ownership fn_check_ownership
fn_check_permissions fn_check_permissions
fn_check_permissions_conclusion

8
lgsm/functions/check_root.sh

@ -2,12 +2,14 @@
# LGSM check_root.sh function # LGSM check_root.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
local commandname="CHECK"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
if [ $(whoami) = "root" ]; then if [ $(whoami) = "root" ]; then
fn_print_fail_nl "Do NOT run this script as root!" fn_print_fail_nl "Do NOT run this script as root!"
if [ -d "${scriptlogdir}" ]; then if [ -d "${scriptlogdir}" ]; then
fn_scriptlog "${selfname} attempted to run as root." fn_script_log_fatal "${selfname} attempted to run as root."
fi fi
exit 1 core_exit.sh
fi fi

7
lgsm/functions/check_status.sh

@ -1,11 +1,12 @@
#!/bin/bash #!/bin/bash
# LGSM check_status function # LGSM check_status.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Checks the proccess status of the server. Either online or offline. # Description: Checks the proccess status of the server. Either online or offline.
local commandname="CHECK"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
if [ "${gamename}" == "Teamspeak 3" ]; then if [ "${gamename}" == "Teamspeak 3" ]; then
# 1: Server is running # 1: Server is running
# 0: Server seems to have died # 0: Server seems to have died

17
lgsm/functions/check_steamcmd.sh

@ -2,10 +2,9 @@
# LGSM check_steamcmd.sh function # LGSM check_steamcmd.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Checks SteamCMD is installed and correct. # Description: Checks SteamCMD is installed and correct.
local commandname="CHECK"
fn_install_steamcmd(){ fn_install_steamcmd(){
if [ ! -d "${steamcmddir}" ]; then if [ ! -d "${steamcmddir}" ]; then
@ -20,18 +19,18 @@ fn_install_steamcmd(){
fn_check_steamcmd_user(){ fn_check_steamcmd_user(){
# Checks steamuser is setup. # Checks steamuser is setup.
if [ "${steamuser}" == "username" ]; then if [ "${steamuser}" == "username" ]; then
fn_print_fail_nl "Steam login not set. Update steamuser." fn_print_fail_nl "Steam login not set. Update steamuser in ${selfname}."
echo " * Change steamuser=\"username\" to a valid steam login." echo " * Change steamuser=\"username\" to a valid steam login."
if [ -d "${scriptlogdir}" ]; then if [ -d "${scriptlogdir}" ]; then
fn_scriptlog "edit ${selfname}. change steamuser=\"username\" to a valid steam login." fn_script_log_fatal "Steam login not set. Update steamuser in ${selfname}."
exit 1
fi fi
core_exit.sh
fi fi
# Anonymous user is set if steamuser is missing # Anonymous user is set if steamuser is missing
if [ -z "${steamuser}" ]; then if [ -z "${steamuser}" ]; then
fn_print_warn_nl "Steam login not set. Using anonymous login." fn_print_error_nl "Steam login not set. Using anonymous login."
if [ -d "${scriptlogdir}" ]; then if [ -d "${scriptlogdir}" ]; then
fn_scriptlog "Steam login not set. Using anonymous login." fn_script_log_error "Steam login not set. Using anonymous login."
fi fi
steamuser="anonymous" steamuser="anonymous"
steampass="" steampass=""
@ -47,8 +46,8 @@ fn_check_steamcmd_sh(){
if [ "${function_selfname}" == "command_install.sh" ]; then if [ "${function_selfname}" == "command_install.sh" ]; then
fn_install_steamcmd fn_install_steamcmd
else else
fn_print_warn_nl "SteamCMD is missing" fn_print_error_nl "SteamCMD is missing"
fn_scriptlog "SteamCMD is missing" fn_script_log_error "SteamCMD is missing"
sleep 1 sleep 1
fn_install_steamcmd fn_install_steamcmd
fi fi

8
lgsm/functions/check_system_dir.sh

@ -2,12 +2,14 @@
# LGSM check_system_dir.sh function # LGSM check_system_dir.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
local commandname="CHECK"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
if [ ! -d "${systemdir}" ]; then if [ ! -d "${systemdir}" ]; then
fn_print_fail_nl "Cannot access ${systemdir}: No such directory" fn_print_fail_nl "Cannot access ${systemdir}: No such directory"
if [ -d "${scriptlogdir}" ]; then if [ -d "${scriptlogdir}" ]; then
fn_scriptlog "Cannot access ${systemdir}: No such directory." fn_script_log_fatal "Cannot access ${systemdir}: No such directory."
fi fi
exit 1 core_exit.sh
fi fi

9
lgsm/functions/check_tmux.sh

@ -2,19 +2,20 @@
# LGSM check_tmux.sh function # LGSM check_tmux.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516" # Description: Checks if tmux is installed as too many users do not RTFM or know how to use Google.
# Checks if tmux is installed as too many users do not RTFM or know how to use Google. local commandname="CHECK"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
if [ "$(command -v tmux)" ]||[ "$(which tmux >/dev/null 2>&1)" ]||[ -f "/usr/bin/tmux" ]||[ -f "/bin/tmux" ]; then if [ "$(command -v tmux)" ]||[ "$(which tmux >/dev/null 2>&1)" ]||[ -f "/usr/bin/tmux" ]||[ -f "/bin/tmux" ]; then
: :
else else
fn_print_fail_nl "Tmux not installed" fn_print_fail_nl "Tmux not installed"
sleep 1 sleep 1
fn_scriptlog "Tmux is not installed" fn_script_log_fatal "Tmux is not installed"
echo " * Tmux is required to run this server." echo " * Tmux is required to run this server."
# Suitable passive agressive message # Suitable passive agressive message
echo " * Please see the the following link." echo " * Please see the the following link."
echo " * https://gameservermanagers.com/tmux-not-found" echo " * https://gameservermanagers.com/tmux-not-found"
exit 127 core_exit.sh
fi fi

30
lgsm/functions/command_backup.sh

@ -2,21 +2,22 @@
# LGSM command_backup.sh function # LGSM command_backup.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Creates a .tar.gz file in the backup directory. # Description: Creates a .tar.gz file in the backup directory.
local modulename="Backup" local commandname="BACKUP"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="Backup"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
check.sh check.sh
info_distro.sh
backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')" backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')"
echo "" fn_print_dots ""
fn_print_info_nl "A total of $(du -sh "${rootdir}" --exclude="${backupdir}" | awk '{print $1}') will be compressed into the following backup:" sleep 0.5
fn_print_info_nl "A total of ${rootdirduexbackup} will be compressed into the following backup:"
echo "${backupdir}/${backupname}.tar.gz" echo "${backupdir}/${backupname}.tar.gz"
echo "" echo ""
while true; do while true; do
read -p "Continue? [Y/N]" yn read -e -i "y" -p "Continue? [Y/N]" yn
case $yn in case $yn in
[Yy]* ) break;; [Yy]* ) break;;
[Nn]* ) echo Exiting; return;; [Nn]* ) echo Exiting; return;;
@ -38,14 +39,21 @@ if [ "${status}" != "0" ]; then
esac esac
done done
fi fi
fn_scriptlog "Started backup"
fn_print_dots "Backup in progress, please wait..." fn_print_dots "Backup in progress, please wait..."
fn_script_log_info "Started backup"
sleep 2 sleep 2
if [ ! -d "${backupdir}" ]; then if [ ! -d "${backupdir}" ]; then
mkdir "${backupdir}" mkdir "${backupdir}"
fi fi
tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "backups" ./* tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "backups" ./*
fn_print_ok_nl "Backup created: ${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size" if [ $? != 0 ]; then
fn_scriptlog "Complete, Backup created: ${backupdir}/${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size" fn_print_ok_nl "Backup created: ${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size"
fn_script_log_pass "Backup created: ${backupdir}/${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size"
else
fn_print_error_nl "Backup failed: ${backupname}.tar.gz"
fn_script_log_error "Backup failed: ${backupname}.tar.gz"
fi
sleep 1 sleep 1
echo "" echo ""
core_exit.sh

25
lgsm/functions/command_console.sh

@ -2,12 +2,11 @@
# LGSM command_console.sh function # LGSM command_console.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Gives access to the server tmux console. # Description: Gives access to the server tmux console.
local modulename="Console" local commandname="CONSOLE"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="Console"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
check.sh check.sh
echo "" echo ""
@ -25,24 +24,28 @@ while true; do
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done done
fn_print_dots "Starting" fn_print_dots "Accessing console"
sleep 1 sleep 1
check_status.sh check_status.sh
if [ "${status}" != "0" ]; then if [ "${status}" != "0" ]; then
fn_print_ok_nl "Starting" fn_print_ok_nl "Accessing console"
fn_scriptlog "accessed" fn_script_log_pass "Console accessed"
sleep 1 sleep 1
tmux attach-session -t ${servicename} tmux attach-session -t ${servicename}
fn_print_ok_nl "Closing console"
fn_script_log_pass "Console closed"
else else
fn_print_fail_nl "Server not running" fn_print_error_nl "Server not running"
fn_scriptlog "Failed to access: Server not running" fn_script_log_error "Failed to access: Server not running"
sleep 1 sleep 1
while true; do while true; do
read -p "Do you want to start the server? [y/N]" yn read -e -i "y" -p "Do you want to start the server? [Y/n]" yn
case $yn in case $yn in
[Yy]* ) command_start.sh; break;; [Yy]* ) exitbypass=1; command_start.sh; break;;
[Nn]* ) break;; [Nn]* ) break;;
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done done
fi fi
core_exit.sh

39
lgsm/functions/command_debug.sh

@ -2,16 +2,27 @@
# LGSM command_debug.sh function # LGSM command_debug.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Runs the server without tmux. Runs direct from the terminal. # Description: Runs the server without tmux. Runs direct from the terminal.
local modulename="Debug" local commandname="DEBUG"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="Debug"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
# Trap to remove lockfile on quit.
fn_lockfile_trap(){
# Remove lock file
rm -f "${rootdir}/${lockselfname}"
# resets terminal. Servers can sometimes mess up the terminal on exit.
reset
fn_print_ok_nl "Closing debug"
fn_script_log_pass "Debug closed"
core_exit.sh
}
check.sh check.sh
fix.sh fix.sh
info_distro.sh info_distro.sh
# NOTE: Check if works with server without parms. Could be intergrated in to info_parms.sh
fn_parms fn_parms
echo "" echo ""
echo "${gamename} Debug" echo "${gamename} Debug"
@ -41,19 +52,29 @@ while true; do
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done done
fn_scriptlog "Starting debug"
fn_print_info_nl "Stopping any running servers" fn_print_info_nl "Stopping any running servers"
fn_scriptlog "Stopping any running servers" fn_script_log_info "Stopping any running servers"
sleep 1 sleep 1
exitbypass=1
command_stop.sh command_stop.sh
fn_print_dots "Starting debug" fn_print_dots "Starting debug"
fn_script_log_info "Starting debug"
sleep 1 sleep 1
fn_print_ok_nl "Starting debug" fn_print_ok_nl "Starting debug"
fn_scriptlog "Started debug"
# create lock file.
date > "${rootdir}/${lockselfname}"
# trap to remove lockfile on quit.
trap fn_lockfile_trap INT
cd "${executabledir}" cd "${executabledir}"
fix.sh
if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
${executable} ${parms} -debug ${executable} ${parms} -debug
else else
${executable} ${parms} ${executable} ${parms}
fi fi
# remove trap.
trap - INT
core_exit.sh

168
lgsm/functions/command_details.sh

@ -2,11 +2,11 @@
# LGSM command_details.sh function # LGSM command_details.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Displays server infomation. # Description: Displays server infomation.
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandname="DETAILS"
local commandaction="Details"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
# Standard Details # Standard Details
# This applies to all engines # This applies to all engines
@ -23,15 +23,15 @@ fn_details_os(){
# GLIBC: 2.19 # GLIBC: 2.19
echo -e "" echo -e ""
echo -e "\e[93mDistro Details\e[0m" echo -e "${lightyellow}Distro Details${default}"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
{ {
echo -e "\e[34mDistro:\t\e[0m${os}" echo -e "${blue}Distro:\t${default}${os}"
echo -e "\e[34mArch:\t\e[0m${arch}" echo -e "${blue}Arch:\t${default}${arch}"
echo -e "\e[34mKernel:\t\e[0m${kernel}" echo -e "${blue}Kernel:\t${default}${kernel}"
echo -e "\e[34mHostname:\t\e[0m$HOSTNAME" echo -e "${blue}Hostname:\t${default}$HOSTNAME"
echo -e "\e[34mtmux:\t\e[0m${tmuxv}" echo -e "${blue}tmux:\t${default}${tmuxv}"
echo -e "\e[34mGLIBC:\t\e[0m${glibcversion}" echo -e "${blue}GLIBC:\t${default}${glibcversion}"
} | column -s $'\t' -t } | column -s $'\t' -t
} }
@ -47,17 +47,17 @@ fn_details_performance(){
# Swap: 0B 0B 0B # Swap: 0B 0B 0B
echo -e "" echo -e ""
echo -e "\e[93mPerformance\e[0m" echo -e "${lightyellow}Performance${default}"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
{ {
echo -e "\e[34mUptime:\t\e[0m${days}d, ${hours}h, ${minutes}m" echo -e "${blue}Uptime:\t${default}${days}d, ${hours}h, ${minutes}m"
echo -e "\e[34mAvg Load:\t\e[0m${load}" echo -e "${blue}Avg Load:\t${default}${load}"
} | column -s $'\t' -t } | column -s $'\t' -t
echo -e "" echo -e ""
{ {
echo -e "\e[34mMem:\t\e[34mtotal\t used\t free\e[0m" echo -e "${blue}Mem:\t${blue}total\t used\t free${default}"
echo -e "\e[34mPhysical:\t\e[0m${physmemtotal}\t${physmemused}\t${physmemfree}\e[0m" echo -e "${blue}Physical:\t${default}${physmemtotal}\t${physmemused}\t${physmemfree}${default}"
echo -e "\e[34mSwap:\t\e[0m${swaptotal}\t${swapused}\t${swapfree}\e[0m" echo -e "${blue}Swap:\t${default}${swaptotal}\t${swapused}\t${swapfree}${default}"
} | column -s $'\t' -t } | column -s $'\t' -t
} }
@ -69,19 +69,22 @@ fn_details_disk(){
# Total: 15G # Total: 15G
# Used: 8.4G # Used: 8.4G
# Available: 5.7G # Available: 5.7G
# LGSM Total: 1G
# Serverfiles: 961M # Serverfiles: 961M
# Backups: 2G
echo -e "" echo -e ""
echo -e "\e[93mStorage\e[0m" echo -e "${lightyellow}Storage${default}"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
{ {
echo -e "\e[34mFilesystem:\t\e[0m${filesystem}" echo -e "${blue}Filesystem:\t${default}${filesystem}"
echo -e "\e[34mTotal:\t\e[0m${totalspace}" echo -e "${blue}Total:\t${default}${totalspace}"
echo -e "\e[34mUsed:\t\e[0m${usedspace}" echo -e "${blue}Used:\t${default}${usedspace}"
echo -e "\e[34mAvailable:\t\e[0m${availspace}" echo -e "${blue}Available:\t${default}${availspace}"
echo -e "\e[34mServerfiles:\t\e[0m${filesdirdu}" echo -e "${blue}LGSM Total:\t${default}${rootdirdu}"
echo -e "${blue}Serverfiles:\t${default}${filesdirdu}"
if [ -d "${backupdir}" ]; then if [ -d "${backupdir}" ]; then
echo -e "\e[34mBackups:\t\e[0m${backupdirdu}" echo -e "${blue}Backups:\t${default}${backupdirdu}"
fi fi
} | column -s $'\t' -t } | column -s $'\t' -t
} }
@ -98,65 +101,65 @@ fn_details_gameserver(){
# Status: OFFLINE # Status: OFFLINE
echo -e "" echo -e ""
echo -e "\e[92m${gamename} Server Details\e[0m" echo -e "${lightgreen}${gamename} Server Details${default}"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
{ {
# Server name # Server name
echo -e "\e[34mServer name:\t\e[0m${servername}" echo -e "${blue}Server name:\t${default}${servername}"
# Server ip # Server ip
echo -e "\e[34mServer IP:\t\e[0m${ip}:${port}" echo -e "${blue}Server IP:\t${default}${ip}:${port}"
# Server password # Server password
if [ -n "${serverpassword}" ]; then if [ -n "${serverpassword}" ]; then
echo -e "\e[34mServer password:\t\e[0m${serverpassword}" echo -e "${blue}Server password:\t${default}${serverpassword}"
fi fi
# RCON password # RCON password
if [ -n "${rconpassword}" ]; then if [ -n "${rconpassword}" ]; then
echo -e "\e[34mRCON password:\t\e[0m${rconpassword}" echo -e "${blue}RCON password:\t${default}${rconpassword}"
fi fi
# Admin password # Admin password
if [ -n "${adminpassword}" ]; then if [ -n "${adminpassword}" ]; then
echo -e "\e[34mAdmin password:\t\e[0m${adminpassword}" echo -e "${blue}Admin password:\t${default}${adminpassword}"
fi fi
# Stats password (Quake Live) # Stats password (Quake Live)
if [ -n "${statspassword}" ]; then if [ -n "${statspassword}" ]; then
echo -e "\e[34mStats password:\t\e[0m${statspassword}" echo -e "${blue}Stats password:\t${default}${statspassword}"
fi fi
# Slots # Slots
if [ -n "${slots}" ]; then if [ -n "${slots}" ]; then
echo -e "\e[34mSlots:\t\e[0m${slots}" echo -e "${blue}Slots:\t${default}${slots}"
fi fi
# Game mode # Game mode
if [ -n "${gamemode}" ]; then if [ -n "${gamemode}" ]; then
echo -e "\e[34mGame mode:\t\e[0m${gamemode}" echo -e "${blue}Game mode:\t${default}${gamemode}"
fi fi
# Game world # Game world
if [ -n "${gameworld}" ]; then if [ -n "${gameworld}" ]; then
echo -e "\e[34mGame world:\t\e[0m${gameworld}" echo -e "${blue}Game world:\t${default}${gameworld}"
fi fi
# Tick rate # Tick rate
if [ -n "${tickrate}" ]; then if [ -n "${tickrate}" ]; then
echo -e "\e[34mTick rate:\t\e[0m${tickrate}" echo -e "${blue}Tick rate:\t${default}${tickrate}"
fi fi
# Teamspeak dbplugin # Teamspeak dbplugin
if [ -n "${dbplugin}" ]; then if [ -n "${dbplugin}" ]; then
echo -e "\e[34mdbplugin:\t\e[0m${dbplugin}" echo -e "${blue}dbplugin:\t${default}${dbplugin}"
fi fi
# Online status # Online status
if [ "${status}" == "0" ]; then if [ "${status}" == "0" ]; then
echo -e "\e[34mStatus:\t\e[0;31mOFFLINE\e[0m" echo -e "${blue}Status:\t${red}OFFLINE${default}"
else else
echo -e "\e[34mStatus:\t\e[0;32mONLINE\e[0m" echo -e "${blue}Status:\t${green}ONLINE${default}"
fi fi
} | column -s $'\t' -t } | column -s $'\t' -t
echo -e "" echo -e ""
@ -174,61 +177,61 @@ fn_details_script(){
# Location: /home/lgsm/qlserver # Location: /home/lgsm/qlserver
# Config file: /home/lgsm/qlserver/serverfiles/baseq3/ql-server.cfg # Config file: /home/lgsm/qlserver/serverfiles/baseq3/ql-server.cfg
echo -e "\e[92m${selfname} Script Details\e[0m" echo -e "${lightgreen}${selfname} Script Details${default}"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
{ {
# Service name # Service name
echo -e "\e[34mService name:\t\e[0m${servicename}" echo -e "${blue}Service name:\t${default}${servicename}"
# Script version # Script version
if [ -n "${version}" ]; then if [ -n "${version}" ]; then
echo -e "\e[34m${selfname} version:\t\e[0m${version}" echo -e "${blue}${selfname} version:\t${default}${version}"
fi fi
# User # User
echo -e "\e[34mUser:\t\e[0m$(whoami)" echo -e "${blue}User:\t${default}$(whoami)"
# GLIBC required # GLIBC required
if [ -n "${glibcrequired}" ]; then if [ -n "${glibcrequired}" ]; then
if [ "${glibcrequired}" == "NOT REQUIRED" ]; then if [ "${glibcrequired}" == "NOT REQUIRED" ]; then
: :
elif [ "${glibcrequired}" == "UNKNOWN" ]; then elif [ "${glibcrequired}" == "UNKNOWN" ]; then
echo -e "\e[34mGLIBC required:\t\e[0;31m${glibcrequired}" echo -e "${blue}GLIBC required:\t${red}${glibcrequired}"
elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibcrequired}" ]; then elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibcrequired}" ]; then
if [ "${glibcfix}" == "yes" ]; then if [ "${glibcfix}" == "yes" ]; then
echo -e "\e[34mGLIBC required:\t\e[0;31m${glibcrequired} \e[0m(\e[0;32mUsing GLIBC fix\e[0m)" echo -e "${blue}GLIBC required:\t${red}${glibcrequired} ${default}(${green}Using GLIBC fix${default})"
else else
echo -e "\e[34mGLIBC required:\t\e[0;31m${glibcrequired} \e[0m(\e[0;31mGLIBC version too old\e[0m)" echo -e "${blue}GLIBC required:\t${red}${glibcrequired} ${default}(${red}GLIBC version too old${default})"
fi fi
else else
echo -e "\e[34mGLIBC required:\t\e[0;32m${glibcrequired}\e[0m" echo -e "${blue}GLIBC required:\t${green}${glibcrequired}${default}"
fi fi
fi fi
# Email alert # Email alert
echo -e "\e[34mEmail alert:\t\e[0m${emailalert}" echo -e "${blue}Email alert:\t${default}${emailalert}"
# Pushbullet alert # Pushbullet alert
echo -e "\e[34mPushbullet alert:\t\e[0m${pushbulletalert}" echo -e "${blue}Pushbullet alert:\t${default}${pushbulletalert}"
# Update on start # Update on start
echo -e "\e[34mUpdate on start:\t\e[0m${updateonstart}" echo -e "${blue}Update on start:\t${default}${updateonstart}"
# Script location # Script location
echo -e "\e[34mLocation:\t\e[0m${rootdir}" echo -e "${blue}Location:\t${default}${rootdir}"
# Config file location # Config file location
if [ -n "${servercfgfullpath}" ]; then if [ -n "${servercfgfullpath}" ]; then
if [ -f "${servercfgfullpath}" ]; then if [ -f "${servercfgfullpath}" ]; then
echo -e "\e[34mConfig file:\t\e[0m${servercfgfullpath}" echo -e "${blue}Config file:\t${default}${servercfgfullpath}"
else else
echo -e "\e[34mConfig file:\t\e[0m\e[0;31m${servercfgfullpath}\e[0m (\e[0;31mFILE MISSING\e[0m)" echo -e "${blue}Config file:\t${default}${red}${servercfgfullpath}${default} (${red}FILE MISSING${default})"
fi fi
fi fi
# Network config file location (ARMA 3) # Network config file location (ARMA 3)
if [ -n "${networkcfgfullpath}" ]; then if [ -n "${networkcfgfullpath}" ]; then
echo -e "\e[34mNetwork config file:\t\e[0m${networkcfgfullpath}" echo -e "${blue}Network config file:\t${default}${networkcfgfullpath}"
fi fi
} | column -s $'\t' -t } | column -s $'\t' -t
} }
@ -244,17 +247,17 @@ fn_details_backup(){
# size: 945M # size: 945M
echo -e "" echo -e ""
echo -e "\e[92mBackups\e[0m" echo -e "${lightgreen}Backups${default}"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
if [ ! -d "${backupdir}" ]||[ "${backupcount}" == "0" ]; then if [ ! -d "${backupdir}" ]||[ "${backupcount}" == "0" ]; then
echo -e "No Backups created" echo -e "No Backups created"
else else
{ {
echo -e "\e[34mNo. of backups:\t\e[0m${backupcount}" echo -e "${blue}No. of backups:\t${default}${backupcount}"
echo -e "\e[34mLatest backup:\e[0m" echo -e "${blue}Latest backup:${default}"
echo -e "\e[34m date:\t\e[0m${lastbackupdate}" echo -e "${blue} date:\t${default}${lastbackupdate}"
echo -e "\e[34m file:\t\e[0m${lastbackup}" echo -e "${blue} file:\t${default}${lastbackup}"
echo -e "\e[34m size:\t\e[0m${lastbackupsize}" echo -e "${blue} size:\t${default}${lastbackupsize}"
} | column -s $'\t' -t } | column -s $'\t' -t
fi fi
} }
@ -266,7 +269,7 @@ fn_details_commandlineparms(){
# ./run_server_x86.sh +set net_strict 1 # ./run_server_x86.sh +set net_strict 1
echo -e "" echo -e ""
echo -e "\e[92mCommand-line Parameters\e[0m" echo -e "${lightgreen}Command-line Parameters${default}"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
echo -e "${executable} ${parms}" echo -e "${executable} ${parms}"
} }
@ -278,11 +281,11 @@ fn_details_ports(){
# /home/lgsm/qlserver/serverfiles/baseq3/ql-server.cfg # /home/lgsm/qlserver/serverfiles/baseq3/ql-server.cfg
echo -e "" echo -e ""
echo -e "\e[92mPorts\e[0m" echo -e "${lightgreen}Ports${default}"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
echo -e "Change ports by editing the parameters in:" echo -e "Change ports by editing the parameters in:"
parmslocation="\e[0;31mUNKNOWN\e[0m" parmslocation="${red}UNKNOWN${default}"
local ports_edit_array=( "avalanche" "dontstarve" "projectzomboid" "idtech3" "realvirtuality" "seriousengine35" "teeworlds" "terraria" "unreal" "unreal2" "Teamspeak 3" "7 Days To Die" ) local ports_edit_array=( "avalanche" "dontstarve" "projectzomboid" "idtech3" "realvirtuality" "seriousengine35" "teeworlds" "terraria" "unreal" "unreal2" "Teamspeak 3" "7 Days To Die" )
for port_edit in "${ports_edit_array[@]}" for port_edit in "${ports_edit_array[@]}"
do do
@ -306,9 +309,9 @@ fn_details_ports(){
fn_details_statusbottom(){ fn_details_statusbottom(){
echo -e "" echo -e ""
if [ "${status}" == "0" ]; then if [ "${status}" == "0" ]; then
echo -e "\e[34mStatus:\t\e[0;31mOFFLINE\e[0m" echo -e "${blue}Status:\t${red}OFFLINE${default}"
else else
echo -e "\e[34mStatus:\t\e[0;32mONLINE\e[0m" echo -e "${blue}Status:\t${green}ONLINE${default}"
fi fi
echo -e "" echo -e ""
} }
@ -347,7 +350,7 @@ fn_details_realvirtuality(){
echo -e "netstat -atunp | grep arma3server" echo -e "netstat -atunp | grep arma3server"
echo -e "" echo -e ""
if [ -z "${port}" ]||[ -z "${queryport}" ]||[ -z "${masterport}" ]; then if [ -z "${port}" ]||[ -z "${queryport}" ]||[ -z "${masterport}" ]; then
echo -e "\e[0;31mERROR!\e[0m Missing/commented ports in ${servercfg}." echo -e "${red}ERROR!${default} Missing/commented ports in ${servercfg}."
echo -e "" echo -e ""
fi fi
{ {
@ -362,7 +365,7 @@ fn_details_idtech3(){
echo -e "netstat -atunp | grep qzeroded" echo -e "netstat -atunp | grep qzeroded"
echo -e "" echo -e ""
if [ -z "${port}" ]||[ -z "${rconport}" ]||[ -z "${statsport}" ]; then if [ -z "${port}" ]||[ -z "${rconport}" ]||[ -z "${statsport}" ]; then
echo -e "\e[0;31mERROR!\e[0m Missing/commented ports in ${servercfg}." echo -e "${red}ERROR!${default} Missing/commented ports in ${servercfg}."
echo -e "" echo -e ""
fi fi
{ {
@ -407,12 +410,12 @@ fn_details_spark(){
echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp" echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp"
} | column -s $'\t' -t } | column -s $'\t' -t
echo -e "" echo -e ""
echo -e "\e[92m${servername} WebAdmin\e[0m" echo -e "${lightgreen}${servername} WebAdmin${default}"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
{ {
echo -e "\e[34mWebAdmin url:\t\e[0mhttp://${ip}:${webadminport}/index.html" echo -e "${blue}WebAdmin url:\t${default}http://${ip}:${webadminport}/index.html"
echo -e "\e[34mWebAdmin username:\t\e[0m${webadminuser}" echo -e "${blue}WebAdmin username:\t${default}${webadminuser}"
echo -e "\e[34mWebAdmin password:\t\e[0m${webadminpass}" echo -e "${blue}WebAdmin password:\t${default}${webadminpass}"
} | column -s $'\t' -t } | column -s $'\t' -t
} }
@ -467,20 +470,20 @@ fn_details_sdtd(){
echo -e "> Telnet\tINBOUND\t${telnetport}\ttcp" echo -e "> Telnet\tINBOUND\t${telnetport}\ttcp"
} | column -s $'\t' -t } | column -s $'\t' -t
echo -e "" echo -e ""
echo -e "\e[92m${servername} WebAdmin\e[0m" echo -e "${lightgreen}${servername} WebAdmin${default}"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
{ {
echo -e "\e[34mWebAdmin enabled:\t\e[0m${webadminenabled}" echo -e "${blue}WebAdmin enabled:\t${default}${webadminenabled}"
echo -e "\e[34mWebAdmin url:\t\e[0mhttp://${ip}:${webadminport}" echo -e "${blue}WebAdmin url:\t${default}http://${ip}:${webadminport}"
echo -e "\e[34mWebAdmin password:\t\e[0m${webadminpass}" echo -e "${blue}WebAdmin password:\t${default}${webadminpass}"
} | column -s $'\t' -t } | column -s $'\t' -t
echo -e "" echo -e ""
echo -e "\e[92m${servername} Telnet\e[0m" echo -e "${lightgreen}${servername} Telnet${default}"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
{ {
echo -e "\e[34mTelnet enabled:\t\e[0m${telnetenabled}" echo -e "${blue}Telnet enabled:\t${default}${telnetenabled}"
echo -e "\e[34mTelnet address:\t\e[0m${ip} ${telnetport}" echo -e "${blue}Telnet address:\t${default}${ip} ${telnetport}"
echo -e "\e[34mTelnet password:\t\e[0m${telnetpass}" echo -e "${blue}Telnet password:\t${default}${telnetpass}"
} | column -s $'\t' -t } | column -s $'\t' -t
} }
@ -532,13 +535,13 @@ fn_details_unreal(){
echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp\tListenPort=${webadminport}" echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp\tListenPort=${webadminport}"
} | column -s $'\t' -t } | column -s $'\t' -t
echo -e "" echo -e ""
echo -e "\e[92m${servername} WebAdmin\e[0m" echo -e "${lightgreen}${servername} WebAdmin${default}"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
{ {
echo -e "\e[34mWebAdmin enabled:\t\e[0m${webadminenabled}" echo -e "${blue}WebAdmin enabled:\t${default}${webadminenabled}"
echo -e "\e[34mWebAdmin url:\t\e[0mhttp://${ip}:${webadminport}" echo -e "${blue}WebAdmin url:\t${default}http://${ip}:${webadminport}"
echo -e "\e[34mWebAdmin username:\t\e[0m${webadminuser}" echo -e "${blue}WebAdmin username:\t${default}${webadminuser}"
echo -e "\e[34mWebAdmin password:\t\e[0m${webadminpass}" echo -e "${blue}WebAdmin password:\t${default}${webadminpass}"
} | column -s $'\t' -t } | column -s $'\t' -t
} }
@ -612,3 +615,4 @@ else
fi fi
fn_details_statusbottom fn_details_statusbottom
core_exit.sh

20
lgsm/functions/command_dev_debug.sh

@ -1,17 +1,21 @@
#!/bin/bash #!/bin/bash
# LGSM dev_debug.sh function # LGSM command_dev_debug.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Dev only: enables debuging log to be saved to dev-debug.log. # Description: Dev only: enables debuging log to be saved to dev-debug.log.
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandname="DEV-DEBUG"
local commandaction="Dev-Debug"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
if [ -f ".dev-debug" ]; then if [ -f "${rootdir}/.dev-debug" ]; then
rm .dev-debug rm "${rootdir}/.dev-debug"
fn_print_ok_nl "Disabled dev-debug" fn_print_ok_nl "Disabled dev-debug"
fn_script_log_info "Disabled dev-debug"
else else
date > .dev-debug date > "${rootdir}/.dev-debug"
fn_print_ok_nl "Enabled dev-debug" fn_print_ok_nl "Enabled dev-debug"
fi fn_script_log_info "Enabled dev-debug"
fi
core_exit.sh

9
lgsm/functions/command_dev_detect_deps.sh

@ -1,13 +1,12 @@
#!/bin/bash #!/bin/bash
# LGSM fn_dep_detect function # LGSM command_dev_detect_deps.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Detects dependencies the server binary requires. # Description: Detects dependencies the server binary requires.
local modulename="Backup" local commandname="DEPS-DETECT"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="Deps-Detect"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
check.sh check.sh
cd "${executabledir}" cd "${executabledir}"

67
lgsm/functions/command_fastdl.sh

@ -1,14 +1,13 @@
#!/bin/bash #!/bin/bash
# LGSM command_fastdl function # LGSM command_fastdl.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Contributor: UltimateByte # Contributor: UltimateByte
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="060616"
# Description: Creates a FastDL folder # Description: Creates a FastDL folder
local modulename="FastDL" local commandname="FASTDL"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="FastDL"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
check.sh check.sh
@ -26,7 +25,7 @@ fn_check_bzip2(){
if [ -z "$(command -v bzip2)" ]; then if [ -z "$(command -v bzip2)" ]; then
bzip2installed="0" bzip2installed="0"
fn_print_info "bzip2 is not installed !" fn_print_info "bzip2 is not installed !"
fn_scriptlog "bzip2 is not installed" fn_script_log_info "bzip2 is not installed"
echo -en "\n" echo -en "\n"
sleep 1 sleep 1
echo "We advise using it" echo "We advise using it"
@ -42,7 +41,7 @@ fn_fastdl_init(){
fn_print_ok "Welcome to LGSM's FastDL generator" fn_print_ok "Welcome to LGSM's FastDL generator"
sleep 1 sleep 1
echo -en "\n" echo -en "\n"
fn_scriptlog "Started FastDL creation" fn_script_log "Started FastDL creation"
while true; do while true; do
read -e -i "y" -p "Continue? [Y/n]" yn read -e -i "y" -p "Continue? [Y/n]" yn
case $yn in case $yn in
@ -51,7 +50,7 @@ fn_fastdl_init(){
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done done
fn_scriptlog "Initiating FastDL creation" fn_script_log "Initiating FastDL creation"
# Check and create folders # Check and create folders
if [ ! -d "${webdir}" ]; then if [ ! -d "${webdir}" ]; then
@ -63,7 +62,7 @@ fn_fastdl_init(){
sleep 0.5 sleep 0.5
mkdir "${webdir}" mkdir "${webdir}"
fn_print_ok "Created www directory" fn_print_ok "Created www directory"
fn_scriptlog "FastDL created www directory" fn_script_log "FastDL created www directory"
sleep 1 sleep 1
echo -en "\n" echo -en "\n"
fi fi
@ -74,7 +73,7 @@ fn_fastdl_init(){
sleep 0.5 sleep 0.5
mkdir "${fastdldir}" mkdir "${fastdldir}"
fn_print_ok "Created fastdl directory" fn_print_ok "Created fastdl directory"
fn_scriptlog "FastDL created fastdl directory" fn_script_log "FastDL created fastdl directory"
sleep 1 sleep 1
echo -en "\n" echo -en "\n"
clearoldfastdl="off" # Nothing to clear clearoldfastdl="off" # Nothing to clear
@ -86,7 +85,7 @@ fn_fastdl_init(){
fn_fastdl_config(){ fn_fastdl_config(){
# Global settings for FastDL creation # Global settings for FastDL creation
fn_print_info "Entering configuration" fn_print_info "Entering configuration"
fn_scriptlog "Configuration" fn_script_log "Configuration"
sleep 2 sleep 2
echo -en "\n" echo -en "\n"
# Prompt for clearing old files if folder was already here # Prompt for clearing old files if folder was already here
@ -95,8 +94,8 @@ fn_fastdl_config(){
while true; do while true; do
read -e -i "y" -p "Clear old FastDL files? [Y/n]" yn read -e -i "y" -p "Clear old FastDL files? [Y/n]" yn
case $yn in case $yn in
[Yy]* ) clearoldfastdl="on"; fn_scriptlog "clearoldfastdl enabled"; fn_print_ok "Clearing Enabled"; break;; [Yy]* ) clearoldfastdl="on"; fn_script_log "clearoldfastdl enabled"; fn_print_ok "Clearing Enabled"; break;;
[Nn]* ) clearoldfastdl="off"; fn_scriptlog "clearoldfastdl disabled"; fn_print_ok "Clearing Disabled"; break;; [Nn]* ) clearoldfastdl="off"; fn_script_log "clearoldfastdl disabled"; fn_print_ok "Clearing Disabled"; break;;
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done done
@ -108,8 +107,8 @@ fn_fastdl_config(){
while true; do while true; do
read -e -i "y" -p "Enable file compression using bzip2? [Y/n]" yn read -e -i "y" -p "Enable file compression using bzip2? [Y/n]" yn
case $yn in case $yn in
[Yy]* ) bzip2enable="on"; fn_scriptlog "bzip2 enabled"; fn_print_ok "bzip2 Enabled"; break;; [Yy]* ) bzip2enable="on"; fn_script_log "bzip2 enabled"; fn_print_ok "bzip2 Enabled"; break;;
[Nn]* ) bzip2enable="off"; fn_scriptlog "bzip2 disabled"; fn_print_ok "bzip2 Disabled"; break;; [Nn]* ) bzip2enable="off"; fn_script_log "bzip2 disabled"; fn_print_ok "bzip2 Disabled"; break;;
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done done
@ -123,8 +122,8 @@ fn_fastdl_gmod_config(){
while true; do while true; do
read -e -i "y" -p "Use client download enforcer? [Y/n]" yn read -e -i "y" -p "Use client download enforcer? [Y/n]" yn
case $yn in case $yn in
[Yy]* ) luaressource="on"; fn_scriptlog "DL enforcer Enabled"; fn_print_ok "Enforcer Enabled"; break;; [Yy]* ) luaressource="on"; fn_script_log "DL enforcer Enabled"; fn_print_ok "Enforcer Enabled"; break;;
[Nn]* ) luaressource="off"; fn_scriptlog "DL enforcer Disabled"; fn_print_ok "Enforcer Disabled"; break;; [Nn]* ) luaressource="off"; fn_script_log "DL enforcer Disabled"; fn_print_ok "Enforcer Disabled"; break;;
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done done
@ -135,11 +134,11 @@ fn_clear_old_fastdl(){
# Clearing old FastDL if user answered yes # Clearing old FastDL if user answered yes
if [ "${clearoldfastdl}" == "on" ]; then if [ "${clearoldfastdl}" == "on" ]; then
fn_print_info "Clearing existing FastDL folder" fn_print_info "Clearing existing FastDL folder"
fn_scriptlog "Clearing existing FastDL folder" fn_script_log "Clearing existing FastDL folder"
sleep 0.5 sleep 0.5
rm -R "${fastdldir:?}"/* rm -R "${fastdldir:?}"/*
fn_print_ok "Old FastDL folder cleared" fn_print_ok "Old FastDL folder cleared"
fn_scriptlog "Old FastDL folder cleared" fn_script_log "Old FastDL folder cleared"
sleep 1 sleep 1
echo -en "\n" echo -en "\n"
fi fi
@ -149,7 +148,7 @@ fn_gmod_fastdl(){
# Copy all needed files for FastDL # Copy all needed files for FastDL
echo "" echo ""
fn_print_dots "Starting gathering all needed files" fn_print_dots "Starting gathering all needed files"
fn_scriptlog "Starting gathering all needed files" fn_script_log "Starting gathering all needed files"
sleep 1 sleep 1
echo -en "\n" echo -en "\n"
@ -158,7 +157,7 @@ fn_gmod_fastdl(){
# Map Files # Map Files
fn_print_dots "Copying map files..." fn_print_dots "Copying map files..."
fn_scriptlog "Copying map files" fn_script_log "Copying map files"
sleep 0.5 sleep 0.5
find . -name '*.bsp' | cpio --quiet -updm "${fastdldir}" find . -name '*.bsp' | cpio --quiet -updm "${fastdldir}"
fn_print_ok "Map files copied" fn_print_ok "Map files copied"
@ -167,7 +166,7 @@ fn_gmod_fastdl(){
# Materials # Materials
fn_print_dots "Copying materials..." fn_print_dots "Copying materials..."
fn_scriptlog "Copying materials" fn_script_log "Copying materials"
sleep 0.5 sleep 0.5
find . -name '*.vtf' | cpio --quiet -updm "${fastdldir}" find . -name '*.vtf' | cpio --quiet -updm "${fastdldir}"
find . -name '*.vmt' | cpio --quiet -updm "${fastdldir}" find . -name '*.vmt' | cpio --quiet -updm "${fastdldir}"
@ -177,7 +176,7 @@ fn_gmod_fastdl(){
# Models # Models
fn_print_dots "Copying models..." fn_print_dots "Copying models..."
fn_scriptlog "Copying models" fn_script_log "Copying models"
sleep 1 sleep 1
find . -name '*.vtx' | cpio --quiet -updm "${fastdldir}" find . -name '*.vtx' | cpio --quiet -updm "${fastdldir}"
find . -name '*.vvd' | cpio --quiet -updm "${fastdldir}" find . -name '*.vvd' | cpio --quiet -updm "${fastdldir}"
@ -189,7 +188,7 @@ fn_gmod_fastdl(){
# Particles # Particles
fn_print_dots "Copying particles..." fn_print_dots "Copying particles..."
fn_scriptlog "Copying particles" fn_script_log "Copying particles"
sleep 0.5 sleep 0.5
find . -name '*.pcf' | cpio --quiet -updm "${fastdldir}" find . -name '*.pcf' | cpio --quiet -updm "${fastdldir}"
fn_print_ok "Particles copied" fn_print_ok "Particles copied"
@ -198,7 +197,7 @@ fn_gmod_fastdl(){
# Sounds # Sounds
fn_print_dots "Copying sounds..." fn_print_dots "Copying sounds..."
fn_scriptlog "Copying sounds" fn_script_log "Copying sounds"
sleep 0.5 sleep 0.5
find . -name '*.wav' | cpio --quiet -updm "${fastdldir}" find . -name '*.wav' | cpio --quiet -updm "${fastdldir}"
find . -name '*.mp3' | cpio --quiet -updm "${fastdldir}" find . -name '*.mp3' | cpio --quiet -updm "${fastdldir}"
@ -209,7 +208,7 @@ fn_gmod_fastdl(){
# Resources (mostly fonts) # Resources (mostly fonts)
fn_print_dots "Copying fonts and png..." fn_print_dots "Copying fonts and png..."
fn_scriptlog "Copying fonts and png" fn_script_log "Copying fonts and png"
sleep 1 sleep 1
find . -name '*.otf' | cpio --quiet -updm "${fastdldir}" find . -name '*.otf' | cpio --quiet -updm "${fastdldir}"
find . -name '*.ttf' | cpio --quiet -updm "${fastdldir}" find . -name '*.ttf' | cpio --quiet -updm "${fastdldir}"
@ -224,7 +223,7 @@ fn_gmod_fastdl(){
# Correct addons folder structure for FastDL # Correct addons folder structure for FastDL
if [ -d "${fastdldir}/addons" ]; then if [ -d "${fastdldir}/addons" ]; then
fn_print_info "Adjusting addons' file structure" fn_print_info "Adjusting addons' file structure"
fn_scriptlog "Adjusting addon's file structure" fn_script_log "Adjusting addon's file structure"
sleep 1 sleep 1
cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}" cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}"
#Don't remove yet rm -R "${fastdldir:?}/addons" #Don't remove yet rm -R "${fastdldir:?}/addons"
@ -254,7 +253,7 @@ fn_lua_fastdl(){
sleep 1 sleep 1
rm -R "${luafastdlfullpath:?}" rm -R "${luafastdlfullpath:?}"
fn_print_ok "Removed download enforcer" fn_print_ok "Removed download enforcer"
fn_scriptlog "Removed old download inforcer" fn_script_log "Removed old download inforcer"
echo -en "\n" echo -en "\n"
sleep 2 sleep 2
fi fi
@ -266,19 +265,19 @@ fn_lua_fastdl(){
sleep 1 sleep 1
rm "${luafastdlfullpath}" rm "${luafastdlfullpath}"
fn_print_ok "Removed old download enforcer" fn_print_ok "Removed old download enforcer"
fn_scriptlog "Removed old download enforcer" fn_script_log "Removed old download enforcer"
echo -en "\n" echo -en "\n"
sleep 1 sleep 1
fi fi
fn_print_dots "Generating new download enforcer" fn_print_dots "Generating new download enforcer"
fn_scriptlog "Generating new download enforcer" fn_script_log "Generating new download enforcer"
sleep 1 sleep 1
# Read all filenames and put them into a lua file at the right path # Read all filenames and put them into a lua file at the right path
find "${fastdldir}" \( -type f ! -name "*.bz2" \) -printf '%P\n' | while read line; do find "${fastdldir}" \( -type f ! -name "*.bz2" \) -printf '%P\n' | while read line; do
echo "resource.AddFile( "\""${line}"\"" )" >> ${luafastdlfullpath} echo "resource.AddFile( "\""${line}"\"" )" >> ${luafastdlfullpath}
done done
fn_print_ok "Download enforcer generated" fn_print_ok "Download enforcer generated"
fn_scriptlog "Download enforcer generated" fn_script_log "Download enforcer generated"
echo -en "\n" echo -en "\n"
echo "" echo ""
sleep 2 sleep 2
@ -293,11 +292,11 @@ fn_fastdl_bzip2(){
echo -en "\n" echo -en "\n"
echo "" echo ""
fn_print_dots "Compressing files using bzip2..." fn_print_dots "Compressing files using bzip2..."
fn_scriptlog "Compressing files using bzip2..." fn_script_log "Compressing files using bzip2..."
# bzip2 all files that are not already compressed (keeping original files) # bzip2 all files that are not already compressed (keeping original files)
find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec bzip2 -qk \{\} \; find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec bzip2 -qk \{\} \;
fn_print_ok "bzip2 compression done" fn_print_ok "bzip2 compression done"
fn_scriptlog "bzip2 compression done" fn_script_log "bzip2 compression done"
sleep 1 sleep 1
echo -en "\n" echo -en "\n"
fi fi
@ -307,7 +306,7 @@ fn_fastdl_completed(){
# Finished message # Finished message
echo "" echo ""
fn_print_ok "Congratulations, it's done !" fn_print_ok "Congratulations, it's done !"
fn_scriptlog "FastDL job done" fn_script_log "FastDL job done"
sleep 2 sleep 2
echo -en "\n" echo -en "\n"
echo "" echo ""

16
lgsm/functions/command_install.sh

@ -1,13 +1,12 @@
#!/bin/bash #!/bin/bash
# LGSM fn_install function # LGSM command_install.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Overall function for the installer. # Description: Overall function for the installer.
local modulename="Install" local commandname="INSTALL"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
check.sh check.sh
install_header.sh install_header.sh
@ -18,10 +17,9 @@ check_deps.sh
if [ "${gamename}" == "Unreal Tournament 2004" ]; then if [ "${gamename}" == "Unreal Tournament 2004" ]; then
install_server_files.sh install_server_files.sh
install_ut2k4_key.sh install_ut2k4_key.sh
elif [ "${gamename}" == "Unreal Tournament 99" ]; then elif [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Teamspeak 3" ]; then
installer=1
install_server_files.sh install_server_files.sh
elif [ "${gamename}" == "Teamspeak 3" ]; then
install_ts3.sh
elif [ -n "${appid}" ]; then elif [ -n "${appid}" ]; then
install_steamcmd.sh install_steamcmd.sh
install_server_files.sh install_server_files.sh
@ -34,5 +32,7 @@ if [ "${gamename}" == "Counter Strike: Global Offensive" ]||[ "${gamename}" == "
elif [ "${gamename}" == "Teamspeak 3" ]; then elif [ "${gamename}" == "Teamspeak 3" ]; then
install_ts3db.sh install_ts3db.sh
fi fi
fix.sh fix.sh
install_complete.sh install_complete.sh
core_exit.sh

55
lgsm/functions/command_monitor.sh

@ -2,38 +2,37 @@
# LGSM command_monitor.sh function # LGSM command_monitor.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Monitors server by checking for running proccesses # Description: Monitors server by checking for running proccesses
# then passes to monitor_gsquery.sh. # then passes to monitor_gsquery.sh.
local modulename="Monitor" local commandname="MONITOR"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="Monitor"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_monitor_check_lockfile(){ fn_monitor_check_lockfile(){
# Monitor does not run it lockfile is not found # Monitor does not run it lockfile is not found
if [ ! -f "${rootdir}/${lockselfname}" ]; then if [ ! -f "${rootdir}/${lockselfname}" ]; then
fn_print_info_nl "Disabled: No lock file found" fn_print_error_nl "Disabled: No lock file found"
fn_scriptlog "Disabled: No lock file found" fn_script_log_error "Disabled: No lock file found"
echo " * To enable monitor run ./${selfname} start" echo " * To enable monitor run ./${selfname} start"
exit 1 core_exit.sh
fi fi
} }
fn_monitor_check_update(){ fn_monitor_check_update(){
# Monitor will not check if update is running. # Monitor will not check if update is running.
if [ "$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l)" != "0" ]; then if [ "$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l)" != "0" ]; then
fn_print_info_nl "SteamCMD is currently checking for updates" fn_print_error_nl "SteamCMD is currently checking for updates"
fn_scriptlog "SteamCMD is currently checking for updates" fn_script_log_error "SteamCMD is currently checking for updates"
sleep 1 sleep 1
exit core_exit.sh
fi fi
} }
fn_monitor_msg_checking(){ fn_monitor_msg_checking(){
fn_print_dots "Checking session: " fn_print_dots "Checking session: "
fn_print_checking_eol fn_print_checking_eol
fn_scriptlog "Checking session: CHECKING" fn_script_log_info "Checking session: CHECKING"
sleep 1 sleep 1
} }
@ -41,19 +40,18 @@ fn_monitor_teamspeak3(){
if [ "${status}" != "0" ]; then if [ "${status}" != "0" ]; then
fn_print_ok "Checking session: " fn_print_ok "Checking session: "
fn_print_ok_eol_nl fn_print_ok_eol_nl
fn_scriptlog "Checking session: OK" fn_script_log_pass "Checking session: OK"
exit
else else
fn_print_fail "Checking session: ${ts3error}: " fn_print_error "Checking session: ${ts3error}: "
fn_print_fail_eol_nl fn_print_fail_eol_nl
fn_scriptlog "Checking session: ${ts3error}: FAIL" fn_script_log_error "Checking session: ${ts3error}: FAIL"
failurereason="${ts3error}" failurereason="${ts3error}"
alert="restart" alert="restart"
alert.sh alert.sh
fn_script_log_info "Monitor is starting ${servername}"
sleep 1
command_restart.sh
fi fi
fn_scriptlog "Monitor is starting ${servername}"
sleep 1
fn_restart
} }
fn_monitor_tmux(){ fn_monitor_tmux(){
@ -61,7 +59,7 @@ fn_monitor_tmux(){
if [ "${status}" != "0" ]; then if [ "${status}" != "0" ]; then
fn_print_ok "Checking session: " fn_print_ok "Checking session: "
fn_print_ok_eol_nl fn_print_ok_eol_nl
fn_scriptlog "Checking session: OK" fn_script_log_pass "Checking session: OK"
# runs gsquery check on game with specific engines. # runs gsquery check on game with specific engines.
local allowed_engines_array=( avalanche goldsource realvirtuality source spark unity3d unreal unreal2 ) local allowed_engines_array=( avalanche goldsource realvirtuality source spark unity3d unreal unreal2 )
for allowed_engine in "${allowed_engines_array[@]}" for allowed_engine in "${allowed_engines_array[@]}"
@ -70,25 +68,25 @@ fn_monitor_tmux(){
monitor_gsquery.sh monitor_gsquery.sh
fi fi
done done
exit
else else
fn_print_fail "Checking session: " fn_print_error "Checking session: "
fn_print_fail_eol_nl fn_print_fail_eol_nl
fn_scriptlog "Checking session: FAIL" fn_script_log_error "Checking session: FAIL"
alert="restart" alert="restart"
alert.sh alert.sh
fn_scriptlog "Monitor is starting ${servername}" fn_script_log_info "Monitor is starting ${servername}"
sleep 1 sleep 1
command_start.sh command_restart.sh
fi fi
} }
fn_print_dots "${servername}"
sleep 1
check.sh check.sh
logs.sh logs.sh
info_config.sh info_config.sh
fn_print_dots "${servername}"
fn_scriptlog "${servername}"
sleep 1
fn_monitor_check_lockfile fn_monitor_check_lockfile
fn_monitor_check_update fn_monitor_check_update
fn_monitor_msg_checking fn_monitor_msg_checking
@ -96,4 +94,5 @@ if [ "${gamename}" == "Teamspeak 3" ]; then
fn_monitor_teamspeak3 fn_monitor_teamspeak3
else else
fn_monitor_tmux fn_monitor_tmux
fi fi
core_exit.sh

14
lgsm/functions/command_restart.sh

@ -0,0 +1,14 @@
#!/bin/bash
# LGSM command_start.sh function
# Author: Daniel Gibbs
# Website: https://gameservermanagers.com
# Description: Starts the server.
local commandname="RESTART"
local commandaction="Restarting"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
info_config.sh
exitbypass=1
command_stop.sh
command_start.sh

64
lgsm/functions/command_start.sh

@ -2,37 +2,33 @@
# LGSM command_start.sh function # LGSM command_start.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Starts the server. # Description: Starts the server.
local modulename="Starting" local commandname="START"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="Starting"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_start_teamspeak3(){ fn_start_teamspeak3(){
if [ ! -e "${servercfgfullpath}" ]; then if [ ! -e "${servercfgfullpath}" ]; then
fn_print_warn_nl "${servercfgfullpath} is missing" fn_print_warn_nl "${servercfgfullpath} is missing"
fn_scriptlog "${servercfgfullpath} is missing" fn_script_log_warn "${servercfgfullpath} is missing"
echo " * Creating blank ${servercfg}" echo " * Creating blank ${servercfg}"
fn_scriptlog "Creating blank ${servercfg}" fn_script_log_info "Creating blank ${servercfg}"
sleep 2 sleep 2
echo " * ${servercfg} can remain blank by default." echo " * ${servercfg} can remain blank by default."
fn_scriptlog "${servercfgfullpath} can remain blank by default." fn_script_log_info "${servercfgfullpath} can remain blank by default."
sleep 2 sleep 2
echo " * ${servercfg} is located in ${servercfgfullpath}." echo " * ${servercfg} is located in ${servercfgfullpath}."
fn_scriptlog "${servercfg} is located in ${servercfgfullpath}." fn_script_log_info "${servercfg} is located in ${servercfgfullpath}."
sleep 5 sleep 5
touch "${servercfgfullpath}" touch "${servercfgfullpath}"
fi fi
fn_print_dots "${servername}"
fn_scriptlog "${servername}"
sleep 1 sleep 1
check_status.sh check_status.sh
if [ "${status}" != "0" ]; then if [ "${status}" != "0" ]; then
fn_print_info_nl "${servername} is already running" fn_print_info_nl "${servername} is already running"
fn_scriptlog "${servername} is already running" fn_script_log_error "${servername} is already running"
exit core_exit.sh
fi fi
mv "${scriptlog}" "${scriptlogdate}" mv "${scriptlog}" "${scriptlogdate}"
@ -48,25 +44,22 @@ fn_start_teamspeak3(){
check_status.sh check_status.sh
if [ "${status}" == "0" ]; then if [ "${status}" == "0" ]; then
fn_print_fail_nl "Unable to start ${servername}" fn_print_fail_nl "Unable to start ${servername}"
fn_scriptlog "Unable to start ${servername}" fn_script_log_fatal "Unable to start ${servername}"
echo -e " Check log files: ${rootdir}/log" echo -e " Check log files: ${rootdir}/log"
exit 1 core_exit.sh
else else
fn_print_ok_nl "${servername}" fn_print_ok_nl "${servername}"
fn_scriptlog "Started ${servername}" fn_script_log_pass "Started ${servername}"
fi fi
} }
fn_start_tmux(){ fn_start_tmux(){
fn_parms fn_parms
fn_print_dots "${servername}"
fn_scriptlog "${servername}"
sleep 1
# Log rotation # Log rotation
check_status.sh check_status.sh
if [ "${status}" == "0" ]; then if [ "${status}" == "0" ]; then
fn_scriptlog "Rotating log files" fn_script_log_info "Rotating log files"
if [ "${engine}" == "unreal2" ]; then if [ "${engine}" == "unreal2" ]; then
if [ -f "${gamelog}" ]; then if [ -f "${gamelog}" ]; then
mv "${gamelog}" "${gamelogdate}" mv "${gamelog}" "${gamelogdate}"
@ -80,8 +73,8 @@ fn_start_tmux(){
check_status.sh check_status.sh
if [ "${status}" != "0" ]; then if [ "${status}" != "0" ]; then
fn_print_info_nl "${servername} is already running" fn_print_info_nl "${servername} is already running"
fn_scriptlog "${servername} is already running" fn_script_log_error "${servername} is already running"
exit core_exit.sh
fi fi
# Create lock file # Create lock file
@ -110,7 +103,7 @@ fn_start_tmux(){
elif [ "${consolelogging}" == "off" ]; then elif [ "${consolelogging}" == "off" ]; then
touch "${consolelog}" touch "${consolelog}"
cat "Console logging disabled by user" >> "{consolelog}" cat "Console logging disabled by user" >> "{consolelog}"
fn_scriptlog "Console logging disabled by user" fn_script_log_info "Console logging disabled by user"
fi fi
sleep 1 sleep 1
@ -118,11 +111,11 @@ fn_start_tmux(){
check_status.sh check_status.sh
if [ "${status}" == "0" ]; then if [ "${status}" == "0" ]; then
fn_print_fail_nl "Unable to start ${servername}" fn_print_fail_nl "Unable to start ${servername}"
fn_scriptlog "Unable to start ${servername}" fn_script_log_fatal "Unable to start ${servername}"
sleep 1 sleep 1
if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then
fn_print_fail_nl "Unable to start ${servername}: Tmux error:" fn_print_fail_nl "Unable to start ${servername}: Tmux error:"
fn_scriptlog "Tmux error" fn_script_log_fatal "Unable to start ${servername}: Tmux error:"
echo "" echo ""
echo "Command" echo "Command"
echo "=================================" echo "================================="
@ -139,35 +132,38 @@ fn_start_tmux(){
echo "=================================" echo "================================="
if [ ! $(grep "tty:" /etc/group|grep "$(whoami)") ]; then if [ ! $(grep "tty:" /etc/group|grep "$(whoami)") ]; then
echo "$(whoami) is not part of the tty group." echo "$(whoami) is not part of the tty group."
fn_scriptlog "$(whoami) is not part of the tty group." fn_script_log_info "$(whoami) is not part of the tty group."
group=$(grep tty /etc/group) group=$(grep tty /etc/group)
echo "" echo ""
echo " ${group}" echo " ${group}"
fn_scriptlog "${group}" fn_script_log_info "${group}"
echo "" echo ""
echo "Run the following command with root privileges." echo "Run the following command with root privileges."
echo "" echo ""
echo " usermod -G tty $(whoami)" echo " usermod -G tty $(whoami)"
echo "" echo ""
echo "https://gameservermanagers.com/tmux-op-perm" echo "https://gameservermanagers.com/tmux-op-perm"
fn_scriptlog "https://gameservermanagers.com/tmux-op-perm" fn_script_log_info "https://gameservermanagers.com/tmux-op-perm"
else else
echo "No known fix currently. Please log an issue." echo "No known fix currently. Please log an issue."
fn_scriptlog "No known fix currently. Please log an issue." fn_script_log_info "No known fix currently. Please log an issue."
echo "https://gameservermanagers.com/issues" echo "https://gameservermanagers.com/issues"
fn_scriptlog "https://gameservermanagers.com/issues" fn_script_log_info "https://gameservermanagers.com/issues"
fi fi
fi fi
fi fi
exit 1
core_exit.sh
else else
fn_print_ok "${servername}" fn_print_ok "${servername}"
fn_scriptlog "Started ${servername}" fn_script_log_pass "Started ${servername}"
fi fi
rm "${scriptlogdir}/.${servicename}-tmux-error.tmp" rm "${scriptlogdir}/.${servicename}-tmux-error.tmp"
echo -en "\n" echo -en "\n"
} }
fn_print_dots "${servername}"
sleep 1
check.sh check.sh
fix.sh fix.sh
info_config.sh info_config.sh
@ -176,7 +172,8 @@ logs.sh
# Will check for updates is updateonstart is yes # Will check for updates is updateonstart is yes
if [ "${status}" == "0" ]; then if [ "${status}" == "0" ]; then
if [ "${updateonstart}" == "yes" ]||[ "${updateonstart}" == "1" ]||[ "${updateonstart}" == "on" ]; then if [ "${updateonstart}" == "yes" ]||[ "${updateonstart}" == "1" ]||[ "${updateonstart}" == "on" ]; then
update_check.sh exitbypass=1
command_update.sh
fi fi
fi fi
@ -185,3 +182,4 @@ if [ "${gamename}" == "Teamspeak 3" ]; then
else else
fn_start_tmux fn_start_tmux
fi fi
core_exit.sh

153
lgsm/functions/command_stop.sh

@ -2,17 +2,16 @@
# LGSM command_stop.sh function # LGSM command_stop.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="050616"
# Description: Stops the server. # Description: Stops the server.
local modulename="Stopping" local commandname="STOP"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="Stopping"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
# Attempts Graceful of source using rcon 'quit' command. # Attempts Graceful of source using rcon 'quit' command.
fn_stop_graceful_source(){ fn_stop_graceful_source(){
fn_print_dots "Graceful: rcon quit" fn_print_dots "Graceful: rcon quit"
fn_scriptlog "Graceful: rcon quit" fn_script_log_info "Graceful: rcon quit"
# sends quit # sends quit
tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1 tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1
# waits up to 30 seconds giving the server time to shutdown gracefuly # waits up to 30 seconds giving the server time to shutdown gracefuly
@ -21,7 +20,7 @@ fn_stop_graceful_source(){
if [ "${status}" == "0" ]; then if [ "${status}" == "0" ]; then
fn_print_ok "Graceful: rcon quit: ${seconds}: " fn_print_ok "Graceful: rcon quit: ${seconds}: "
fn_print_ok_eol_nl fn_print_ok_eol_nl
fn_scriptlog "Graceful: rcon quit: OK: ${seconds} seconds" fn_script_log_pass "Graceful: rcon quit: OK: ${seconds} seconds"
break break
fi fi
sleep 1 sleep 1
@ -29,9 +28,9 @@ fn_stop_graceful_source(){
done done
check_status.sh check_status.sh
if [ "${status}" != "0" ]; then if [ "${status}" != "0" ]; then
fn_print_fail "Graceful: rcon quit: " fn_print_error "Graceful: rcon quit: "
fn_print_fail_eol_nl fn_print_fail_eol_nl
fn_scriptlog "Graceful: rcon quit: FAIL" fn_script_log_error "Graceful: rcon quit: FAIL"
fi fi
sleep 1 sleep 1
fn_stop_tmux fn_stop_tmux
@ -43,7 +42,7 @@ fn_stop_graceful_source(){
# preventing the server from coming back online. # preventing the server from coming back online.
fn_stop_graceful_goldsource(){ fn_stop_graceful_goldsource(){
fn_print_dots "Graceful: rcon quit" fn_print_dots "Graceful: rcon quit"
fn_scriptlog "Graceful: rcon quit" fn_script_log_info "Graceful: rcon quit"
# sends quit # sends quit
tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1 tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1
# waits 3 seconds as goldsource servers restart with the quit command # waits 3 seconds as goldsource servers restart with the quit command
@ -53,7 +52,7 @@ fn_stop_graceful_goldsource(){
done done
fn_print_ok "Graceful: rcon quit: ${seconds}: " fn_print_ok "Graceful: rcon quit: ${seconds}: "
fn_print_ok_eol_nl fn_print_ok_eol_nl
fn_scriptlog "Graceful: rcon quit: OK: ${seconds} seconds" fn_script_log_pass "Graceful: rcon quit: OK: ${seconds} seconds"
sleep 1 sleep 1
fn_stop_tmux fn_stop_tmux
} }
@ -77,12 +76,11 @@ fn_stop_telnet_sdtd(){
expect { eof } expect { eof }
puts "Completed.\n" puts "Completed.\n"
') ')
} }
fn_stop_graceful_sdtd(){ fn_stop_graceful_sdtd(){
fn_print_dots "Graceful: telnet" fn_print_dots "Graceful: telnet"
fn_scriptlog "Graceful: telnet" fn_script_log_info "Graceful: telnet"
sleep 1 sleep 1
if [ "${telnetenabled}" == "false" ]; then if [ "${telnetenabled}" == "false" ]; then
fn_print_info_nl "Graceful: telnet: DISABLED: Enable in ${servercfg}" fn_print_info_nl "Graceful: telnet: DISABLED: Enable in ${servercfg}"
@ -90,15 +88,15 @@ fn_stop_graceful_sdtd(){
# Tries to shutdown with both localhost and server IP. # Tries to shutdown with both localhost and server IP.
for telnetip in 127.0.0.1 ${ip}; do for telnetip in 127.0.0.1 ${ip}; do
fn_print_dots "Graceful: telnet: ${telnetip}" fn_print_dots "Graceful: telnet: ${telnetip}"
fn_scriptlog "Graceful: telnet: ${telnetip}" fn_script_log_info "Graceful: telnet: ${telnetip}"
sleep 1 sleep 1
fn_stop_telnet_sdtd fn_stop_telnet_sdtd
completed=$(echo -en "\n ${sdtd_telnet_shutdown}"|grep "Completed.") completed=$(echo -en "\n ${sdtd_telnet_shutdown}"|grep "Completed.")
refused=$(echo -en "\n ${sdtd_telnet_shutdown}"|grep "Timeout or EOF") refused=$(echo -en "\n ${sdtd_telnet_shutdown}"|grep "Timeout or EOF")
if [ -n "${refused}" ]; then if [ -n "${refused}" ]; then
fn_print_warn "Graceful: telnet: ${telnetip}: " fn_print_error "Graceful: telnet: ${telnetip}: "
fn_print_fail_eol_nl fn_print_fail_eol_nl
fn_scriptlog "Graceful: telnet: ${telnetip}: FAIL" fn_script_log_error "Graceful: telnet: ${telnetip}: FAIL"
sleep 1 sleep 1
elif [ -n "${completed}" ]; then elif [ -n "${completed}" ]; then
break break
@ -114,7 +112,7 @@ fn_stop_graceful_sdtd(){
if [ -n "${refused}" ]; then if [ -n "${refused}" ]; then
fn_print_ok "Graceful: telnet: ${telnetip}: " fn_print_ok "Graceful: telnet: ${telnetip}: "
fn_print_ok_eol_nl fn_print_ok_eol_nl
fn_scriptlog "Graceful: telnet: ${telnetip}: ${seconds} seconds" fn_script_log_pass "Graceful: telnet: ${telnetip}: ${seconds} seconds"
break break
fi fi
sleep 1 sleep 1
@ -124,12 +122,12 @@ fn_stop_graceful_sdtd(){
# If cannot shutdown correctly world save may be lost # If cannot shutdown correctly world save may be lost
else else
if [ -n "${refused}" ]; then if [ -n "${refused}" ]; then
fn_print_fail "Graceful: telnet: " fn_print_error "Graceful: telnet: "
fn_print_fail_eol_nl fn_print_fail_eol_nl
fn_scriptlog "Graceful: telnet: ${telnetip}: FAIL" fn_script_log_error "Graceful: telnet: ${telnetip}: FAIL"
else else
fn_print_fail_nl "Graceful: telnet: Unknown error" fn_print_error_nl "Graceful: telnet: Unknown error"
fn_scriptlog "Graceful: telnet: Unknown error" fn_script_log_error "Graceful: telnet: Unknown error"
fi fi
echo -en "\n" | tee -a "${scriptlog}" echo -en "\n" | tee -a "${scriptlog}"
echo -en "Telnet output:" | tee -a "${scriptlog}" echo -en "Telnet output:" | tee -a "${scriptlog}"
@ -137,11 +135,9 @@ fn_stop_graceful_sdtd(){
echo -en "\n\n" | tee -a "${scriptlog}" echo -en "\n\n" | tee -a "${scriptlog}"
fi fi
else else
fn_print_dots "Graceful: telnet: " fn_print_warn "Graceful: telnet: expect not installed: "
fn_scriptlog "Graceful: telnet: "
fn_print_fail "Graceful: telnet: expect not installed: "
fn_print_fail_eol_nl fn_print_fail_eol_nl
fn_scriptlog "Graceful: telnet: expect not installed: FAIL" fn_script_log_warn "Graceful: telnet: expect not installed: FAIL"
fi fi
sleep 1 sleep 1
fn_stop_tmux fn_stop_tmux
@ -160,47 +156,48 @@ fn_stop_graceful_select(){
} }
fn_stop_ark(){ fn_stop_ark(){
MAXPIDITER=15 # The maximum number of times to check if the ark pid has closed gracefully. maxpiditer=15 # The maximum number of times to check if the ark pid has closed gracefully.
info_config.sh info_config.sh
if [ -z $queryport ] ; then if [ -z "${queryport}" ]; then
fn_print_warn "no queryport found using info_config.sh" fn_print_warn "No queryport found using info_config.sh"
userconfigfile="${filesdir}" fn_script_log_warn "No queryport found using info_config.sh"
userconfigfile+="/ShooterGame/Saved/Config/LinuxServer/GameUserSettings.ini" userconfigfile="${filesdir}"
queryport=$(grep ^QueryPort= ${userconfigfile} | cut -d= -f2 | sed "s/[^[:digit:].*].*//g") userconfigfile+="/ShooterGame/Saved/Config/LinuxServer/GameUserSettings.ini"
fi queryport=$(grep ^QueryPort= ${userconfigfile} | cut -d= -f2 | sed "s/[^[:digit:].*].*//g")
if [ -z $queryport ] ; then fi
fn_print_warn "no queryport found in the GameUsersettings.ini file" if [ -z "${queryport}" ]; then
return fn_print_warn "No queryport found in the GameUsersettings.ini file"
fi fn_script_log_warn "No queryport found in the GameUsersettings.ini file"
return
fi
if [[ ${#queryport} -gt 0 ]] ; then if [[ ${#queryport} -gt 0 ]] ; then
for (( pidcheck=0 ; pidcheck < ${MAXPIDITER} ; pidcheck++ )) ; do for (( pidcheck=0 ; pidcheck < ${maxpiditer} ; pidcheck++ )) ; do
pid=$(netstat -nap 2>/dev/null | grep ^udp[[:space:]] |\ pid=$(netstat -nap 2>/dev/null | grep ^udp[[:space:]] |\
grep :${queryport}[[:space:]] | rev | awk '{print $1}' |\ grep :${queryport}[[:space:]] | rev | awk '{print $1}' |\
rev | cut -d\/ -f1) rev | cut -d\/ -f1)
# #
# check for a valid pid # check for a valid pid
let pid+=0 # turns an empty string into a valid number, '0', let pid+=0 # turns an empty string into a valid number, '0',
# and a valid numeric pid remains unchanged. # and a valid numeric pid remains unchanged.
if [[ $pid -gt 1 && $pid -le $(cat /proc/sys/kernel/pid_max) ]] ; then if [[ ${pid} -gt 1 && $pid -le $(cat /proc/sys/kernel/pid_max) ]] ; then
fn_print_dots "Process still bound. Awaiting graceful exit: $pidcheck" fn_print_dots "Process still bound. Awaiting graceful exit: ${pidcheck}"
sleep 1 sleep 1
else else
break # Our job is done here break # Our job is done here
fi # end if for pid range check fi # end if for pid range check
done done
if [[ ${pidcheck} -eq ${MAXPIDITER} ]] ; then if [[ ${pidcheck} -eq ${maxpiditer} ]] ; then
# The process doesn't want to close after 20 seconds. # The process doesn't want to close after 20 seconds.
# kill it hard. # kill it hard.
fn_print_warn "Terminating reluctant Ark process: $pid" fn_print_error "Terminating reluctant Ark process: ${pid}"
kill -9 $pid kill -9 $pid
fi fi
fi # end if for port check fi # end if for port check
} # end of fn_stop_ark } # end of fn_stop_ark
fn_stop_teamspeak3(){ fn_stop_teamspeak3(){
fn_print_dots "${servername}" fn_print_dots "${servername}"
fn_scriptlog "${servername}"
sleep 1 sleep 1
${filesdir}/ts3server_startscript.sh stop > /dev/null 2>&1 ${filesdir}/ts3server_startscript.sh stop > /dev/null 2>&1
check_status.sh check_status.sh
@ -208,16 +205,16 @@ fn_stop_teamspeak3(){
# Remove lock file # Remove lock file
rm -f "${rootdir}/${lockselfname}" rm -f "${rootdir}/${lockselfname}"
fn_print_ok_nl "${servername}" fn_print_ok_nl "${servername}"
fn_scriptlog "Stopped ${servername}" fn_script_log_pass "Stopped ${servername}"
else else
fn_print_fail_nl "Unable to stop${servername}" fn_print_fail_nl "Unable to stop ${servername}"
fn_scriptlog "Unable to stop${servername}" fn_script_log_fail "Unable to stop ${servername}"
fi fi
} }
fn_stop_tmux(){ fn_stop_tmux(){
fn_print_dots "${servername}" fn_print_dots "${servername}"
fn_scriptlog "tmux kill-session: ${servername}" fn_script_log_info "tmux kill-session: ${servername}"
sleep 1 sleep 1
# Kill tmux session # Kill tmux session
tmux kill-session -t "${servicename}" > /dev/null 2>&1 tmux kill-session -t "${servicename}" > /dev/null 2>&1
@ -227,16 +224,16 @@ fn_stop_tmux(){
# Remove lock file # Remove lock file
rm -f "${rootdir}/${lockselfname}" rm -f "${rootdir}/${lockselfname}"
# ARK doesn't clean up immediately after tmux is killed. # ARK doesn't clean up immediately after tmux is killed.
# Make certain the ports are cleared before continuing. # Make certain the ports are cleared before continuing.
if [ "${gamename}" == "ARK: Survivial Evolved" ]; then if [ "${gamename}" == "ARK: Survivial Evolved" ]; then
fn_stop_ark fn_stop_ark
echo -en "\n" echo -en "\n"
fi fi
fn_print_ok_nl "${servername}" fn_print_ok_nl "${servername}"
fn_scriptlog "Stopped ${servername}" fn_script_log_pass "Stopped ${servername}"
else else
fn_print_fail_nl "Unable to stop${servername}" fn_print_fail_nl "Unable to stop${servername}"
fn_scriptlog "Unable to stop${servername}" fn_script_log_fatal "Unable to stop${servername}"
fi fi
} }
@ -245,25 +242,25 @@ fn_stop_pre_check(){
if [ "${gamename}" == "Teamspeak 3" ]; then if [ "${gamename}" == "Teamspeak 3" ]; then
check_status.sh check_status.sh
if [ "${status}" == "0" ]; then if [ "${status}" == "0" ]; then
fn_print_ok_nl "${servername} is already stopped" fn_print_info_nl "${servername} is already stopped"
fn_scriptlog "${servername} is already stopped" fn_script_log_error "${servername} is already stopped"
else else
fn_stop_teamspeak3 fn_stop_teamspeak3
fi fi
else else
check_status.sh check_status.sh
if [ "${status}" == "0" ]; then if [ "${status}" == "0" ]; then
fn_print_ok_nl "${servername} is already stopped" fn_print_info_nl "${servername} is already stopped"
fn_scriptlog "${servername} is already stopped" fn_script_log_error "${servername} is already stopped"
else else
fn_stop_graceful_select fn_stop_graceful_select
fi fi
fi fi
} }
check.sh
info_config.sh
fn_print_dots "${servername}" fn_print_dots "${servername}"
fn_scriptlog "${servername}"
sleep 1 sleep 1
check.sh
info_config.sh
fn_stop_pre_check fn_stop_pre_check
core_exit.sh

12
lgsm/functions/command_test_alert.sh

@ -1,15 +1,17 @@
#!/bin/bash #!/bin/bash
# LGSM command_email_test.sh function # LGSM command_test_alert.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Sends a test email alert. # Description: Sends a test email alert.
local modulename="Alert" local commandname="ALERT"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="Alert"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_print_dots "${servername}"
sleep 1
check.sh check.sh
info_config.sh info_config.sh
alert="test" alert="test"
alert.sh alert.sh
core_exit.sh

18
lgsm/functions/command_ts3_server_pass.sh

@ -1,14 +1,13 @@
#!/bin/bash #!/bin/bash
# LGSM command_serveradmin_password.sh function # LGSM command_ts3_server_pass.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Contributor : UltimateByte # Contributor : UltimateByte
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Changes TS3 serveradmin password # Description: Changes TS3 serveradmin password
local modulename="Change password" local commandname="TS3-CHANGE-PASS"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="TS3 Change Password"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_serveradmin_password_prompt(){ fn_serveradmin_password_prompt(){
@ -28,14 +27,14 @@ fn_serveradmin_password_prompt(){
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done done
fn_scriptlog "Initiating ${gamename} ServerAdmin password change" fn_script_log_info "Initiating ${gamename} ServerAdmin password change"
read -p "Enter new password : " newpassword read -p "Enter new password : " newpassword
} }
fn_serveradmin_password_set(){ fn_serveradmin_password_set(){
fn_print_info_nl "Applying new password" fn_print_info_nl "Applying new password"
fn_scriptlog "Applying new password" fn_script_log_info "Applying new password"
sleep 1 sleep 1
# Stop any running server # Stop any running server
command_stop.sh command_stop.sh
@ -47,7 +46,7 @@ fn_serveradmin_password_prompt(){
command_stop.sh command_stop.sh
ts3serverpass="0" ts3serverpass="0"
fn_print_ok_nl "Password applied" fn_print_ok_nl "Password applied"
fn_scriptlog "New ServerAdmin password applied" fn_script_log_pass "New ServerAdmin password applied"
sleep 1 sleep 1
} }
@ -60,4 +59,5 @@ if [ "${status}" != "0" ]; then
command_start.sh command_start.sh
else else
fn_serveradmin_password_set fn_serveradmin_password_set
fi fi
core_exit.sh

22
lgsm/functions/command_update.sh

@ -0,0 +1,22 @@
#!/bin/bash
# LGSM command_update.sh function
# Author: Daniel Gibbs
# Website: https://gameservermanagers.com
# Description: Handles updating of servers.
local commandname="UPDATE"
local commandaction="Update"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_print_dots ""
sleep 0.5
check.sh
if [ "${gamename}" == "Teamspeak 3" ]; then
update_ts3.sh
else
update_steamcmd.sh
fi
core_exit.sh

49
lgsm/functions/command_update_functions.sh

@ -2,15 +2,15 @@
# LGSM command_update_functions.sh function # LGSM command_update_functions.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Deletes the functions dir to allow re-downloading of functions from GitHub. # Description: Deletes the functions dir to allow re-downloading of functions from GitHub.
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="Update LGSM"
check.sh local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_print_dots "Updating functions" fn_print_dots "Updating functions"
fn_scriptlog "Updating functions"
sleep 1 sleep 1
check.sh
fn_script_log_info "Updating functions"
echo -ne "\n" echo -ne "\n"
# Removed legecy functions dir # Removed legecy functions dir
@ -23,16 +23,39 @@ fi
if [ -n "${functionsdir}" ]; then if [ -n "${functionsdir}" ]; then
if [ -d "${functionsdir}" ]; then if [ -d "${functionsdir}" ]; then
rm -rfv "${functionsdir}/"* cd "${functionsdir}"
exitcode=$? for functionfile in *
do
# Check curl exists and use available path
curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
for curlcmd in ${curlpaths}
do
if [ -x "${curlcmd}" ]; then
curlcmd=${curlcmd}
break
fi
done
echo -ne " checking ${functionfile}...\c"
function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}"))
if [ "${function_file_diff}" != "" ]; then
fn_print_update_eol_nl
fn_script_log_info "checking ${functionfile}: UPDATE"
rm -rf "${functionsdir}/${functionfile}"
fn_update_function
else
fn_print_ok_eol_nl
fi
done
fi fi
fi fi
if [ "${exitcode}" == "0" ]; then if [ "${exitcode}" != "0" ]&&[ -n "${exitcode}" ]; then
fn_print_ok "Updating functions"
fn_scriptlog "Success! Updating functions"
else
fn_print_fail "Updating functions" fn_print_fail "Updating functions"
fn_scriptlog "Failure! Updating functions" fn_script_log_fatal "Updating functions"
else
fn_print_ok "Updating functions"
fn_script_log_pass "Updating functions"
fi fi
echo -ne "\n" echo -ne "\n"
core_exit.sh

35
lgsm/functions/command_validate.sh

@ -2,22 +2,19 @@
# LGSM command_validate.sh function # LGSM command_validate.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Runs a server validation. # Description: Runs a server validation.
local modulename="Validate" local commandname="VALIDATE"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="Validate"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_validation(){ fn_validation(){
fn_print_warn_nl "Validating may overwrite some customised files." echo -e " * Validating may overwrite some customised files."
echo -en "https://developer.valvesoftware.com/wiki/SteamCMD#Validate" echo -en " * https://developer.valvesoftware.com/wiki/SteamCMD#Validate"
sleep 5 sleep 3
echo -en "\n" echo -en "\n"
fn_print_dots "Checking server files" fn_print_dots_nl "Validating files: SteamCMD"
sleep 1 fn_script_log_info "Validating files: SteamCMD"
fn_print_ok "Checking server files"
fn_scriptlog "Checking server files"
sleep 1 sleep 1
cd "${rootdir}/steamcmd" cd "${rootdir}/steamcmd"
@ -31,16 +28,28 @@ fn_validation(){
else else
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" validate +quit| tee -a "${scriptlog}" ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" validate +quit| tee -a "${scriptlog}"
fi fi
if [ $? != 0 ]; then
fn_print_fail_nl "Validating files: SteamCMD"
fn_script_log_fatal "Validating files: SteamCMD: FAIL"
else
fn_print_ok_nl "Validating files: SteamCMD"
fn_script_log_pass "Validating files: SteamCMD: OK"
fi
fix.sh fix.sh
fn_scriptlog "Checking complete"
} }
fn_print_dots "Validating files"
sleep 1
check.sh
check_status.sh check_status.sh
if [ "${status}" != "0" ]; then if [ "${status}" != "0" ]; then
exitbypass=1
command_stop.sh command_stop.sh
fn_validation fn_validation
exitbypass=1
command_start.sh command_start.sh
else else
fn_validation fn_validation
fi fi
core_exit.sh

6
lgsm/functions/compress_unreal2_maps.sh

@ -2,9 +2,10 @@
# LGSM compress_unreal2_maps.sh function # LGSM compress_unreal2_maps.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516" # Description: compresses unreal maps
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="Unreal Map Compressor"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
check.sh check.sh
clear clear
@ -33,3 +34,4 @@ for map in "${filesdir}/Maps/"*; do
./ucc-bin compress "${map}" --nohomedir ./ucc-bin compress "${map}" --nohomedir
done done
mv -fv "${filesdir}/Maps/"*.ut2.uz2 "${compressedmapsdir}" mv -fv "${filesdir}/Maps/"*.ut2.uz2 "${compressedmapsdir}"
core_exit.sh

6
lgsm/functions/compress_ut99_maps.sh

@ -2,9 +2,10 @@
# LGSM compress_ut99_maps.sh function # LGSM compress_ut99_maps.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516" # Description: compresses unreal maps
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local commandaction="Unreal Map Compressor"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
check.sh check.sh
clear clear
@ -33,3 +34,4 @@ for map in "${filesdir}/Maps/"*; do
./ucc-bin compress "${map}" --nohomedir ./ucc-bin compress "${map}" --nohomedir
done done
mv -fv "${filesdir}/Maps/"*.unr.uz "${compressedmapsdir}" mv -fv "${filesdir}/Maps/"*.unr.uz "${compressedmapsdir}"
core_exit.sh

59
lgsm/functions/core_dl.sh

@ -2,8 +2,6 @@
# LGSM core_dl.sh function # LGSM core_dl.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Deals with all downloads for LGSM. # Description: Deals with all downloads for LGSM.
# fileurl: The URL of the file: http://example.com/dl/File.tar.bz2 # fileurl: The URL of the file: http://example.com/dl/File.tar.bz2
@ -18,6 +16,10 @@ lgsm_version="210516"
# fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" # fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
# fn_fetch_file "http://example.com/file.tar.bz2" "/some/dir" "file.tar.bz2" "executecmd" "run" "force" "10cd7353aa9d758a075c600a6dd193fd" # fn_fetch_file "http://example.com/file.tar.bz2" "/some/dir" "file.tar.bz2" "executecmd" "run" "force" "10cd7353aa9d758a075c600a6dd193fd"
local commandname="DOWNLOAD"
local commandaction="Download"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_dl_md5(){ fn_dl_md5(){
# Runs MD5 Check if available # Runs MD5 Check if available
if [ "${md5}" != "0" ]&&[ "${md5}" != "nomd5" ]; then if [ "${md5}" != "0" ]&&[ "${md5}" != "nomd5" ]; then
@ -28,15 +30,15 @@ fn_dl_md5(){
fn_print_fail_eol_nl fn_print_fail_eol_nl
echo "${filename} returned MD5 checksum: ${md5sumcmd}" echo "${filename} returned MD5 checksum: ${md5sumcmd}"
echo "expected MD5 checksum: ${md5}" echo "expected MD5 checksum: ${md5}"
fn_scriptlog "verifying ${filename} with MD5: FAIL" fn_script_log_fatal "Verifying ${filename} with MD5: FAIL"
fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}" fn_script_log_info "${filename} returned MD5 checksum: ${md5sumcmd}"
fn_scriptlog "expected MD5 checksum: ${md5}" fn_script_log_info "Expected MD5 checksum: ${md5}"
exit 1 core_exit.sh
else else
fn_print_ok_eol_nl fn_print_ok_eol_nl
fn_scriptlog "verifying ${filename} with MD5: OK" fn_script_log_pass "Verifying ${filename} with MD5: OK"
fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}" fn_script_log_info "${filename} returned MD5 checksum: ${md5sumcmd}"
fn_scriptlog "expected MD5 checksum: ${md5}" fn_script_log_info "Expected MD5 checksum: ${md5}"
fi fi
fi fi
} }
@ -51,7 +53,7 @@ fn_dl_extract(){
extractdir="${3}" extractdir="${3}"
# extracts archives # extracts archives
echo -ne "extracting ${filename}..." echo -ne "extracting ${filename}..."
fn_scriptlog "extracting download" fn_script_log_info "Extracting download"
mime=$(file -b --mime-type "${filedir}/${filename}") mime=$(file -b --mime-type "${filedir}/${filename}")
if [ "${mime}" == "application/gzip" ]||[ "${mime}" == "application/x-gzip" ]; then if [ "${mime}" == "application/gzip" ]||[ "${mime}" == "application/x-gzip" ]; then
@ -62,26 +64,26 @@ fn_dl_extract(){
local exitcode=$? local exitcode=$?
if [ ${exitcode} -ne 0 ]; then if [ ${exitcode} -ne 0 ]; then
fn_print_fail_eol_nl fn_print_fail_eol_nl
fn_scriptlog "extracting download: FAIL" fn_script_log_fatal "Extracting download: FAIL"
echo "${tarcmd}" | tee -a "${scriptlog}" echo "${tarcmd}" | tee -a "${scriptlog}"
exit ${exitcode} core_exit.sh
else else
fn_print_ok_eol_nl fn_print_ok_eol_nl
fi fi
} }
# Trap to remove file download if canceled before completed # Trap to remove file download if canceled before completed
fn_fetch_trap() { fn_fetch_trap(){
echo "" echo ""
echo -ne "downloading ${filename}: " echo -ne "downloading ${filename}: "
fn_print_canceled_eol_nl fn_print_canceled_eol_nl
fn_scriptlog "downloading ${filename}: CANCELED" fn_script_log_info "downloading ${filename}: CANCELED"
sleep 1 sleep 1
rm -f "${filedir}/${filename}" | tee -a "${scriptlog}" rm -f "${filedir}/${filename}" | tee -a "${scriptlog}"
echo -ne "downloading ${filename}: " echo -ne "downloading ${filename}: "
fn_print_removed_eol_nl fn_print_removed_eol_nl
fn_scriptlog "downloading ${filename}: REMOVED" fn_script_log_info "downloading ${filename}: REMOVED"
exit core_exit.sh
} }
fn_fetch_file(){ fn_fetch_file(){
@ -125,15 +127,15 @@ fn_fetch_file(){
if [ ${exitcode} -ne 0 ]; then if [ ${exitcode} -ne 0 ]; then
fn_print_fail_eol_nl fn_print_fail_eol_nl
if [ -f "${scriptlog}" ]; then if [ -f "${scriptlog}" ]; then
fn_scriptlog "downloading ${filename}: FAIL" fn_script_log_fatal "downloading ${filename}: FAIL"
fi fi
echo "${curlcmd}" | tee -a "${scriptlog}" echo "${curlcmd}" | tee -a "${scriptlog}"
echo -e "${fileurl}\n" | tee -a "${scriptlog}" echo -e "${fileurl}\n" | tee -a "${scriptlog}"
exit ${exitcode} core_exit.sh
else else
fn_print_ok_eol_nl fn_print_ok_eol_nl
if [ -f "${scriptlog}" ]; then if [ -f "${scriptlog}" ]; then
fn_scriptlog "downloading ${filename}: OK" fn_script_log_pass "downloading ${filename}: OK"
fi fi
fi fi
# remove trap # remove trap
@ -142,7 +144,10 @@ fn_fetch_file(){
fn_print_fail_eol_nl fn_print_fail_eol_nl
echo "Curl is not installed!" echo "Curl is not installed!"
echo -e "" echo -e ""
exit 1 if [ -f "${scriptlog}" ]; then
fn_script_log_fatal "Curl is not installed!"
fi
core_exit.sh
fi fi
# make file executecmd if executecmd is set # make file executecmd if executecmd is set
if [ "${executecmd}" == "executecmd" ]; then if [ "${executecmd}" == "executecmd" ]; then
@ -199,4 +204,18 @@ fn_fetch_function(){
force="noforce" force="noforce"
md5="nomd5" md5="nomd5"
fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
}
fn_update_function(){
github_file_url_dir="lgsm/functions" # github dir containing the file
github_file_url_name="${functionfile}" # name of the github file
githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
fileurl="${githuburl}"
filedir="${functionsdir}"
filename="${github_file_url_name}"
executecmd="executecmd"
run="norun"
force="noforce"
md5="nomd5"
fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
} }

38
lgsm/functions/core_exit.sh

@ -0,0 +1,38 @@
#!/bin/bash
# LGSM core_exit.sh function
# Author: Daniel Gibbs
# Website: https://gameservermanagers.com
# Description: handles exiting of LGSM by running and reporting an exit code.
fn_exit_dev_debug(){
if [ -f "${rootdir}/.dev-debug" ]; then
echo ""
echo "${function_selfname} exiting with code: ${exitcode}"
fi
}
if [ -n "${exitbypass}" ]; then
unset exitbypass
elif [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then
if [ "${exitcode}" == "1" ]; then
fn_script_log_fatal "${function_selfname} exiting with code: ${exitcode}"
elif [ "${exitcode}" == "2" ]; then
fn_script_log_error "${function_selfname} exiting with code: ${exitcode}"
elif [ "${exitcode}" == "3" ]; then
fn_script_log_warn "${function_selfname} exiting with code: ${exitcode}"
else
fn_script_log_warn "${function_selfname} exiting with code: ${exitcode}"
fi
fn_exit_dev_debug
# remove trap.
trap - INT
exit ${exitcode}
else
exitcode=0
fn_script_log_pass "${function_selfname} exiting with code: ${exitcode}"
fn_exit_dev_debug
# remove trap.
trap - INT
exit ${exitcode}
fi

43
lgsm/functions/core_functions.sh

@ -2,10 +2,8 @@
# LGSM core_functions.sh function # LGSM core_functions.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Defines all functions to allow download and execution of functions using fn_fetch_function. # Description: Defines all functions to allow download and execution of functions using fn_fetch_function.
# This function is called first before any other function. Without this file other functions would not load. # This function is called first before any other function. Without this file other functions will not load.
# Code/functions for legacy servers # Code/functions for legacy servers
@ -51,15 +49,15 @@ if [ ! -f "${filedir}/${filename}" ]; then
if [ "$(basename ${curlcmd})" == "curl" ]; then if [ "$(basename ${curlcmd})" == "curl" ]; then
curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo -e "\e[0;31mFAIL\e[0m\n" echo -e "${red}FAIL${default}\n"
echo "${curlfetch}" echo "${curlfetch}"
echo -e "${githuburl}\n" echo -e "${githuburl}\n"
exit 1 exit 1
else else
echo -e "\e[0;32mOK\e[0m" echo -e "${green}OK${default}"
fi fi
else else
echo -e "\e[0;31mFAIL\e[0m\n" echo -e "${red}FAIL${default}\n"
echo "Curl is not installed!" echo "Curl is not installed!"
echo -e "" echo -e ""
exit 1 exit 1
@ -78,17 +76,22 @@ functionfile="${FUNCNAME}"
fn_fetch_core_dl fn_fetch_core_dl
} }
core_exit.sh(){
functionfile="${FUNCNAME}"
fn_fetch_core_dl
}
core_getopt.sh(){ core_getopt.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_fetch_core_dl fn_fetch_core_dl
} }
core_messages.sh(){ core_trap.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_fetch_core_dl fn_fetch_core_dl
} }
core_dl.sh(){ core_messages.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_fetch_core_dl fn_fetch_core_dl
} }
@ -156,14 +159,9 @@ functionfile="${FUNCNAME}"
fn_fetch_function fn_fetch_function
} }
fn_restart(){ command_restart.sh(){
local modulename="Restarting" functionfile="${FUNCNAME}"
info_config.sh fn_fetch_function
if [ -d "${scriptlogdir}" ]; then
fn_scriptlog "${servername}"
fi
command_stop.sh
command_start.sh
} }
@ -367,17 +365,22 @@ fn_fetch_function
# Update # Update
update_check.sh(){ command_update_functions.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_fetch_function fn_fetch_function
} }
command_update_functions.sh(){ command_update.sh(){
functionfile="${FUNCNAME}"
fn_fetch_function
}
update_ts3.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_fetch_function fn_fetch_function
} }
update_dl.sh(){ update_steamcmd.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_fetch_function fn_fetch_function
} }
@ -476,6 +479,8 @@ functionfile="${FUNCNAME}"
fn_fetch_function fn_fetch_function
} }
# Calls the global Ctrl-C trap
core_trap.sh
# Calls on-screen messages # Calls on-screen messages
core_messages.sh core_messages.sh

282
lgsm/functions/core_getopt.sh

@ -2,23 +2,23 @@
# LGSM core_getopt.sh function # LGSM core_getopt.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: getopt arguments. # Description: getopt arguments.
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_getopt_generic(){ fn_getopt_generic(){
case "$getopt" in case "${getopt}" in
st|start) st|start)
command_start.sh;; command_start.sh;;
sp|stop) sp|stop)
command_stop.sh;; command_stop.sh;;
r|restart) r|restart)
fn_restart;; command_restart.sh;;
u|update) u|update)
update_check.sh;; command_update.sh;;
fu|force-update|update-restart) fu|force-update|update-restart)
forceupdate=1; forceupdate=1;
update_check.sh;; command_update.sh;;
uf|update-functions) uf|update-functions)
command_update_functions.sh;; command_update_functions.sh;;
v|validate) v|validate)
@ -44,42 +44,45 @@ case "$getopt" in
dd|depsdetect) dd|depsdetect)
command_dev_detect_deps.sh;; command_dev_detect_deps.sh;;
*) *)
if [ -n "${getopt}" ]; then
echo -e "${red}Unknown command${default}: $0 ${getopt}"
exitcode=2
fi
echo "Usage: $0 [option]" echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "https://gameservermanagers.com/${selfname}" echo "https://gameservermanagers.com/${selfname}"
echo -e "" echo -e ""
echo -e "\e[93mCommands\e[0m" echo -e "${lightyellow}Commands${default}"
{ {
echo -e "\e[34mstart\t\e[0mst |Start the server." echo -e "${blue}start\t${default}st |Start the server."
echo -e "\e[34mstop\t\e[0msp |Stop the server." echo -e "${blue}stop\t${default}sp |Stop the server."
echo -e "\e[34mrestart\t\e[0mr |Restart the server." echo -e "${blue}restart\t${default}r |Restart the server."
echo -e "\e[34mupdate\t\e[0mu |Checks and applies updates from SteamCMD." echo -e "${blue}update\t${default}u |Checks and applies updates from SteamCMD."
echo -e "\e[34mforce-update\t\e[0mfu |Bypasses the check and applies updates from SteamCMD." echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD."
echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded." echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
echo -e "\e[34mvalidate\t\e[0mv |Validate server files with SteamCMD." echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD."
echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running." echo -e "${blue}monitor\t${default}m |Checks that the server is running."
echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert." echo -e "${blue}test-alert\t${default}ta |Sends test alert."
echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server." echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
echo -e "\e[34mbackup\t\e[0mb |Create archive of the server." echo -e "${blue}backup\t${default}b |Create archive of the server."
echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server." echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal." echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
echo -e "\e[34minstall\t\e[0mi |Install the server." echo -e "${blue}install\t${default}i |Install the server."
echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts." echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
} | column -s $'\t' -t } | column -s $'\t' -t
esac esac
exit
} }
fn_getopt_teamspeak3(){ fn_getopt_teamspeak3(){
case "$getopt" in case "${getopt}" in
st|start) st|start)
command_start.sh;; command_start.sh;;
sp|stop) sp|stop)
command_stop.sh;; command_stop.sh;;
r|restart) r|restart)
fn_restart;; command_restart.sh;;
u|update) u|update)
update_check.sh;; command_update.sh;;
uf|update-functions) uf|update-functions)
command_update_functions.sh;; command_update_functions.sh;;
m|monitor) m|monitor)
@ -101,37 +104,40 @@ case "$getopt" in
dd|depsdetect) dd|depsdetect)
command_dev_detect_deps.sh;; command_dev_detect_deps.sh;;
*) *)
if [ -n "${getopt}" ]; then
echo -e "${red}Unknown command${default}: $0 ${getopt}"
exitcode=2
fi
echo "Usage: $0 [option]" echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "https://gameservermanagers.com/${selfname}" echo "https://gameservermanagers.com/${selfname}"
echo -e "" echo -e ""
echo -e "\e[93mCommands\e[0m" echo -e "${lightyellow}Commands${default}"
{ {
echo -e "\e[34mstart\t\e[0mst |Start the server." echo -e "${blue}start\t${default}st |Start the server."
echo -e "\e[34mstop\t\e[0msp |Stop the server." echo -e "${blue}stop\t${default}sp |Stop the server."
echo -e "\e[34mrestart\t\e[0mr |Restart the server." echo -e "${blue}restart\t${default}r |Restart the server."
echo -e "\e[34mupdate\t\e[0mu |Checks and applies updates from SteamCMD." echo -e "${blue}update\t${default}u |Checks and applies updates from SteamCMD."
echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded." echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running." echo -e "${blue}monitor\t${default}m |Checks that the server is running."
echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert." echo -e "${blue}test-alert\t${default}ta |Sends test alert."
echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server." echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
echo -e "\e[34mchange-password\t\e[0mpw |Changes TS3 serveradmin password." echo -e "${blue}change-password\t${default}pw |Changes TS3 serveradmin password."
echo -e "\e[34mbackup\t\e[0mb |Create archive of the server." echo -e "${blue}backup\t${default}b |Create archive of the server."
echo -e "\e[34minstall\t\e[0mi |Install the server." echo -e "${blue}install\t${default}i |Install the server."
echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts." echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
} | column -s $'\t' -t } | column -s $'\t' -t
esac esac
exit
} }
fn_getopt_mumble(){ fn_getopt_mumble(){
case "$getopt" in case "${getopt}" in
st|start) st|start)
command_start.sh;; command_start.sh;;
sp|stop) sp|stop)
command_stop.sh;; command_stop.sh;;
r|restart) r|restart)
fn_restart;; command_restart.sh;;
uf|update-functions) uf|update-functions)
command_update_functions.sh;; command_update_functions.sh;;
m|monitor) m|monitor)
@ -149,36 +155,39 @@ case "$getopt" in
dd|depsdetect) dd|depsdetect)
command_dev_detect_deps.sh;; command_dev_detect_deps.sh;;
*) *)
if [ -n "${getopt}" ]; then
echo -e "${red}Unknown command${default}: $0 ${getopt}"
exitcode=2
fi
echo "Usage: $0 [option]" echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "https://gameservermanagers.com/${selfname}" echo "https://gameservermanagers.com/${selfname}"
echo -e "" echo -e ""
echo -e "\e[93mCommands\e[0m" echo -e "${lightyellow}Commands${default}"
{ {
echo -e "\e[34mstart\t\e[0mst |Start the server." echo -e "${blue}start\t${default}st |Start the server."
echo -e "\e[34mstop\t\e[0msp |Stop the server." echo -e "${blue}stop\t${default}sp |Stop the server."
echo -e "\e[34mrestart\t\e[0mr |Restart the server." echo -e "${blue}restart\t${default}r |Restart the server."
echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded." echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running." echo -e "${blue}monitor\t${default}m |Checks that the server is running."
echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert." echo -e "${blue}test-alert\t${default}ta |Sends test alert."
echo -e "\e[34mbackup\t\e[0mb |Create archive of the server." echo -e "${blue}backup\t${default}b |Create archive of the server."
echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server." echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal." echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
} | column -s $'\t' -t } | column -s $'\t' -t
esac esac
exit
} }
fn_getopt_gmodserver(){ fn_getopt_gmodserver(){
case "$getopt" in case "${getopt}" in
st|start) st|start)
command_start.sh;; command_start.sh;;
sp|stop) sp|stop)
command_stop.sh;; command_stop.sh;;
r|restart) r|restart)
fn_restart;; command_restart.sh;;
u|update) u|update)
update_check.sh;; command_update.sh;;
fu|force-update|update-restart) fu|force-update|update-restart)
forceupdate=1; forceupdate=1;
update_check.sh;; update_check.sh;;
@ -209,41 +218,44 @@ case "$getopt" in
fd|fastdl) fd|fastdl)
command_fastdl.sh;; command_fastdl.sh;;
*) *)
if [ -n "${getopt}" ]; then
echo -e "${red}Unknown command${default}: $0 ${getopt}"
exitcode=2
fi
echo "Usage: $0 [option]" echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "https://gameservermanagers.com/${selfname}" echo "https://gameservermanagers.com/${selfname}"
echo -e "" echo -e ""
echo -e "\e[93mCommands\e[0m" echo -e "${lightyellow}Commands${default}"
{ {
echo -e "\e[34mstart\t\e[0mst |Start the server." echo -e "${blue}start\t${default}st |Start the server."
echo -e "\e[34mstop\t\e[0msp |Stop the server." echo -e "${blue}stop\t${default}sp |Stop the server."
echo -e "\e[34mrestart\t\e[0mr |Restart the server." echo -e "${blue}restart\t${default}r |Restart the server."
echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD." echo -e "${blue}update\t${default}Checks and applies updates from SteamCMD."
echo -e "\e[34mforce-update\t\e[0mfu |Bypasses the check and applies updates from SteamCMD." echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD."
echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded." echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
echo -e "\e[34mvalidate\t\e[0mv |Validate server files with SteamCMD." echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD."
echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running." echo -e "${blue}monitor\t${default}m |Checks that the server is running."
echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert." echo -e "${blue}test-alert\t${default}ta |Sends test alert."
echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server." echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
echo -e "\e[34mbackup\t\e[0mb |Create archive of the server." echo -e "${blue}backup\t${default}b |Create archive of the server."
echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server." echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal." echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
echo -e "\e[34minstall\t\e[0mi |Install the server." echo -e "${blue}install\t${default}i |Install the server."
echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts." echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
echo -e "\e[34mfastdl\t\e[0mfd |Generates or update a FastDL folder for your server." echo -e "${blue}fastdl\t${default}fd |Generates or update a FastDL folder for your server."
} | column -s $'\t' -t } | column -s $'\t' -t
esac esac
exit
} }
fn_getopt_unreal(){ fn_getopt_unreal(){
case "$getopt" in case "${getopt}" in
st|start) st|start)
command_start.sh;; command_start.sh;;
sp|stop) sp|stop)
command_stop.sh;; command_stop.sh;;
r|restart) r|restart)
fn_restart;; command_restart.sh;;
uf|update-functions) uf|update-functions)
command_update_functions.sh;; command_update_functions.sh;;
m|monitor) m|monitor)
@ -269,41 +281,44 @@ case "$getopt" in
dd|depsdetect) dd|depsdetect)
command_dev_detect_deps.sh;; command_dev_detect_deps.sh;;
*) *)
if [ -n "${getopt}" ]; then
echo -e "${red}Unknown command${default}: $0 ${getopt}"
exitcode=2
fi
echo "Usage: $0 [option]" echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "https://gameservermanagers.com/${selfname}" echo "https://gameservermanagers.com/${selfname}"
echo -e "" echo -e ""
echo -e "\e[93mCommands\e[0m" echo -e "${lightyellow}Commands${default}"
{ {
echo -e "\e[34mstart\t\e[0mst |Start the server." echo -e "${blue}start\t${default}st |Start the server."
echo -e "\e[34mstop\t\e[0msp |Stop the server." echo -e "${blue}stop\t${default}sp |Stop the server."
echo -e "\e[34mrestart\t\e[0mr |Restart the server." echo -e "${blue}restart\t${default}r |Restart the server."
echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded." echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running." echo -e "${blue}monitor\t${default}m |Checks that the server is running."
echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert." echo -e "${blue}test-alert\t${default}ta |Sends test alert."
echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server." echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
echo -e "\e[34mbackup\t\e[0mb |Create archive of the server." echo -e "${blue}backup\t${default}b |Create archive of the server."
echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server." echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal." echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
echo -e "\e[34minstall\t\e[0mi |Install the server." echo -e "${blue}install\t${default}i |Install the server."
echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts." echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
echo -e "\e[34mmap-compressor\t\e[0mmc |Compresses all ${gamename} server maps." echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps."
} | column -s $'\t' -t } | column -s $'\t' -t
esac esac
exit
} }
fn_getopt_unreal2(){ fn_getopt_unreal2(){
case "$getopt" in case "${getopt}" in
st|start) st|start)
command_start.sh;; command_start.sh;;
sp|stop) sp|stop)
command_stop.sh;; command_stop.sh;;
r|restart) r|restart)
fn_restart;; command_restart.sh;;
u|update) u|update)
update_check.sh;; command_update.sh;;
fu|force-update|update-restart) fu|force-update|update-restart)
forceupdate=1; forceupdate=1;
update_check.sh;; update_check.sh;;
@ -334,42 +349,45 @@ case "$getopt" in
mc|map-compressor) mc|map-compressor)
compress_unreal2_maps.sh;; compress_unreal2_maps.sh;;
*) *)
if [ -n "${getopt}" ]; then
echo -e "${red}Unknown command${default}: $0 ${getopt}"
exitcode=2
fi
echo "Usage: $0 [option]" echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "https://gameservermanagers.com/${selfname}" echo "https://gameservermanagers.com/${selfname}"
echo -e "" echo -e ""
echo -e "\e[93mCommands\e[0m" echo -e "${lightyellow}Commands${default}"
{ {
echo -e "\e[34mstart\t\e[0mst |Start the server." echo -e "${blue}start\t${default}st |Start the server."
echo -e "\e[34mstop\t\e[0msp |Stop the server." echo -e "${blue}stop\t${default}sp |Stop the server."
echo -e "\e[34mrestart\t\e[0mr |Restart the server." echo -e "${blue}restart\t${default}r |Restart the server."
echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD." echo -e "${blue}update\t${default}Checks and applies updates from SteamCMD."
echo -e "\e[34mforce-update\t\e[0mfu |Bypasses the check and applies updates from SteamCMD." echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD."
echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded." echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
echo -e "\e[34mvalidate\t\e[0mv |Validate server files with SteamCMD." echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD."
echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running." echo -e "${blue}monitor\t${default}m |Checks that the server is running."
echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert." echo -e "${blue}test-alert\t${default}ta |Sends test alert."
echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server." echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
echo -e "\e[34mbackup\t\e[0mb |Create archive of the server." echo -e "${blue}backup\t${default}b |Create archive of the server."
echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server." echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal." echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
echo -e "\e[34minstall\t\e[0mi |Install the server." echo -e "${blue}install\t${default}i |Install the server."
echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts." echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
echo -e "\e[34mmap-compressor\t\e[0mmc |Compresses all ${gamename} server maps." echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps."
} | column -s $'\t' -t } | column -s $'\t' -t
esac esac
exit
} }
fn_getopt_ut2k4(){ fn_getopt_ut2k4(){
case "$getopt" in case "${getopt}" in
st|start) st|start)
command_start.sh;; command_start.sh;;
sp|stop) sp|stop)
command_stop.sh;; command_stop.sh;;
r|restart) r|restart)
fn_restart;; command_restart.sh;;
uf|update-functions) uf|update-functions)
command_update_functions.sh;; command_update_functions.sh;;
m|monitor) m|monitor)
@ -397,29 +415,32 @@ case "$getopt" in
dd|depsdetect) dd|depsdetect)
command_dev_detect_deps.sh;; command_dev_detect_deps.sh;;
*) *)
if [ -n "${getopt}" ]; then
echo -e "${red}Unknown command${default}: $0 ${getopt}"
exitcode=2
fi
echo "Usage: $0 [option]" echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "https://gameservermanagers.com/${selfname}" echo "https://gameservermanagers.com/${selfname}"
echo -e "" echo -e ""
echo -e "\e[93mCommands\e[0m" echo -e "${lightyellow}Commands${default}"
{ {
echo -e "\e[34mstart\t\e[0mst |Start the server." echo -e "${blue}start\t${default}st |Start the server."
echo -e "\e[34mstop\t\e[0msp |Stop the server." echo -e "${blue}stop\t${default}sp |Stop the server."
echo -e "\e[34mrestart\t\e[0mr |Restart the server." echo -e "${blue}restart\t${default}r |Restart the server."
echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded." echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running." echo -e "${blue}monitor\t${default}m |Checks that the server is running."
echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert." echo -e "${blue}test-alert\t${default}ta |Sends test alert."
echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server." echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
echo -e "\e[34mbackup\t\e[0mb |Create archive of the server." echo -e "${blue}backup\t${default}b |Create archive of the server."
echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server." echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal." echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
echo -e "\e[34minstall\t\e[0mi |Install the server." echo -e "${blue}install\t${default}i |Install the server."
echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts." echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
echo -e "\e[34mserver-cd-key\t\e[0mcd |Add your server cd key" echo -e "${blue}server-cd-key\t${default}cd |Add your server cd key"
echo -e "\e[34mmap-compressor\t\e[0mmc |Compresses all ${gamename} server maps." echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps."
} | column -s $'\t' -t } | column -s $'\t' -t
esac esac
exit
} }
if [ "${gamename}" == "Mumble" ]; then if [ "${gamename}" == "Mumble" ]; then
@ -439,3 +460,4 @@ elif [ "${engine}" == "unreal" ]; then
else else
fn_getopt_generic fn_getopt_generic
fi fi
core_exit.sh

295
lgsm/functions/core_messages.sh

@ -1,204 +1,331 @@
#!/bin/bash #!/bin/bash
# LGSM fn_messages function # LGSM core_messages.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Defines on-screen messages such as [ OK ] and how script logs look. # Description: Defines on-screen messages such as [ OK ] and how script logs look.
# nl: new line: message is following by a new line # nl: new line: message is following by a new line
# eol: end of line: message is placed at the end of the current line # eol: end of line: message is placed at the end of the current line
# Date, servicename & module details displayed in log files. if [ "${ansi}" != "off" ]; then
# e.g Feb 28 14:56:58 ut99-server: Monitor: # echo colors
fn_scriptlog(){ default="\e[0m"
if [ -n "${modulename}" ]; then red="\e[31m"
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: ${1}" >> "${scriptlog}" green="\e[32m"
yellow="\e[33m"
blue="\e[34m"
magenta="\e[35m"
cyan="\e[36m"
lightyellow="\e[93m"
# carriage return & erase to end of line
creeol="\r\033[K"
fi
# Log display
##########
## Feb 28 14:56:58 ut99-server: Monitor:
fn_script_log(){
if [ -n "${commandaction}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: ${1}" >> "${scriptlog}"
else else
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${1}" >> "${scriptlog}" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${1}" >> "${scriptlog}"
fi fi
} }
# [ FAIL ] ## Feb 28 14:56:58 ut99-server: Monitor: PASS:
fn_print_fail(){ fn_script_log_pass(){
if [ -n "${modulename}" ]; then if [ -n "${commandaction}" ]; then
echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${modulename} ${servicename}: $@" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: PASS: ${1}" >> "${scriptlog}"
else else
echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@" echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: PASS: ${1}" >> "${scriptlog}"
fi fi
exitcode=0
} }
fn_print_fail_nl(){ ## Feb 28 14:56:58 ut99-server: Monitor: FATAL:
if [ -n "${modulename}" ]; then fn_script_log_fatal(){
echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${modulename} ${servicename}: $@" if [ -n "${commandaction}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: FATAL: ${1}" >> "${scriptlog}"
else
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: FATAL: ${1}" >> "${scriptlog}"
fi
exitcode=1
}
## Feb 28 14:56:58 ut99-server: Monitor: ERROR:
fn_script_log_error(){
if [ -n "${commandaction}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: ERROR: ${1}" >> "${scriptlog}"
else
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ERROR: ${1}" >> "${scriptlog}"
fi
exitcode=2
}
## Feb 28 14:56:58 ut99-server: Monitor: WARN:
fn_script_log_warn(){
if [ -n "${commandaction}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: WARN: ${1}" >> "${scriptlog}"
else
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: WARN: ${1}" >> "${scriptlog}"
fi
exitcode=3
}
## Feb 28 14:56:58 ut99-server: Monitor: INFO:
fn_script_log_info(){
if [ -n "${commandaction}" ]; then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: INFO: ${1}" >> "${scriptlog}"
else
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: INFO: ${1}" >> "${scriptlog}"
fi
}
# On-Screen
##########
# [ .... ]
fn_print_dots(){
if [ -n "${commandaction}" ]; then
echo -en "${creeol}[ .... ] ${commandaction} ${servicename}: $@"
else
echo -en "${creeol}[ .... ] $@"
fi
}
fn_print_dots_nl(){
if [ -n "${commandaction}" ]; then
echo -e "${creeol}[ .... ] ${commandaction} ${servicename}: $@"
else else
echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@" echo -e "${creeol}[ .... ] $@"
fi fi
sleep 1 sleep 0.5
echo -en "\n" echo -en "\n"
} }
# [ OK ] # [ OK ]
fn_print_ok(){ fn_print_ok(){
if [ -n "${modulename}" ]; then if [ -n "${commandaction}" ]; then
echo -en "\r\033[K[\e[0;32m OK \e[0m] ${modulename} ${servicename}: $@" echo -en "${creeol}[${green} OK ${default}] ${commandaction} ${servicename}: $@"
else else
echo -en "\r\033[K[\e[0;32m OK \e[0m] $@" echo -en "${creeol}[${green} OK ${default}] $@"
fi fi
} }
fn_print_ok_nl(){ fn_print_ok_nl(){
if [ -n "${modulename}" ]; then if [ -n "${commandaction}" ]; then
echo -en "\r\033[K[\e[0;32m OK \e[0m] ${modulename} ${servicename}: $@" echo -en "${creeol}[${green} OK ${default}] ${commandaction} ${servicename}: $@"
else else
echo -en "\r\033[K[\e[0;32m OK \e[0m] $@" echo -en "${creeol}[${green} OK ${default}] $@"
fi fi
sleep 1 sleep 0.5
echo -en "\n" echo -en "\n"
} }
# [ INFO ] # [ FAIL ]
fn_print_info(){ fn_print_fail(){
if [ -n "${modulename}" ]; then if [ -n "${commandaction}" ]; then
echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${modulename} ${servicename}: $@" echo -en "${creeol}[${red} FAIL ${default}] ${commandaction} ${servicename}: $@"
else else
echo -en "\r\033[K[\e[0;36m INFO \e[0m] $@" echo -en "${creeol}[${red} FAIL ${default}] $@"
fi fi
} }
fn_print_info_nl(){ fn_print_fail_nl(){
if [ -n "${modulename}" ]; then if [ -n "${commandaction}" ]; then
echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${modulename} ${servicename}: $@" echo -en "${creeol}[${red} FAIL ${default}] ${commandaction} ${servicename}: $@"
else
echo -en "${creeol}[${red} FAIL ${default}] $@"
fi
sleep 0.5
echo -en "\n"
}
# [ ERROR ]
fn_print_error(){
if [ -n "${commandaction}" ]; then
echo -en "${creeol}[${red}ERROR ${default}] ${commandaction} ${servicename}: $@"
else
echo -en "${creeol}[${red}ERROR ${default}] $@"
fi
}
fn_print_error_nl(){
if [ -n "${commandaction}" ]; then
echo -en "${creeol}[${red}ERROR ${default}] ${commandaction} ${servicename}: $@"
else else
echo -en "\r\033[K[\e[0;36m INFO \e[0m] $@" echo -en "${creeol}[${red}ERROR ${default}] $@"
fi fi
sleep 1 sleep 0.5
echo -en "\n" echo -en "\n"
} }
# [ WARN ] # [ WARN ]
fn_print_warn(){ fn_print_warn(){
if [ -n "${modulename}" ]; then if [ -n "${commandaction}" ]; then
echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${modulename} ${servicename}: $@" echo -en "${creeol}[${yellow} WARN ${default}] ${commandaction} ${servicename}: $@"
else else
echo -en "\r\033[K[\e[1;33m WARN \e[0m] $@" echo -en "${creeol}[${yellow} WARN ${default}] $@"
fi fi
} }
fn_print_warn_nl(){ fn_print_warn_nl(){
if [ -n "${modulename}" ]; then if [ -n "${commandaction}" ]; then
echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${modulename} ${servicename}: $@" echo -en "${creeol}[${yellow} WARN ${default}] ${commandaction} ${servicename}: $@"
else else
echo -en "\r\033[K[\e[1;33m WARN \e[0m] $@" echo -en "${creeol}[${yellow} WARN ${default}] $@"
fi fi
sleep 1 sleep 0.5
echo -en "\n" echo -en "\n"
} }
# [ .... ] # [ INFO ]
fn_print_dots(){ fn_print_info(){
if [ -n "${modulename}" ]; then if [ -n "${commandaction}" ]; then
echo -en "\r\033[K[ .... ] ${modulename} ${servicename}: $@" echo -en "${creeol}[${cyan} INFO ${default}] ${commandaction} ${servicename}: $@"
else else
echo -en "\r\033[K[ .... ] $@" echo -en "${creeol}[${cyan} INFO ${default}] $@"
fi fi
} }
# Complete! fn_print_info_nl(){
fn_print_complete(){ if [ -n "${commandaction}" ]; then
echo -en "\e[0;32mComplete!\e[0m $@" echo -en "${creeol}[${cyan} INFO ${default}] ${commandaction} ${servicename}: $@"
else
echo -en "${creeol}[${cyan} INFO ${default}] $@"
fi
sleep 0.5
echo -en "\n"
} }
fn_print_complete_nl(){ # On-Screen full word
echo -e "\e[0;32mComplete!\e[0m $@" ##########
}
# Warning! # Complete!
fn_print_warning(){ fn_print_complete(){
echo -en "\e[0;33mWarning!\e[0m $@" echo -en "${green}Complete!${default} $@"
} }
fn_print_warning_nl(){ fn_print_complete_nl(){
echo -e "\e[0;33mWarning!\e[0m $@" echo -e "${green}Complete!${default} $@"
} }
# Failure! # Failure!
fn_print_failure(){ fn_print_failure(){
echo -en "\e[0;31mFailure!\e[0m $@" echo -en "${red}Failure!${default} $@"
} }
fn_print_failure_nl(){ fn_print_failure_nl(){
echo -e "\e[0;31mFailure!\e[0m $@" echo -e "${red}Failure!${default} $@"
} }
# Error! # Error!
fn_print_error(){ fn_print_error2(){
echo -en "\e[0;31mError!\e[0m $@" echo -en "${red}Error!${default} $@"
} }
fn_print_error_nl(){ fn_print_error2_nl(){
echo -e "\e[0;31mError!\e[0m $@" echo -e "${red}Error!${default} $@"
}
# Warning!
fn_print_warning(){
echo -en "${yellow}Warning!${default} $@"
}
fn_print_warning_nl(){
echo -e "${yellow}Warning!${default} $@"
} }
# Infomation! # Infomation!
fn_print_infomation(){ fn_print_infomation(){
echo -en "\e[0;36mInfomation!\e[0m $@" echo -en "${cyan}Infomation!${default} $@"
} }
fn_print_infomation_nl(){ fn_print_infomation_nl(){
echo -e "\e[0;36mInfomation!\e[0m $@" echo -e "${cyan}Infomation!${default} $@"
} }
# FAIL for end of line # On-Screen End of Line
##########
# OK
fn_print_ok_eol(){ fn_print_ok_eol(){
echo -en "\e[0;32mOK\e[0m" echo -en "${green}OK${default}"
} }
fn_print_ok_eol_nl(){ fn_print_ok_eol_nl(){
echo -e "\e[0;32mOK\e[0m" echo -e "${green}OK${default}"
} }
# FAIL for end of line # FAIL
fn_print_fail_eol(){ fn_print_fail_eol(){
echo -en "\e[0;31mFAIL\e[0m" echo -en "${red}FAIL${default}"
} }
fn_print_fail_eol_nl(){ fn_print_fail_eol_nl(){
echo -e "\e[0;31mFAIL\e[0m" echo -e "${red}FAIL${default}"
}
# WARN
fn_print_warn_eol(){
echo -en "${red}FAIL${default}"
} }
# QUERYING for end of line fn_print_warn_eol_nl(){
echo -e "${red}FAIL${default}"
}
# INFO
fn_print_info_eol(){
echo -en "${red}FAIL${default}"
}
fn_print_info_eol_nl(){
echo -e "${red}FAIL${default}"
}
# QUERYING
fn_print_querying_eol(){ fn_print_querying_eol(){
echo -en "\e[0;36mQUERYING\e[0m" echo -en "${cyan}QUERYING${default}"
} }
fn_print_querying_eol_nl(){ fn_print_querying_eol_nl(){
echo -e "\e[0;36mQUERYING\e[0m" echo -e "${cyan}QUERYING${default}"
} }
# CHECKING for end of line # CHECKING
fn_print_checking_eol(){ fn_print_checking_eol(){
echo -en "\e[0;36mCHECKING\e[0m" echo -en "${cyan}CHECKING${default}"
} }
fn_print_checking_eol_nl(){ fn_print_checking_eol_nl(){
echo -e "\e[0;36mCHECKING\e[0m" echo -e "${cyan}CHECKING${default}"
} }
# CANCELED for end of line # CANCELED
fn_print_canceled_eol(){ fn_print_canceled_eol(){
echo -en "\e[0;33mCANCELED\e[0m" echo -en "${yellow}CANCELED${default}"
} }
fn_print_canceled_eol_nl(){ fn_print_canceled_eol_nl(){
echo -e "\e[0;33mCANCELED\e[0m" echo -e "${yellow}CANCELED${default}"
} }
# REMOVED for end of line # REMOVED
fn_print_removed_eol(){ fn_print_removed_eol(){
echo -en "\e[0;31mREMOVED\e[0m" echo -en "${red}REMOVED${default}"
} }
fn_print_removed_eol_nl(){ fn_print_removed_eol_nl(){
echo -e "\e[0;31mREMOVED\e[0m" echo -e "${red}REMOVED${default}"
}
# UPDATE
fn_print_update_eol(){
echo -en "${cyan}UPDATE${default}"
}
fn_print_update_eol_nl(){
echo -e "${cyan}UPDATE${default}"
} }

13
lgsm/functions/core_trap.sh

@ -0,0 +1,13 @@
#!/bin/bash
# LGSM core_trap.sh function
# Author: Daniel Gibbs
# Website: https://gameservermanagers.com
# Description: handles ctrl-C trap to give an exitcode.
fn_exit_trap(){
echo ""
core_exit.sh
}
# trap to give an exitcode.
trap fn_exit_trap INT

14
lgsm/functions/fix.sh

@ -2,27 +2,29 @@
# LGSM fix.sh function # LGSM fix.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Overall function for managing fixes. # Description: Overall function for managing fixes.
# Runs functions that will fix an issue. # Runs functions that will fix an issue.
local commandname="FIX"
local commandaction="Fix"
# Messages that are displayed for some fixes # Messages that are displayed for some fixes
fn_fix_msg_start(){ fn_fix_msg_start(){
fn_print_dots "Applying ${fixname} fix: ${gamename}" fn_print_dots "Applying ${fixname} fix: ${gamename}"
sleep 1 sleep 1
fn_print_info "Applying ${fixname} fix: ${gamename}" fn_print_info "Applying ${fixname} fix: ${gamename}"
fn_scriptlog "Applying ${fixname} fix: ${gamename}" fn_script_log_info "Applying ${fixname} fix: ${gamename}"
sleep 1 sleep 1
} }
fn_fix_msg_end(){ fn_fix_msg_end(){
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
fn_print_fail_nl "Applying ${fixname} fix: ${gamename}" fn_print_error_nl "Applying ${fixname} fix: ${gamename}"
fn_scriptlog "Failure! Applying ${fixname} fix: ${gamename}" fn_script_log_error "Applying ${fixname} fix: ${gamename}"
exitcode=2
else else
fn_print_ok_nl "Applying ${fixname} fix: ${gamename}" fn_print_ok_nl "Applying ${fixname} fix: ${gamename}"
fn_scriptlog "Complete! Applying ${fixname} fix: ${gamename}" fn_script_log_pass "Applying ${fixname} fix: ${gamename}"
fi fi
} }

6
lgsm/functions/fix_arma3.sh

@ -2,7 +2,11 @@
# LGSM fix_arma3.sh function # LGSM fix_arma3.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="240516" # Description: Resolves an issue with ARMA3.
local commandname="FIX"
local commandaction="Fix"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
# Fixes: 20150 Segmentation fault (core dumped) error. # Fixes: 20150 Segmentation fault (core dumped) error.
if [ ! -d "${HOME}/.local/share/Arma 3" ]||[ ! -d "${HOME}/.local/share/Arma 3 - Other Profiles" ]; then if [ ! -d "${HOME}/.local/share/Arma 3" ]||[ ! -d "${HOME}/.local/share/Arma 3 - Other Profiles" ]; then

6
lgsm/functions/fix_csgo.sh

@ -2,10 +2,12 @@
# LGSM fix_csgo.sh function # LGSM fix_csgo.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Resolves various issues with csgo. # Description: Resolves various issues with csgo.
local commandname="FIX"
local commandaction="Fix"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
# Fixes: server not always creating steam_appid.txt file. # Fixes: server not always creating steam_appid.txt file.
if [ ! -f "${filesdir}/steam_appid.txt" ]; then if [ ! -f "${filesdir}/steam_appid.txt" ]; then
fixname="730 steam_appid.txt" fixname="730 steam_appid.txt"

6
lgsm/functions/fix_dst.sh

@ -2,10 +2,12 @@
# LGSM fix_dst.sh function # LGSM fix_dst.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Resolves various issues with Dont Starve together. # Description: Resolves various issues with Dont Starve together.
local commandname="FIX"
local commandaction="Fix"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
# Fixes: ./dontstarve_dedicated_server_nullrenderer: ./lib32/libcurl-gnutls.so.4: no version information available (required by ./dontstarve_dedicated_server_nullrenderer) # Fixes: ./dontstarve_dedicated_server_nullrenderer: ./lib32/libcurl-gnutls.so.4: no version information available (required by ./dontstarve_dedicated_server_nullrenderer)
# Issue only occures on CentOS as libcurl-gnutls.so.4 is called libcurl.so.4 on CentOS. # Issue only occures on CentOS as libcurl-gnutls.so.4 is called libcurl.so.4 on CentOS.
if [ -f "/etc/redhat-release" ] && [ ! -f "${filesdir}/bin/lib32/libcurl-gnutls.so.4" ]; then if [ -f "/etc/redhat-release" ] && [ ! -f "${filesdir}/bin/lib32/libcurl-gnutls.so.4" ]; then

6
lgsm/functions/fix_glibc.sh

@ -2,10 +2,12 @@
# LGSM fix_glibc.sh function # LGSM fix_glibc.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Downloads required glibc files and applys teh glibc fix if required # Description: Downloads required glibc files and applys teh glibc fix if required
local commandname="FIX"
local commandaction="Fix"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
local libstdc_servers_array=( "ARMA 3" "Blade Symphony" "Garry's Mod" "Just Cause 2" ) local libstdc_servers_array=( "ARMA 3" "Blade Symphony" "Garry's Mod" "Just Cause 2" )
for libstdc_server in "${libstdc_servers_array[@]}" for libstdc_server in "${libstdc_servers_array[@]}"
do do

13
lgsm/functions/fix_ins.sh

@ -2,18 +2,19 @@
# LGSM fix_ins.sh function # LGSM fix_ins.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Resolves various issues with Insurgency. # Description: Resolves various issues with Insurgency.
# Resolves ./srcds_linux: error while loading shared libraries: libtier0.so: cannot open shared object file: No such file or directory local commandname="FIX"
local commandaction="Fix"
# Fixes: ./srcds_linux: error while loading shared libraries: libtier0.so: cannot open shared object file: No such file or directory.
export LD_LIBRARY_PATH=${filesdir}:${filesdir}/bin:${LD_LIBRARY_PATH} export LD_LIBRARY_PATH=${filesdir}:${filesdir}/bin:${LD_LIBRARY_PATH}
# fix for issue #529 - gamemode not passed to debug or start # Fixes: issue #529 - gamemode not passed to debug or start.
if [ "${function_selfname}" == "command_debug.sh" ]; then if [ "${function_selfname}" == "command_debug.sh" ]; then
defaultmap="\"${defaultmap}\"" defaultmap="\"${defaultmap}\""
else else
defaultmap="\\\"${defaultmap}\\\"" defaultmap="\\\"${defaultmap}\\\""
fi fi

6
lgsm/functions/fix_kf.sh

@ -2,7 +2,11 @@
# LGSM fix_kf.sh function # LGSM fix_kf.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516" # Description: Resolves various issues with Killing Floor.
local commandname="FIX"
local commandaction="Fix"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
echo "Applying WebAdmin ROOst.css fix." echo "Applying WebAdmin ROOst.css fix."
echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13"

6
lgsm/functions/fix_ro.sh

@ -2,9 +2,11 @@
# LGSM fix_ro.sh function # LGSM fix_ro.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516" # Description: Resolves various issues with Red Orchestra.
# Description: Resolves various issues with red orchestra. local commandname="FIX"
local commandaction="Fix"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
echo "Applying WebAdmin ROOst.css fix." echo "Applying WebAdmin ROOst.css fix."
echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13"

6
lgsm/functions/fix_steamcmd.sh

@ -2,9 +2,11 @@
# LGSM fix_steamcmd.sh function # LGSM fix_steamcmd.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516" # Description: Resolves various issues related to steamCMD.
# Description: fixes various issues related to steamCMD. local commandname="FIX"
local commandaction="Fix"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
# Fixes: [S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam,or a local steamclient.so. # Fixes: [S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam,or a local steamclient.so.
if [ ! -f "${HOME}/.steam/sdk32/steamclient.so" ]; then if [ ! -f "${HOME}/.steam/sdk32/steamclient.so" ]; then

6
lgsm/functions/fix_ut2k4.sh

@ -2,9 +2,11 @@
# LGSM fix_ut2k4.sh function # LGSM fix_ut2k4.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516" # Description: Resolves various issues with Unreal Tournament 2004.
# Description: Resolves various issues with unreal tournament 2004. local commandname="FIX"
local commandaction="Fix"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
echo "applying WebAdmin ut2003.css fix." echo "applying WebAdmin ut2003.css fix."
echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13"

7
lgsm/functions/fix_ut99.sh

@ -2,7 +2,12 @@
# LGSM fix_ut99.sh function # LGSM fix_ut99.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516" # Description: Resolves various issues with Unreal Tournament 99.
local commandname="FIX"
local commandaction="Fix"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
echo "${servercfgfullpath}" echo "${servercfgfullpath}"
echo "enabling UdpServerUplink." echo "enabling UdpServerUplink."
{ {

2
lgsm/functions/fn_functions

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# LGSM core_functions.sh function # LGSM fn_functions function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516" lgsm_version="210516"

2
lgsm/functions/fn_getopt

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# LGSM core_getopt.sh function # LGSM fn_getopt function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516" lgsm_version="210516"

7
lgsm/functions/fn_update_functions

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# LGSM fn_update_functions.sh function # LGSM fn_update_functions function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516" lgsm_version="210516"
@ -7,16 +7,15 @@ lgsm_version="210516"
# Description: LEGACY FUNCTION Deletes the functions dir to allow re-downloading of functions from GitHub. # Description: LEGACY FUNCTION Deletes the functions dir to allow re-downloading of functions from GitHub.
fn_print_dots "Updating functions" fn_print_dots "Updating functions"
fn_scriptlog "Updating functions"
sleep 1 sleep 1
echo -ne "\n" echo -ne "\n"
rm -rfv "${rootdir}/functions/"* rm -rfv "${rootdir}/functions/"*
exitcode=$? exitcode=$?
if [ "${exitcode}" == "0" ]; then if [ "${exitcode}" == "0" ]; then
fn_print_ok "Updating functions" fn_print_ok "Updating functions"
fn_scriptlog "Success! Updating functions" fn_script_log "Success! Updating functions"
else else
fn_print_fail "Updating functions" fn_print_fail "Updating functions"
fn_scriptlog "Failure! Updating functions" fn_script_log "Failure! Updating functions"
fi fi
echo -ne "\n" echo -ne "\n"

4
lgsm/functions/gsquery.py

@ -2,8 +2,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Game Server Query # Game Server Query
# Author: Anonymous & Daniel Gibbs # Author: Anonymous & Daniel Gibbs
# # Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
# Version: 190216 # Description: Handles querying of .
import optparse import optparse
import socket import socket

8
lgsm/functions/info_config.sh

@ -2,18 +2,18 @@
# LGSM info_config.sh function # LGSM info_config.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Gets specific details from config files. # Description: Gets specific details from config files.
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
## Examples of filtering to get info from config files ## Examples of filtering to get info from config files
# sed 's/foo//g' - remove foo # sed 's/foo//g' - remove foo
# tr -cd '[:digit:]' leave only digits # tr -cd '[:digit:]' leave only digits
# tr -d '=\"; ' remove selected charectors =\"; # tr -d '=\"; ' remove selected charectors =\";
# grep -v "foo" filter out lines that contain foo # grep -v "foo" filter out lines that contain foo
unavailable="\e[0;31mUNAVAILABLE\e[0m" unavailable="${red}UNAVAILABLE${default}"
zero="\e[0;31m0\e[0m" zero="${red}0${default}"
fn_info_config_avalanche(){ fn_info_config_avalanche(){
if [ ! -f "${servercfgfullpath}" ]; then if [ ! -f "${servercfgfullpath}" ]; then

88
lgsm/functions/info_distro.sh

@ -2,86 +2,106 @@
# LGSM info_distro.sh function # LGSM info_distro.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Variables providing useful info on the Operating System such as disk and performace info. # Description: Variables providing useful info on the Operating System such as disk and performace info.
# Used for command_details.sh, command_debug.sh and email.sh. # Used for command_details.sh, command_debug.sh and alert.sh.
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
### Distro infomation
## Distro infomation ## Distro
# Returns architecture, kernel and distro/os. # Returns architecture, kernel and distro/os.
arch=$(uname -m) arch=$(uname -m)
kernel=$(uname -r) kernel=$(uname -r)
if [ -n "$(command -v lsb_release)" ]; then if [ -n "$(command -v lsb_release)" ]; then
os=$(lsb_release -s -d) os=$(lsb_release -s -d)
elif [ -f /etc/debian_version ]; then elif [ -f "/etc/debian_version" ]; then
os="Debian $(cat /etc/debian_version)" os="Debian $(cat /etc/debian_version)"
elif [ -f /etc/redhat-release ]; then elif [ -f "/etc/redhat-release" ]; then
os=$(cat /etc/redhat-release) os=$(cat /etc/redhat-release)
else else
os="$(uname -s) $(uname -r)" os="$(uname -s) $(uname -r)"
fi fi
# Glibc version number ## Glibc version
# e.g: 1.17 # e.g: 1.17
glibcversion="$(ldd --version | sed -n '1s/.* //p')" glibcversion="$(ldd --version | sed -n '1s/.* //p')"
# tmux version ## tmux version
# e.g: tmux 1.6 # e.g: tmux 1.6
if [ -z "$(command -v tmux)" ]; then if [ -z "$(command -v tmux)" ]; then
tmuxv="\e[0;31mNOT INSTALLED!\e[0m" tmuxv="${red}NOT INSTALLED!${default}"
elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ]; then elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ]; then
tmuxv="$(tmux -V) (>= 1.6 required for console log)" tmuxv="$(tmux -V) (>= 1.6 required for console log)"
else else
tmuxv=$(tmux -V) tmuxv=$(tmux -V)
fi fi
## Performance ## Uptime
uptime=$(</proc/uptime)
uptime=${uptime/[. ]*/}
minutes=$(( uptime/60%60 ))
hours=$(( uptime/60/60%24 ))
days=$(( uptime/60/60/24 ))
# Average server load ### Performance infomation
## Average server load
load=$(uptime|awk -F 'load average: ' '{ print $2 }') load=$(uptime|awk -F 'load average: ' '{ print $2 }')
# Memory ## Memory Infomation
# Available RAM and swap.
# Older versions of free do not support -h option. # Older versions of free do not support -h option.
if [ "$(free -h > /dev/null 2>&1; echo $?)" -ne "0" ]; then if [ "$(free -h > /dev/null 2>&1; echo $?)" -ne "0" ]; then
option="-m" humanreadable="-m"
else else
option="-h" humanreadable="-h"
fi fi
physmemtotal=$(free ${option} | awk '/Mem:/ {print $2}')
physmemused=$(free ${option} | awk '/Mem:/ {print $3}')
physmemfree=$(free ${option} | awk '/Mem:/ {print $4}')
swaptotal=$(free ${option} | awk '/Swap:/ {print $2}')
swapused=$(free ${option} | awk '/Swap:/ {print $3}')
swapfree=$(free ${option} | awk '/Swap:/ {print $4}')
# Uptime
uptime=$(</proc/uptime)
uptime=${uptime/[. ]*/}
minutes=$(( uptime/60%60 ))
hours=$(( uptime/60/60%24 ))
days=$(( uptime/60/60/24 ))
# Disk usage physmemtotal=$(free ${humanreadable} | awk '/Mem:/ {print $2}')
# available space on the partition. physmemused=$(free ${humanreadable} | awk '/Mem:/ {print $3}')
physmemfree=$(free ${humanreadable} | awk '/Mem:/ {print $4}')
swaptotal=$(free ${humanreadable} | awk '/Swap:/ {print $2}')
swapused=$(free ${humanreadable} | awk '/Swap:/ {print $3}')
swapfree=$(free ${humanreadable} | awk '/Swap:/ {print $4}')
### Disk Infomation
## Available disk space on the partition.
filesystem=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $1}') filesystem=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $1}')
totalspace=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $2}') totalspace=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $2}')
usedspace=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $3}') usedspace=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $3}')
availspace=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $4}') availspace=$(df -hP "${rootdir}" | grep -v "Filesystem" | awk '{print $4}')
# used space in serverfiles dir. ## LGSM used space total.
rootdirdu=$(du -sh "${rootdir}" 2> /dev/null | awk '{print $1}')
if [ -z "${rootdirdu}" ]; then
rootdirdu="0M"
fi
## LGSM used space in serverfiles dir.
filesdirdu=$(du -sh "${filesdir}" 2> /dev/null | awk '{print $1}') filesdirdu=$(du -sh "${filesdir}" 2> /dev/null | awk '{print $1}')
if [ -z ${filesdirdu} ]; then if [ -z "${filesdirdu}" ]; then
filesdirdu="0M" filesdirdu="0M"
fi fi
# Backup info ## LGSM used space total minus backup dir.
rootdirduexbackup=$(du -sh --exclude="${backupdir}" "${filesdir}" 2> /dev/null | awk '{print $1}')
if [ -z "${rootdirduexbackup}" ]; then
rootdirduexbackup="0M"
fi
## Backup info
if [ -d "${backupdir}" ]; then if [ -d "${backupdir}" ]; then
# used space in backups dir. # used space in backups dir.
backupdirdu=$(du -sh "${backupdir}" | awk '{print $1}') backupdirdu=$(du -sh "${backupdir}" | awk '{print $1}')
if [ -z ${backupdirdu} ]; then if [ -z "${backupdirdu}" ]; then
backupdirdu="0M" backupdirdu="0M"
fi fi
# number of backups. # number of backups.
backupcount=$(find "${backupdir}"/*.tar.gz | wc -l) backupcount=$(find "${backupdir}"/*.tar.gz | wc -l)
# most recent backup. # most recent backup.
@ -91,4 +111,4 @@ if [ -d "${backupdir}" ]; then
# size of most recent backup. # size of most recent backup.
lastbackupsize=$(du -h "${lastbackup}" | awk '{print $1}') lastbackupsize=$(du -h "${lastbackup}" | awk '{print $1}')
fi fi

4
lgsm/functions/info_glibc.sh

@ -2,10 +2,10 @@
# LGSM info_glibc.sh function # LGSM info_glibc.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: stores details on servers Glibc requirements. # Description: stores details on servers Glibc requirements.
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
if [ "${gamename}" == "Blade Symphony" ]; then if [ "${gamename}" == "Blade Symphony" ]; then
glibcrequired="2.15" glibcrequired="2.15"
glibcfix="yes" glibcfix="yes"

8
lgsm/functions/info_parms.sh

@ -2,9 +2,9 @@
# LGSM info_parms.sh function # LGSM info_parms.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516" # Description: Gets specific details from server parameters.
# Description: Gets specific details server parameters. local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
## Examples of filtering to get info from config files ## Examples of filtering to get info from config files
# sed 's/foo//g' - remove foo # sed 's/foo//g' - remove foo
@ -12,8 +12,8 @@ lgsm_version="210516"
# tr -d '=\"; ' remove selected charectors =\"; # tr -d '=\"; ' remove selected charectors =\";
# grep -v "foo" filter out lines that contain foo # grep -v "foo" filter out lines that contain foo
unavailable="\e[0;31mUNAVAILABLE\e[0m" unavailable="${red}UNAVAILABLE${default}"
zero="\e[0;31m0\e[0m" zero="${red}0${default}"
fn_info_config_idtech3(){ fn_info_config_idtech3(){

8
lgsm/functions/install_complete.sh

@ -2,9 +2,10 @@
# LGSM install_complete.sh function # LGSM install_complete.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
local modulename="Install" local commandname="INSTALL"
local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
if [ "${gamename}" == "Don't Starve Together" ]; then if [ "${gamename}" == "Don't Starve Together" ]; then
echo "" echo ""
@ -14,8 +15,9 @@ if [ "${gamename}" == "Don't Starve Together" ]; then
fi fi
echo "=================================" echo "================================="
echo "Install Complete!" echo "Install Complete!"
fn_scriptlog "Install Complete!" fn_script_log_info "Install Complete!"
echo "" echo ""
echo "To start server type:" echo "To start server type:"
echo "./${selfname} start" echo "./${selfname} start"
echo "" echo ""
core_exit.sh

26
lgsm/functions/install_config.sh

@ -2,12 +2,14 @@
# LGSM install_config.sh function # LGSM install_config.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
local modulename="Install" local commandname="INSTALL"
local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_defaultconfig(){ fn_defaultconfig(){
echo "creating ${servercfg} config file." echo "creating ${servercfg} config file."
fn_script_log_info "creating ${servercfg} config file."
cp -v "${servercfgdefault}" "${servercfgfullpath}" cp -v "${servercfgdefault}" "${servercfgfullpath}"
sleep 1 sleep 1
} }
@ -26,9 +28,11 @@ fn_userinputconfig(){
rconpass="rconpassword" rconpass="rconpassword"
fi fi
echo "changing hostname." echo "changing hostname."
fn_script_log_info "changing hostname."
sed -i "s/\"<hostname>\"/\"${servername}\"/g" "${servercfgfullpath}" sed -i "s/\"<hostname>\"/\"${servername}\"/g" "${servercfgfullpath}"
sleep 1 sleep 1
echo "changing rconpassword." echo "changing rconpassword."
fn_script_log_info "changing rconpassword."
sed -i "s/\"<rconpassword>\"/\"${rconpass}\"/g" "${servercfgfullpath}" sed -i "s/\"<rconpassword>\"/\"${rconpass}\"/g" "${servercfgfullpath}"
sleep 1 sleep 1
} }
@ -36,6 +40,7 @@ fn_userinputconfig(){
fn_arma3config(){ fn_arma3config(){
fn_defaultconfig fn_defaultconfig
echo "creating ${networkcfg} config file." echo "creating ${networkcfg} config file."
fn_script_log_info "creating ${networkcfg} config file."
cp -v "${networkcfgdefault}" "${networkcfgfullpath}" cp -v "${networkcfgdefault}" "${networkcfgfullpath}"
sleep 1 sleep 1
echo "" echo ""
@ -46,18 +51,22 @@ fn_goldsourceconfig(){
# server.cfg redirects to ${servercfg} for added security # server.cfg redirects to ${servercfg} for added security
echo "creating server.cfg." echo "creating server.cfg."
fn_script_log_info "creating server.cfg."
touch "server.cfg" touch "server.cfg"
sleep 1 sleep 1
echo "creating redirect." echo "creating redirect."
fn_script_log_info "creating redirect."
echo "server.cfg > ${servercfg}." echo "server.cfg > ${servercfg}."
echo "exec ${servercfg}" > "server.cfg" echo "exec ${servercfg}" > "server.cfg"
sleep 1 sleep 1
# creating other files required # creating other files required
echo "creating listip.cfg." echo "creating listip.cfg."
fn_script_log_info "creating listip.cfg."
touch "${systemdir}/listip.cfg" touch "${systemdir}/listip.cfg"
sleep 1 sleep 1
echo "creating banned.cfg." echo "creating banned.cfg."
fn_script_log_info "creating banned.cfg."
touch "${systemdir}/banned.cfg" touch "${systemdir}/banned.cfg"
sleep 1 sleep 1
@ -70,6 +79,8 @@ fn_serious3config(){
echo "" echo ""
echo "To edit ${gamename} server config use SS3 Server GUI 3 tool" echo "To edit ${gamename} server config use SS3 Server GUI 3 tool"
echo "http://mrag.nl/sgui3/" echo "http://mrag.nl/sgui3/"
fn_script_log_info "To edit ${gamename} server config use SS3 Server GUI 3 tool"
fn_script_log_info "http://mrag.nl/sgui3/"
sleep 1 sleep 1
echo "" echo ""
} }
@ -79,9 +90,11 @@ fn_sourceconfig(){
# server.cfg redirects to ${servercfg} for added security # server.cfg redirects to ${servercfg} for added security
echo "creating server.cfg." echo "creating server.cfg."
fn_script_log_info "creating server.cfg."
touch "server.cfg" touch "server.cfg"
sleep 1 sleep 1
echo "creating redirect." echo "creating redirect."
fn_script_log_info "creating redirect."
echo "server.cfg > ${servercfg}." echo "server.cfg > ${servercfg}."
echo "exec ${servercfg}" > "server.cfg" echo "exec ${servercfg}" > "server.cfg"
sleep 1 sleep 1
@ -94,9 +107,11 @@ fn_teeworldsconfig(){
fn_defaultconfig fn_defaultconfig
echo "adding logfile location to config." echo "adding logfile location to config."
fn_script_log_info "adding logfile location to config."
sed -i "s@\"<logfile>\"@\"${gamelog}\"@g" "${servercfgfullpath}" sed -i "s@\"<logfile>\"@\"${gamelog}\"@g" "${servercfgfullpath}"
sleep 1 sleep 1
echo "removing password holder." echo "removing password holder."
fn_script_log_info "removing password holder."
sed -i "s/<password>//" "${servercfgfullpath}" sed -i "s/<password>//" "${servercfgfullpath}"
sleep 1 sleep 1
@ -105,6 +120,8 @@ fn_teeworldsconfig(){
} }
fn_ut99config(){ fn_ut99config(){
echo "creating ${servercfg} config file."
fn_script_log_info "creating ${servercfg} config file."
echo "${servercfgdefault} > ${servercfgfullpath}" echo "${servercfgdefault} > ${servercfgfullpath}"
tr -d '\r' < "${servercfgdefault}" > "${servercfgfullpath}" tr -d '\r' < "${servercfgdefault}" > "${servercfgfullpath}"
sleep 1 sleep 1
@ -113,9 +130,11 @@ fn_ut99config(){
echo "=================================" echo "================================="
sleep 1 sleep 1
echo "enabling WebAdmin." echo "enabling WebAdmin."
fn_script_log_info "enabling WebAdmin."
sed -i 's/bEnabled=False/bEnabled=True/g' "${servercfgfullpath}" sed -i 's/bEnabled=False/bEnabled=True/g' "${servercfgfullpath}"
sleep 1 sleep 1
echo "setting WebAdmin port to 8076." echo "setting WebAdmin port to 8076."
fn_script_log_info "setting WebAdmin port to 8076."
sed -i '467i\ListenPort=8076' "${servercfgfullpath}" sed -i '467i\ListenPort=8076' "${servercfgfullpath}"
sleep 1 sleep 1
echo "" echo ""
@ -128,14 +147,17 @@ fn_unreal2config(){
echo "=================================" echo "================================="
sleep 1 sleep 1
echo "setting WebAdmin username and password." echo "setting WebAdmin username and password."
fn_script_log_info "setting WebAdmin username and password."
sed -i 's/AdminName=/AdminName=admin/g' "${servercfgfullpath}" sed -i 's/AdminName=/AdminName=admin/g' "${servercfgfullpath}"
sed -i 's/AdminPassword=/AdminPassword=admin/g' "${servercfgfullpath}" sed -i 's/AdminPassword=/AdminPassword=admin/g' "${servercfgfullpath}"
sleep 1 sleep 1
echo "enabling WebAdmin." echo "enabling WebAdmin."
fn_script_log_info "enabling WebAdmin."
sed -i 's/bEnabled=False/bEnabled=True/g' "${servercfgfullpath}" sed -i 's/bEnabled=False/bEnabled=True/g' "${servercfgfullpath}"
if [ "${gamename}" == "Unreal Tournament 2004" ]; then if [ "${gamename}" == "Unreal Tournament 2004" ]; then
sleep 1 sleep 1
echo "setting WebAdmin port to 8075." echo "setting WebAdmin port to 8075."
fn_script_log_info "setting WebAdmin port to 8075."
sed -i 's/ListenPort=80/ListenPort=8075/g' "${servercfgfullpath}" sed -i 's/ListenPort=80/ListenPort=8075/g' "${servercfgfullpath}"
fi fi
sleep 1 sleep 1

16
lgsm/functions/install_gslt.sh

@ -2,11 +2,11 @@
# LGSM install_gslt.sh function # LGSM install_gslt.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Configures GSLT. # Description: Configures GSLT.
local modulename="Install" local commandname="INSTALL"
local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
echo "" echo ""
echo "Game Server Login Token" echo "Game Server Login Token"
@ -14,16 +14,16 @@ echo "================================="
sleep 1 sleep 1
if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then
echo "GSLT is required to run a public ${gamename} server" echo "GSLT is required to run a public ${gamename} server"
fn_scriptlog "GSLT is required to run a public ${gamename} server" fn_script_log_info "GSLT is required to run a public ${gamename} server"
else else
echo "GSLT is an optional feature for ${gamename} server" echo "GSLT is an optional feature for ${gamename} server"
fn_scriptlog "GSLT is an optional feature for ${gamename} server" fn_script_log_info "GSLT is an optional feature for ${gamename} server"
fi fi
echo "Get more info and a token here:" echo "Get more info and a token here:"
echo "https://gameservermanagers.com/gslt" echo "https://gameservermanagers.com/gslt"
fn_scriptlog "Get more info and a token here:" fn_script_log_info "Get more info and a token here:"
fn_scriptlog "https://gameservermanagers.com/gslt" fn_script_log_info "https://gameservermanagers.com/gslt"
echo "" echo ""
if [ -z "${autoinstall}" ]; then if [ -z "${autoinstall}" ]; then
echo "Enter token below (Can be blank)." echo "Enter token below (Can be blank)."
@ -33,5 +33,5 @@ if [ -z "${autoinstall}" ]; then
fi fi
sleep 1 sleep 1
echo "The GSLT can be changed by editing ${selfname}." echo "The GSLT can be changed by editing ${selfname}."
fn_scriptlog "The GSLT can be changed by editing ${selfname}." fn_script_log_info "The GSLT can be changed by editing ${selfname}."
echo "" echo ""

5
lgsm/functions/install_gsquery.sh

@ -2,7 +2,10 @@
# LGSM install_gsquery.sh function # LGSM install_gsquery.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
local commandname="INSTALL"
local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_dlgsquery(){ fn_dlgsquery(){
cd "${functionsdir}" cd "${functionsdir}"

5
lgsm/functions/install_header.sh

@ -2,9 +2,10 @@
# LGSM install_header.sh function # LGSM install_header.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
local modulename="Install" local commandname="INSTALL"
local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
clear clear
echo "=================================" echo "================================="

7
lgsm/functions/install_logs.sh

@ -2,9 +2,10 @@
# LGSM install_logs.sh function # LGSM install_logs.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
local modulename="Install" local commandname="INSTALL"
local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
if [ "${checklogs}" != "1" ]; then if [ "${checklogs}" != "1" ]; then
echo "" echo ""
@ -40,4 +41,4 @@ if [ -d "${rootdir}/Steam/logs" ]; then
fi fi
fi fi
sleep 1 sleep 1
fn_scriptlog "logs installed" fn_script_log_info "Logs installed"

5
lgsm/functions/install_retry.sh

@ -2,9 +2,10 @@
# LGSM install_retry.sh function # LGSM install_retry.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
local modulename="Install" local commandname="INSTALL"
local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
while true; do while true; do
read -e -i "y" -p "Retry install? [Y/n]" yn read -e -i "y" -p "Retry install? [Y/n]" yn

7
lgsm/functions/install_server_dir.sh

@ -1,10 +1,11 @@
#!/bin/bash #!/bin/bash
# LGSM install_serverdir.sh function # LGSM install_server_dir.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
local modulename="Install" local commandname="INSTALL"
local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
echo "" echo ""
echo "Server Directory" echo "Server Directory"

20
lgsm/functions/install_server_files.sh

@ -2,9 +2,10 @@
# LGSM install_server_files.sh function # LGSM install_server_files.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="270516"
local modulename="Install" local commandname="INSTALL"
local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_install_server_files(){ fn_install_server_files(){
if [ "${gamename}" == "Unreal Tournament 99" ]; then if [ "${gamename}" == "Unreal Tournament 99" ]; then
@ -32,7 +33,7 @@ fn_install_server_files_steamcmd(){
if [ "${counter}" -ge "2" ]; then if [ "${counter}" -ge "2" ]; then
fn_print_warning_nl "SteamCMD did not complete the download, retrying: Attempt ${counter}" fn_print_warning_nl "SteamCMD did not complete the download, retrying: Attempt ${counter}"
fn_scriptlog "SteamCMD did not complete the download, retrying: Attempt ${counter}" fn_script_log "SteamCMD did not complete the download, retrying: Attempt ${counter}"
fi fi
if [ "${counter}" -ge "7" ]; then if [ "${counter}" -ge "7" ]; then
@ -68,7 +69,7 @@ fn_install_server_files_steamcmd(){
fi fi
elif [ "${counter}" -ge "11" ]; then elif [ "${counter}" -ge "11" ]; then
fn_print_failure_nl "SteamCMD did not complete the download, too many retrys" fn_print_failure_nl "SteamCMD did not complete the download, too many retrys"
fn_scriptlog "SteamCMD did not complete the download, too many retrys" fn_script_log "SteamCMD did not complete the download, too many retrys"
break break
fi fi
done done
@ -90,14 +91,17 @@ echo ""
echo "Installing ${gamename} Server" echo "Installing ${gamename} Server"
echo "=================================" echo "================================="
sleep 1 sleep 1
if [ -n "${appid}" ]; then
fn_install_server_files_steamcmd
fi
if [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then if [ "${gamename}" == "Teamspeak 3" ]; then
update_ts3.sh
elif [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then
fn_install_server_files fn_install_server_files
fi fi
if [ -n "${appid}" ]; then
fn_install_server_files_steamcmd
fi
if [ -z "${autoinstall}" ]; then if [ -z "${autoinstall}" ]; then
echo "" echo ""
echo "=================================" echo "================================="

5
lgsm/functions/install_steamcmd.sh

@ -2,11 +2,10 @@
# LGSM install_steamcmd.sh function # LGSM install_steamcmd.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Downloads SteamCMD on install. # Description: Downloads SteamCMD on install.
local modulename="Install" local commandname="INSTALL"
local commandaction="Install"
echo "" echo ""
echo "Installing SteamCMD" echo "Installing SteamCMD"

81
lgsm/functions/install_ts3.sh

@ -1,81 +0,0 @@
#!/bin/bash
# LGSM install_ts3.sh function
# Author: Daniel Gibbs
# Website: https://gameservermanagers.com
lgsm_version="210516"
local modulename="Install"
info_distro.sh
# Gets the teamspeak server architecture
if [ "${arch}" == "x86_64" ]; then
ts3arch="amd64"
elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then
ts3arch="x86"
else
fn_print_failure "${arch} is an unsupported architecture"
exit 1
fi
# Grabs all version numbers but not in correct order
wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '<a href=\".*\/\">.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp
# Sort version numbers
cat .ts3_version_numbers_unsorted.tmp | sort -r --version-sort -o .ts3_version_numbers_sorted.tmp
# Finds directory with most recent server version.
while read ts3_version_number; do
wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
if [ $? -eq 0 ]; then
availablebuild="${ts3_version_number}"
# Break while-loop, if the latest release could be found
break
fi
done < .ts3_version_numbers_sorted.tmp
# Tidy up
rm -f ".ts3_version_numbers_unsorted.tmp"
rm -f ".ts3_version_numbers_sorted.tmp"
# Checks availablebuild info is available
if [ -z "${availablebuild}" ]; then
fn_print_fail "Checking for update: teamspeak.com"
sleep 1
fn_print_fail "Checking for update: teamspeak.com: Not returning version info"
sleep 2
exit 1
fi
echo ""
echo "Installing ${gamename} Server"
echo "================================="
cd "${rootdir}"
echo -e "downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2 2>&1 | grep -F HTTP | cut -c45-| uniq
sleep 1
echo -e "extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
tar -xf "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" 2> ".${servicename}-tar-error.tmp"
local status=$?
if [ ${status} -eq 0 ]; then
echo "OK"
else
echo "FAIL - Exit status ${status}"
sleep 1
cat ".${servicename}-tar-error.tmp"
rm ".${servicename}-tar-error.tmp"
exit $?
fi
echo -e "copying to ${filesdir}...\c"
cp -R "${rootdir}/teamspeak3-server_linux_${ts3arch}/"* "${filesdir}" 2> ".${servicename}-cp-error.tmp"
local status=$?
if [ ${status} -eq 0 ]; then
echo "OK"
else
echo "FAIL - Exit status ${status}"
sleep 1
cat ".${servicename}-cp-error.tmp"
rm ".${servicename}-cp-error.tmp"
exit $?
fi
rm -f "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
rm -rf "${rootdir}/teamspeak3-server_linux_${ts3arch}"

7
lgsm/functions/install_ts3db.sh

@ -1,11 +1,12 @@
#!/bin/bash #!/bin/bash
# LGSM fn_install_ts3_mariadb function # LGSM install_ts3db.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Contributor: PhilPhonic # Contributor: PhilPhonic
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
local modulename="Install" local commandname="INSTALL"
local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_install_ts3db_mariadb(){ fn_install_ts3db_mariadb(){
echo "" echo ""

7
lgsm/functions/install_ut2k4_key.sh

@ -2,9 +2,10 @@
# LGSM install_ut2k4_key.sh function # LGSM install_ut2k4_key.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
local modulename="Install" local commandname="INSTALL"
local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
echo "" echo ""
echo "Enter ${gamename} CD Key" echo "Enter ${gamename} CD Key"
@ -20,7 +21,7 @@ if [ -z "${autoinstall}" ]; then
read CODE read CODE
echo ""\""CDKey"\""="\""${CODE}"\""" > "${systemdir}/cdkey" echo ""\""CDKey"\""="\""${CODE}"\""" > "${systemdir}/cdkey"
if [ -f "${systemdir}/cdkey" ]; then if [ -f "${systemdir}/cdkey" ]; then
fn_scriptlog "UT2K4 Server CD Key created" fn_script_log_info "UT2K4 Server CD Key created"
fi fi
else else
echo "You can add your key using the following command" echo "You can add your key using the following command"

12
lgsm/functions/logs.sh

@ -3,11 +3,10 @@
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Contributor: UltimateByte # Contributor: UltimateByte
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Acts as a log rotater, removing old logs. # Description: Acts as a log rotater, removing old logs.
local modulename="Log Manager" local commandname="LOGS"
local commandaction="Log-Manager"
# Check if logfile variable and file exist, create logfile if it doesn't exist # Check if logfile variable and file exist, create logfile if it doesn't exist
if [ -n "${consolelog}" ]; then if [ -n "${consolelog}" ]; then
@ -20,7 +19,7 @@ fi
if [ "${function_selfname}" == "command_start.sh" ] && [ -n "${gamelogfile}" ]; then if [ "${function_selfname}" == "command_start.sh" ] && [ -n "${gamelogfile}" ]; then
if [ -n "$(find "${systemdir}" -name "gamelog*.log")" ]; then if [ -n "$(find "${systemdir}" -name "gamelog*.log")" ]; then
fn_print_info "Moving game logs to ${gamelogdir}" fn_print_info "Moving game logs to ${gamelogdir}"
fn_scriptlog "Moving game logs to ${gamelogdir}" fn_script_log_info "Moving game logs to ${gamelogdir}"
echo -en "\n" echo -en "\n"
sleep 1 sleep 1
mv "${systemdir}"/gamelog*.log "${gamelogdir}" mv "${systemdir}"/gamelog*.log "${gamelogdir}"
@ -39,9 +38,8 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th
scriptcount="0" ; consolecount="0" ; gamecount="0" ; srcdscount="0" ; smcount="0" ; ulxcount="0" ; darkrpcount="0" ; legacycount="0" scriptcount="0" ; consolecount="0" ; gamecount="0" ; srcdscount="0" ; smcount="0" ; ulxcount="0" ; darkrpcount="0" ; legacycount="0"
sleep 1 sleep 1
fn_print_ok_nl "Starting" fn_print_ok_nl "Starting"
fn_scriptlog "Starting"
fn_print_info_nl "Removing logs older than "${logdays}" days" fn_print_info_nl "Removing logs older than "${logdays}" days"
fn_scriptlog "Removing logs older than "${logdays}" days" fn_script_log_info "Removing logs older than "${logdays}" days"
# Logging logfiles to be removed according to "${logdays}", counting and removing them # Logging logfiles to be removed according to "${logdays}", counting and removing them
# Script logfiles # Script logfiles
find "${scriptlogdir}"/ -type f -mtime +"${logdays}"| tee >> "${scriptlog}" find "${scriptlogdir}"/ -type f -mtime +"${logdays}"| tee >> "${scriptlog}"
@ -98,5 +96,5 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th
count=$((${scriptcount} + ${consolecount} + ${gamecount} + ${srcdscount} + ${smcount} + ${ulxcount} + ${darkrpcount} + ${legacycount})) count=$((${scriptcount} + ${consolecount} + ${gamecount} + ${srcdscount} + ${smcount} + ${ulxcount} + ${darkrpcount} + ${legacycount}))
# Job done # Job done
fn_print_ok_nl "Removed ${count} log files" fn_print_ok_nl "Removed ${count} log files"
fn_scriptlog "Removed ${count} log files" fn_script_log "Removed ${count} log files"
fi fi

27
lgsm/functions/monitor_gsquery.sh

@ -2,12 +2,12 @@
# LGSM monitor_gsquery.sh function # LGSM monitor_gsquery.sh function
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: uses gsquery.py to query the server port. # Description: uses gsquery.py to query the server port.
# Detects if the server has frozen with the proccess still running. # Detects if the server has frozen with the proccess still running.
local modulename="Monitor" local commandname="MONITOR"
local commandaction="Monitor"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
# Forces legecy servers to use gsquery # Forces legecy servers to use gsquery
if [ -z "${gsquery}" ]; then if [ -z "${gsquery}" ]; then
@ -26,7 +26,7 @@ if [ "${gsquery}" == "yes" ]; then
if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then
port=$((port + 1)) port=$((port + 1))
elif [ "${engine}" == "realvirtuality" ]; then elif [ "${engine}" == "realvirtuality" ]; then
port=$((port + 1)) port=$((port + 1))
elif [ "${engine}" == "spark" ]; then elif [ "${engine}" == "spark" ]; then
port=$((port + 1)) port=$((port + 1))
fi fi
@ -36,7 +36,7 @@ if [ "${gsquery}" == "yes" ]; then
fi fi
fn_print_info "Querying port: gsquery.py enabled" fn_print_info "Querying port: gsquery.py enabled"
fn_scriptlog "Querying port: gsquery.py enabled" fn_script_log_info "Querying port: gsquery.py enabled"
sleep 1 sleep 1
# Will query up to 4 times every 15 seconds. # Will query up to 4 times every 15 seconds.
@ -46,7 +46,7 @@ if [ "${gsquery}" == "yes" ]; then
for queryattempt in {1..5}; do for queryattempt in {1..5}; do
fn_print_dots "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : " fn_print_dots "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : "
fn_print_querying_eol fn_print_querying_eol
fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : QUERYING" fn_script_log_info "Querying port: ${ip}:${port} : ${queryattempt} : QUERYING"
gsquerycmd=$("${functionsdir}"/gsquery.py -a "${ip}" -p "${port}" -e "${engine}" 2>&1) gsquerycmd=$("${functionsdir}"/gsquery.py -a "${ip}" -p "${port}" -e "${engine}" 2>&1)
exitcode=$? exitcode=$?
@ -56,30 +56,30 @@ if [ "${gsquery}" == "yes" ]; then
# Server OK # Server OK
fn_print_ok "Querying port: ${ip}:${port} : ${queryattempt} : " fn_print_ok "Querying port: ${ip}:${port} : ${queryattempt} : "
fn_print_ok_eol_nl fn_print_ok_eol_nl
fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : OK" fn_script_log_pass "Querying port: ${ip}:${port} : ${queryattempt} : OK"
sleep 1 exitcode=0
exit break
else else
# Server failed query # Server failed query
fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : ${gsquerycmd}" fn_script_log_info "Querying port: ${ip}:${port} : ${queryattempt} : ${gsquerycmd}"
if [ "${queryattempt}" == "5" ]; then if [ "${queryattempt}" == "5" ]; then
# Server failed query 4 times confirmed failure # Server failed query 4 times confirmed failure
fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : " fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : "
fn_print_fail_eol_nl fn_print_fail_eol_nl
fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : FAIL" fn_script_log_error "Querying port: ${ip}:${port} : ${queryattempt} : FAIL"
sleep 1 sleep 1
# Send alert if enabled # Send alert if enabled
alert="restartquery" alert="restartquery"
alert.sh alert.sh
fn_restart command_restart.sh
break break
fi fi
# Seconds counter # Seconds counter
for seconds in {1..15}; do for seconds in {1..15}; do
fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : \e[0;31m${gsquerycmd}\e[0m" fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : ${red}${gsquerycmd}${default}"
totalseconds=$((totalseconds + 1)) totalseconds=$((totalseconds + 1))
sleep 1 sleep 1
if [ "${seconds}" == "15" ]; then if [ "${seconds}" == "15" ]; then
@ -89,3 +89,4 @@ if [ "${gsquery}" == "yes" ]; then
fi fi
done done
fi fi
core_exit.sh

342
lgsm/functions/update_check.sh

@ -1,342 +0,0 @@
#!/bin/bash
# LGSM update_check.sh function
# Author: Daniel Gibbs
# Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Checks if a server update is available.
local modulename="Update"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
### SteamCMD Update Checker ###
fn_appmanifestinfo(){
appmanifestfile=$(find "${filesdir}" -type f -name "appmanifest_${appid}.acf")
appmanifestfilewc=$(find "${filesdir}" -type f -name "appmanifest_${appid}.acf"|wc -l)
}
fn_appmanifestcheck(){
fn_appmanifestinfo
# Multiple or no matching appmanifest files may sometimes be available.
# This is an error is corrected below if required.
if [ "${appmanifestfilewc}" -ge "2" ]; then
sleep 1
fn_print_warn "Multiple appmanifest_${appid}.acf files found"
fn_scriptlog "Warning! Multiple appmanifest_${appid}.acf files found"
sleep 2
fn_print_dots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files"
sleep 1
for appfile in ${appmanifestfile}; do
rm "${appfile}"
done
appmanifestfilewc1="${appmanifestfilewc}"
fn_appmanifestinfo
if [ "${appmanifestfilewc}" -ge "2" ]; then
fn_print_fail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files"
fn_scriptlog "Failure! Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files"
sleep 1
echo ""
echo " Check user permissions"
for appfile in ${appmanifestfile}; do
echo " ${appfile}"
done
exit 1
else
sleep 1
fn_print_ok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files"
fn_scriptlog "Success! Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files"
sleep 1
fn_print_info_nl "Forcing update to correct issue"
fn_scriptlog "Forcing update to correct issue"
sleep 1
update_dl.sh
update_check.sh
fi
elif [ "${appmanifestfilewc}" -eq "0" ]; then
if [ "${forceupdate}" == "1" ]; then
fn_print_fail "Still no appmanifest_${appid}.acf found: Unable to update"
fn_scriptlog "Warning! Still no appmanifest_${appid}.acf found: Unable to update"
exit 1
fi
forceupdate=1
fn_print_warn "No appmanifest_${appid}.acf found"
fn_scriptlog "Warning! No appmanifest_${appid}.acf found"
sleep 2
fn_print_info_nl "Forcing update to correct issue"
fn_scriptlog "Forcing update to correct issue"
sleep 1
update_dl.sh
update_check.sh
fi
}
fn_logupdaterequest(){
# Checks for server update requests from server logs.
fn_print_dots "Checking for update: Server logs"
fn_scriptlog "Checking for update: Server logs"
sleep 1
requestrestart=$(grep -Ec "MasterRequestRestart" "${consolelog}")
if [ "${requestrestart}" -ge "1" ]; then
fn_print_ok_nl "Checking for update: Server logs: Update requested"
sleep 1
echo ""
echo -ne "Applying update.\r"
sleep 1
echo -ne "Applying update..\r"
sleep 1
echo -ne "Applying update...\r"
sleep 1
echo -ne "\n"
unset updateonstart
check_status.sh
if [ "${status}" != "0" ]; then
command_stop.sh
update_dl.sh
command_start.sh
else
update_dl.sh
fi
alert="update"
alert.sh
else
fn_print_ok "Checking for update: Server logs: No update requested"
sleep 1
fi
}
fn_steamcmdcheck(){
fn_appmanifestcheck
# Checks for server update from SteamCMD
fn_print_dots "Checking for update: SteamCMD"
fn_scriptlog "Checking for update: SteamCMD"
sleep 1
# Gets currentbuild
currentbuild=$(grep buildid "${appmanifestfile}" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3)
# Removes appinfo.vdf as a fix for not always getting up to date version info from SteamCMD
# Gets availablebuild info
cd "${rootdir}/steamcmd"
if [ -f "${HOME}/Steam/appcache/appinfo.vdf" ]; then
rm -f "${HOME}/Steam/appcache/appinfo.vdf"
fi
# set branch for updateinfo
IFS=' ' read -a branchsplits <<< "${branch}"
if [ "${#branchsplits[@]}" -gt 1 ]; then
branchname="${branchsplits[1]}"
else
branchname="public"
fi
availablebuild=$(./steamcmd.sh +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +app_info_print "${appid}" +quit | grep -EA 1000 "^\s+\"branches\"$" | grep -EA 5 "^\s+\"${branchname}\"$" | grep -m 1 -EB 10 "^\s+}$" | grep -E "^\s+\"buildid\"\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3)
if [ -z "${availablebuild}" ]; then
fn_print_fail "Checking for update: SteamCMD"
fn_scriptlog "Failure! Checking for update: SteamCMD"
sleep 1
fn_print_fail_nl "Checking for update: SteamCMD: Not returning version info"
fn_scriptlog "Failure! Checking for update: SteamCMD: Not returning version info"
exit 1
else
fn_print_ok "Checking for update: SteamCMD"
fn_scriptlog "Success! Checking for update: SteamCMD"
sleep 1
fi
if [ "${currentbuild}" != "${availablebuild}" ]; then
echo -e "\n"
echo -e "Update available:"
sleep 1
echo -e " Current build: \e[0;31m${currentbuild}\e[0;39m"
echo -e " Available build: \e[0;32m${availablebuild}\e[0;39m"
echo -e ""
echo -e " https://steamdb.info/app/${appid}/"
sleep 1
echo ""
echo -en "Applying update.\r"
sleep 1
echo -en "Applying update..\r"
sleep 1
echo -en "Applying update...\r"
sleep 1
echo -en "\n"
fn_scriptlog "Update available"
fn_scriptlog "Current build: ${currentbuild}"
fn_scriptlog "Available build: ${availablebuild}"
fn_scriptlog "${currentbuild} > ${availablebuild}"
unset updateonstart
check_status.sh
if [ "${status}" != "0" ]; then
command_stop.sh
update_dl.sh
command_start.sh
else
update_dl.sh
fi
alert="update"
alert.sh
else
echo -e "\n"
echo -e "No update available:"
echo -e " Current version: \e[0;32m${currentbuild}\e[0;39m"
echo -e " Available version: \e[0;32m${availablebuild}\e[0;39m"
echo -e " https://steamdb.info/app/${appid}/"
echo -e ""
fn_print_ok_nl "No update available"
fn_scriptlog "Current build: ${currentbuild}"
fn_scriptlog "Available build: ${availablebuild}"
fi
}
### END SteamCMD Update Checker ###
fn_teamspeak3_check(){
# Checks for server update from teamspeak.com using a mirror dl.4players.de
fn_print_dots "Checking for update: teamspeak.com"
fn_scriptlog "Checking for update: teamspeak.com"
sleep 1
# Gets currentbuild info
# Checks currentbuild info is available, if fails a server restart will be forced to generate logs
if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then
fn_print_fail "Checking for update: teamspeak.com"
sleep 1
fn_print_fail_nl "Checking for update: teamspeak.com: No logs with server version found"
fn_scriptlog "Failure! Checking for update: teamspeak.com: No logs with server version found"
sleep 2
fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart"
fn_scriptlog "Checking for update: teamspeak.com: Forcing server restart"
sleep 2
command_stop.sh
command_start.sh
sleep 2
# If still failing will exit
if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then
fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found"
fn_scriptlog "Failure! Checking for update: teamspeak.com: Still No logs with server version found"
exit 1
fi
fi
currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}')
# Gets the teamspeak server architecture
info_distro.sh
if [ "${arch}" == "x86_64" ]; then
ts3arch="amd64"
elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then
ts3arch="x86"
else
echo ""
fn_print_failure "${arch} is an unsupported architecture"
exit 1
fi
# Gets availablebuild info
# Grabs all version numbers but not in correct order
wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '<a href=\".*\/\">.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp
# Sort version numbers
cat .ts3_version_numbers_unsorted.tmp | sort -r --version-sort -o .ts3_version_numbers_sorted.tmp
# Finds directory with most recent server version.
while read ts3_version_number; do
wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
if [ $? -eq 0 ]; then
availablebuild="${ts3_version_number}"
# Break while-loop, if the latest release could be found
break
fi
done < .ts3_version_numbers_sorted.tmp
# Tidy up
rm -f ".ts3_version_numbers_unsorted.tmp"
rm -f ".ts3_version_numbers_sorted.tmp"
# Checks availablebuild info is available
if [ -z "${availablebuild}" ]; then
fn_print_fail "Checking for update: teamspeak.com"
fn_scriptlog "Checking for update: teamspeak.com"
sleep 1
fn_print_fail "Checking for update: teamspeak.com: Not returning version info"
fn_scriptlog "Failure! Checking for update: teamspeak.com: Not returning version info"
sleep 2
exit 1
else
fn_print_ok "Checking for update: teamspeak.com"
fn_scriptlog "Success! Checking for update: teamspeak.com"
sleep 1
fi
# Removes dots so if can compare version numbers
currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]')
availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]')
if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then
echo -e "\n"
echo -e "Update available:"
sleep 1
echo -e " Current build: \e[0;31m${currentbuild} ${architecture}\e[0;39m"
echo -e " Available build: \e[0;32m${availablebuild} ${architecture}\e[0;39m"
echo -e ""
sleep 1
echo ""
echo -en "Applying update.\r"
sleep 1
echo -en "Applying update..\r"
sleep 1
echo -en "Applying update...\r"
sleep 1
echo -en "\n"
fn_scriptlog "Update available"
fn_scriptlog "Current build: ${currentbuild}"
fn_scriptlog "Available build: ${availablebuild}"
fn_scriptlog "${currentbuild} > ${availablebuild}"
unset updateonstart
check_status.sh
if [ "${status}" == "0" ]; then
update_dl.sh
command_start.sh
sleep 5
command_stop.sh
else
command_stop.sh
update_dl.sh
command_start.sh
fi
alert="update"
alert.sh
else
echo -e "\n"
echo -e "No update available:"
echo -e " Current version: \e[0;32m${currentbuild}\e[0;39m"
echo -e " Available version: \e[0;32m${availablebuild}\e[0;39m"
echo -e ""
fn_print_ok_nl "No update available"
fn_scriptlog "Current build: ${currentbuild}"
fn_scriptlog "Available build: ${availablebuild}"
fi
}
check.sh
fn_print_dots "Checking for update"
if [ "${gamename}" == "Teamspeak 3" ]; then
fn_teamspeak3_check
elif [ "${engine}" == "goldsource" ]||[ "${forceupdate}" == "1" ]; then
# Goldsource servers bypass checks as fn_steamcmdcheck does not work for appid 90 servers.
# forceupdate bypasses checks
if [ "${status}" != "0" ]; then
command_stop.sh
update_dl.sh
command_start.sh
else
update_dl.sh
fi
else
fn_logupdaterequest
fn_steamcmdcheck
fi

83
lgsm/functions/update_dl.sh

@ -1,83 +0,0 @@
#!/bin/bash
# LGSM update_dl.sh function
# Author: Daniel Gibbs
# Website: https://gameservermanagers.com
lgsm_version="210516"
# Description: Runs a server update.
local modulename="Update"
function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_steamcmd_dl(){
cd "${rootdir}"
cd "steamcmd"
# Detects if unbuffer command is available.
if [ $(command -v stdbuf) ]; then
unbuffer="stdbuf -i0 -o0 -e0"
fi
if [ "${engine}" == "goldsource" ]; then
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit | tee -a "${scriptlog}"
else
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit | tee -a "${scriptlog}"
fi
fix.sh
}
fn_teamspeak3_dl(){
cd "${rootdir}"
echo -e "downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
fn_scriptlog "Downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2 2>&1 | grep -F HTTP | cut -c45-| uniq
sleep 1
echo -e "extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
fn_scriptlog "Extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
tar -xf "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" 2> "${scriptlogdir}/.${servicename}-tar-error.tmp"
local status=$?
if [ ${status} -eq 0 ]; then
echo "OK"
else
echo "FAIL - Exit status ${status}"
fn_scriptlog "Failed to extract - Exit status ${status}"
sleep 1
cat "${scriptlogdir}/.${servicename}-tar-error.tmp"
cat "${scriptlogdir}/.${servicename}-tar-error.tmp" >> "${scriptlog}"
rm "${scriptlogdir}/.${servicename}-tar-error.tmp"
fn_scriptlog "Failure! Unable to update"
exit ${status}
fi
echo -e "copying to ${filesdir}...\c"
fn_scriptlog "Copying to ${filesdir}"
cp -R "${rootdir}/teamspeak3-server_linux_${ts3arch}/"* "${filesdir}" 2> "${scriptlogdir}/.${servicename}-cp-error.tmp"
local status=$?
if [ ${status} -eq 0 ]; then
echo "OK"
else
echo "FAIL - Exit status ${status}"
fn_scriptlog "Failed to copy - Exit status ${status}"
sleep 1
cat "${scriptlogdir}/.${servicename}-cp-error.tmp"
cat "${scriptlogdir}/.${servicename}-cp-error.tmp" >> "${scriptlog}"
rm "${scriptlogdir}/.${servicename}-cp-error.tmp"
fn_scriptlog "Failure! Unable to update"
exit ${status}
fi
rm -f teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2
rm -rf "${rootdir}/teamspeak3-server_linux_${ts3arch}"
}
check.sh
info_config.sh
fn_print_dots "Updating ${servername}"
sleep 1
fn_print_ok_nl "Updating ${servername}"
fn_scriptlog "Updating ${servername}"
sleep 1
if [ "${gamename}" == "Teamspeak 3" ]; then
fn_teamspeak3_dl
else
fn_steamcmd_dl
fi

238
lgsm/functions/update_steamcmd.sh

@ -0,0 +1,238 @@
#!/bin/bash
# LGSM command_update.sh function
# Author: Daniel Gibbs
# Website: https://gameservermanagers.com
# Description:Handles updating using steamCMD.
local commandname="UPDATE"
local commandaction="Update"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_update_steamcmd_dl(){
check.sh
info_config.sh
fn_print_dots "SteamCMD"
sleep 1
fn_print_ok_nl "SteamCMD"
fn_script_log_info "Starting SteamCMD"
cd "${rootdir}/steamcmd"
# Detects if unbuffer command is available.
if [ $(command -v stdbuf) ]; then
unbuffer="stdbuf -i0 -o0 -e0"
fi
if [ "${engine}" == "goldsource" ]; then
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit | tee -a "${scriptlog}"
else
${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit | tee -a "${scriptlog}"
fi
fix.sh
}
fn_appmanifest_info(){
appmanifestfile=$(find "${filesdir}" -type f -name "appmanifest_${appid}.acf")
appmanifestfilewc=$(find "${filesdir}" -type f -name "appmanifest_${appid}.acf"|wc -l)
}
fn_appmanifest_check(){
fn_appmanifest_info
# Multiple or no matching appmanifest files may sometimes be present.
# This error is corrected if required.
if [ "${appmanifestfilewc}" -ge "2" ]; then
sleep 1
fn_print_error "Multiple appmanifest_${appid}.acf files found"
fn_script_log_error "Multiple appmanifest_${appid}.acf files found"
sleep 2
fn_print_dots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files"
sleep 1
for appfile in ${appmanifestfile}; do
rm "${appfile}"
done
sleep 1
appmanifestfilewc1="${appmanifestfilewc}"
fn_appmanifest_info
if [ "${appmanifestfilewc}" -ge "2" ]; then
fn_print_fail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files"
fn_script_log_fatal "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files"
sleep 1
echo " * Check user permissions"
for appfile in ${appmanifestfile}; do
echo " ${appfile}"
done
core_exit.sh
else
fn_print_ok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files"
fn_script_log_pass "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files"
sleep 1
fn_print_info_nl "Forcing update to correct issue"
fn_script_log_info "Forcing update to correct issue"
sleep 1
fn_update_steamcmd_dl
fn_update_request_log
fi
elif [ "${appmanifestfilewc}" -eq "0" ]; then
fn_print_error "No appmanifest_${appid}.acf found"
fn_script_log_error "No appmanifest_${appid}.acf found"
sleep 1
fn_print_info_nl "Forcing update to correct issue"
fn_script_log_info "Forcing update to correct issue"
sleep 1
fn_update_steamcmd_dl
fn_update_request_log
fn_appmanifest_info
if [ "${appmanifestfilewc}" -eq "0" ]; then
fn_print_fatal "Still no appmanifest_${appid}.acf found"
fn_script_log_fatal "Still no appmanifest_${appid}.acf found"
core_exit.sh
fi
fi
}
fn_update_request_log(){
# Checks for server update requests from server logs.
fn_print_dots "Checking for update: Server logs"
fn_script_log_info "Checking for update: Server logs"
sleep 1
requestrestart=$(grep -Ec "MasterRequestRestart" "${consolelog}")
if [ "${requestrestart}" -ge "1" ]; then
fn_print_ok_nl "Checking for update: Server logs: Update requested"
fn_script_log_pass "Checking for update: Server logs: Update requested"
sleep 1
echo ""
echo -en "Applying update.\r"
sleep 1
echo -en "Applying update..\r"
sleep 1
echo -en "Applying update...\r"
sleep 1
echo -en "\n"
unset updateonstart
check_status.sh
if [ "${status}" != "0" ]; then
exitbypass=1
command_stop.sh
fn_update_steamcmd_dl
exitbypass=1
command_start.sh
else
fn_update_steamcmd_dl
fi
alert="update"
alert.sh
else
fn_print_ok "Checking for update: Server logs: No update requested"
sleep 1
fi
}
fn_update_steamcmd_check(){
fn_appmanifest_check
# Checks for server update from SteamCMD
fn_print_dots "Checking for update: SteamCMD"
fn_script_log_info "Checking for update: SteamCMD"
sleep 1
# Gets currentbuild
currentbuild=$(grep buildid "${appmanifestfile}" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3)
# Removes appinfo.vdf as a fix for not always getting up to date version info from SteamCMD
cd "${rootdir}/steamcmd"
if [ -f "${HOME}/Steam/appcache/appinfo.vdf" ]; then
rm -f "${HOME}/Steam/appcache/appinfo.vdf"
fi
# Set branch for updateinfo
IFS=' ' read -a branchsplits <<< "${branch}"
if [ "${#branchsplits[@]}" -gt 1 ]; then
branchname="${branchsplits[1]}"
else
branchname="public"
fi
# Gets availablebuild info
availablebuild=$(./steamcmd.sh +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +app_info_print "${appid}" +quit | grep -EA 1000 "^\s+\"branches\"$" | grep -EA 5 "^\s+\"${branchname}\"$" | grep -m 1 -EB 10 "^\s+}$" | grep -E "^\s+\"buildid\"\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3)
if [ -z "${availablebuild}" ]; then
fn_print_fail "Checking for update: SteamCMD"
sleep 1
fn_print_fail_nl "Checking for update: SteamCMD: Not returning version info"
fn_script_log_fatal "Checking for update: SteamCMD: Not returning version info"
core_exit.sh
else
fn_print_ok "Checking for update: SteamCMD"
fn_script_log_pass "Checking for update: SteamCMD"
sleep 1
fi
if [ "${currentbuild}" != "${availablebuild}" ]; then
fn_print_ok "Checking for update: SteamCMD: Update available"
fn_script_log_pass "Checking for update: SteamCMD: Update available"
echo -e "\n"
echo -e "Update available:"
sleep 1
echo -e " Current build: ${red}${currentbuild}${default}"
echo -e " Available build: ${green}${availablebuild}${default}"
echo -e ""
echo -e " https://steamdb.info/app/${appid}/"
sleep 1
echo ""
echo -en "Applying update.\r"
sleep 1
echo -en "Applying update..\r"
sleep 1
echo -en "Applying update...\r"
sleep 1
echo -en "\n"
fn_script_log_info "Update available"
fn_script_log_info "Current build: ${currentbuild}"
fn_script_log_info "Available build: ${availablebuild}"
fn_script_log_info "${currentbuild} > ${availablebuild}"
unset updateonstart
check_status.sh
if [ "${status}" != "0" ]; then
exitbypass=1
command_stop.sh
fn_update_steamcmd_dl
exitbypass=1
command_start.sh
else
fn_update_steamcmd_dl
fi
alert="update"
alert.sh
else
fn_print_ok "Checking for update: SteamCMD: No update available"
fn_script_log_pass "Checking for update: SteamCMD: No update available"
echo -e "\n"
echo -e "No update available:"
echo -e " Current version: ${green}${currentbuild}${default}"
echo -e " Available version: ${green}${availablebuild}${default}"
echo -e " https://steamdb.info/app/${appid}/"
echo -e ""
fn_script_log_info "Current build: ${currentbuild}"
fn_script_log_info "Available build: ${availablebuild}"
fi
}
if [ "${engine}" == "goldsource" ]||[ "${forceupdate}" == "1" ]; then
# Goldsource servers bypass checks as fn_update_steamcmd_check does not work for appid 90 servers.
# forceupdate bypasses checks
check_status.sh
if [ "${status}" != "0" ]; then
exitbypass=1
command_stop.sh
fn_update_steamcmd_dl
exitbypass=1
command_start.sh
else
fn_update_steamcmd_dl
fi
else
fn_update_request_log
fn_update_steamcmd_check
fi

182
lgsm/functions/update_ts3.sh

@ -0,0 +1,182 @@
#!/bin/bash
# LGSM command_update.sh function
# Author: Daniel Gibbs
# Website: https://gameservermanagers.com
# Description:Handles updating of teamspeak 3 servers.
local commandname="UPDATE"
local commandaction="Update"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_update_ts3_dl(){
fn_fetch_file "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${lgsmdir}/tmp" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
fn_dl_extract "${lgsmdir}/tmp" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${lgsmdir}/tmp"
echo -e "copying to ${filesdir}...\c"
fn_script_log "Copying to ${filesdir}"
cp -R "${lgsmdir}/tmp/teamspeak3-server_linux_${ts3arch}/"* "${filesdir}"
local exitcode=$?
if [ ${exitcode} -eq 0 ]; then
fn_print_ok_eol_nl
else
fn_print_fail_eol_nl
fi
}
fn_update_ts3_currentbuild(){
# Gets currentbuild info
# Checks currentbuild info is available, if fails a server restart will be forced to generate logs.
if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then
fn_print_error "Checking for update: teamspeak.com"
sleep 1
fn_print_error_nl "Checking for update: teamspeak.com: No logs with server version found"
fn_script_log_error "Checking for update: teamspeak.com: No logs with server version found"
sleep 2
fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart"
fn_script_log_info "Checking for update: teamspeak.com: Forcing server restart"
sleep 2
exitbypass=1
command_stop.sh
exitbypass=1
command_start.sh
sleep 1
# Check again and exit on failure.
if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then
fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found"
fn_script_log_fatal "Checking for update: teamspeak.com: Still No logs with server version found"
core_exit.sh
fi
fi
currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}')
}
fn_update_ts3_arch(){
# Gets the teamspeak server architecture.
info_distro.sh
if [ "${arch}" == "x86_64" ]; then
ts3arch="amd64"
elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then
ts3arch="x86"
else
echo ""
fn_print_failure "unknown or unsupported architecture: ${arch}"
fn_script_log_fatal "unknown or unsupported architecture: ${arch}"
core_exit.sh
fi
}
fn_update_ts3_availablebuild(){
# Gets availablebuild info.
# Creates tmp dir if missing
if [ ! -d "${lgsmdir}/tmp" ]; then
mkdir -p "${lgsmdir}/tmp"
fi
# Grabs all version numbers but not in correct order.
wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '<a href=\".*\/\">.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp"
# Sort version numbers
cat "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" | sort -r --version-sort -o "${lgsmdir}/tmp/.ts3_version_numbers_sorted.tmp"
# Finds directory with most recent server version.
while read ts3_version_number; do
wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
if [ $? -eq 0 ]; then
availablebuild="${ts3_version_number}"
# Break while-loop, if the latest release could be found.
break
fi
done < "${lgsmdir}/tmp/.ts3_version_numbers_sorted.tmp"
# Tidy up
rm -f "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp"
rm -f "${lgsmdir}/tmp/.ts3_version_numbers_sorted.tmp"
# Checks availablebuild info is available
if [ -z "${availablebuild}" ]; then
fn_print_fail "Checking for update: teamspeak.com"
sleep 1
fn_print_fail "Checking for update: teamspeak.com: Not returning version info"
fn_script_log_fatal "Failure! Checking for update: teamspeak.com: Not returning version info"
core_exit.sh
else
fn_print_ok_nl "Checking for update: teamspeak.com"
fn_script_log_pass "Checking for update: teamspeak.com"
sleep 1
fi
}
fn_update_ts3_compare(){
# Removes dots so if can compare version numbers
currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]')
availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]')
if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then
echo -e "\n"
echo -e "Update available:"
sleep 1
echo -e " Current build: ${red}${currentbuild} ${architecture}${default}"
echo -e " Available build: ${green}${availablebuild} ${architecture}${default}"
echo -e ""
sleep 1
echo ""
echo -en "Applying update.\r"
sleep 1
echo -en "Applying update..\r"
sleep 1
echo -en "Applying update...\r"
sleep 1
echo -en "\n"
fn_script_log "Update available"
fn_script_log "Current build: ${currentbuild}"
fn_script_log "Available build: ${availablebuild}"
fn_script_log "${currentbuild} > ${availablebuild}"
unset updateonstart
check_status.sh
if [ "${status}" == "0" ]; then
fn_update_ts3_dl
exitbypass=1
command_start.sh
exitbypass=1
command_stop.sh
else
exitbypass=1
command_stop.sh
fn_update_ts3_dl
exitbypass=1
command_start.sh
fi
alert="update"
alert.sh
else
echo -e "\n"
echo -e "No update available:"
echo -e " Current version: ${green}${currentbuild}${default}"
echo -e " Available version: ${green}${availablebuild}${default}"
echo -e ""
fn_print_ok_nl "No update available"
fn_script_log_info "Current build: ${currentbuild}"
fn_script_log_info "Available build: ${availablebuild}"
fi
}
fn_update_ts3_arch
if [ "${installer}" == "1" ]; then
fn_update_ts3_availablebuild
fn_update_ts3_dl
else
# Checks for server update from teamspeak.com using a mirror dl.4players.de.
fn_print_dots "Checking for update: teamspeak.com"
fn_script_log_info "Checking for update: teamspeak.com"
sleep 1
fn_update_ts3_currentbuild
fn_update_ts3_availablebuild
fn_update_ts3_compare
fi

398
tests/tests_jc2server.sh

@ -1,16 +1,29 @@
#!/bin/bash #!/bin/bash
# TravisCI Tests # TravisCI Tests: Just Cause 2
# Server Management Script # Server Management Script
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
version="271215" version="101716"
if [ -f ".dev-debug" ]; then
exec 5>dev-debug.log
BASH_XTRACEFD="5"
set -x
fi
#### Variables #### #### Variables ####
# Alert Email # Notification Alerts
# (on|off) # (on|off)
# Email
emailalert="off" emailalert="off"
email="" email="[email protected]"
# Pushbullet
# https://www.pushbullet.com/#settings
pushbulletalert="off"
pushbullettoken="accesstoken"
# Steam login # Steam login
steamuser="anonymous" steamuser="anonymous"
@ -44,6 +57,9 @@ engine="avalanche"
rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
lockselfname=".${servicename}.lock" lockselfname=".${servicename}.lock"
lgsmdir="${rootdir}/lgsm"
functionsdir="${lgsmdir}/functions"
libdir="${lgsmdir}/lib"
filesdir="${rootdir}/serverfiles" filesdir="${rootdir}/serverfiles"
systemdir="${filesdir}" systemdir="${filesdir}"
executabledir="${filesdir}" executabledir="${filesdir}"
@ -59,6 +75,7 @@ logdays="7"
#gamelogdir="" # No server logs available #gamelogdir="" # No server logs available
scriptlogdir="${rootdir}/log/script" scriptlogdir="${rootdir}/log/script"
consolelogdir="${rootdir}/log/console" consolelogdir="${rootdir}/log/console"
consolelogging="on"
scriptlog="${scriptlogdir}/${servicename}-script.log" scriptlog="${scriptlogdir}/${servicename}-script.log"
consolelog="${consolelogdir}/${servicename}-console.log" consolelog="${consolelogdir}/${servicename}-console.log"
@ -70,74 +87,80 @@ consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-
##### Script ##### ##### Script #####
# Do not edit # Do not edit
fn_getgithubfile(){ # Fetches core_dl for file downloads
filename=$1 fn_fetch_core_dl(){
exec=$2 github_file_url_dir="lgsm/functions"
fileurl=${3:-$filename} github_file_url_name="${functionfile}"
filepath="${rootdir}/${filename}" filedir="${functionsdir}"
filedir=$(dirname "${filepath}") filename="${github_file_url_name}"
# If the function file is missing, then download githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
if [ ! -f "${filepath}" ]; then # If the file is missing, then download
if [ ! -f "${filedir}/${filename}" ]; then
if [ ! -d "${filedir}" ]; then if [ ! -d "${filedir}" ]; then
mkdir "${filedir}" mkdir -p "${filedir}"
fi fi
githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
echo -e " fetching ${filename}...\c" echo -e " fetching ${filename}...\c"
if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then # Check curl exists and use available path
: curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
for curlcmd in ${curlpaths}
do
if [ -x "${curlcmd}" ]; then
break
fi
done
# If curl exists download file
if [ "$(basename ${curlcmd})" == "curl" ]; then
curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
if [ $? -ne 0 ]; then
echo -e "\e[0;31mFAIL\e[0m\n"
echo "${curlfetch}"
echo -e "${githuburl}\n"
exit 1
else
echo -e "\e[0;32mOK\e[0m"
fi
else else
echo -e "\e[0;31mFAIL\e[0m\n" echo -e "\e[0;31mFAIL\e[0m\n"
echo "Curl is not installed!" echo "Curl is not installed!"
echo -e "" echo -e ""
exit exit 1
fi
curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
if [ $? -ne 0 ]; then
echo -e "\e[0;31mFAIL\e[0m\n"
echo "${curl}"
echo -e "${githuburl}\n"
exit
else
echo -e "\e[0;32mOK\e[0m"
fi
if [ "${exec}" ]; then
chmod +x "${filepath}"
fi fi
chmod +x "${filedir}/${filename}"
fi fi
if [ "${exec}" ]; then source "${filedir}/${filename}"
source "${filepath}"
fi
} }
fn_runfunction(){ core_dl.sh(){
fn_getgithubfile "functions/${functionfile}" 1 # Functions are defined in core_functions.sh.
functionfile="${FUNCNAME}"
fn_fetch_core_dl
} }
core_functions.sh(){ core_functions.sh(){
# Functions are defined in core_functions.sh. # Functions are defined in core_functions.sh.
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_core_dl
} }
core_dl.sh
core_functions.sh core_functions.sh
fn_currentstatus_tmux(){ fn_currentstatus_tmux(){
pid=$(tmux list-sessions 2>&1 | awk '{print $1}' | grep -Ec "^${servicename}:") check_status.sh
if [ "${pid}" != "0" ]; then if [ "${status}" != "0" ]; then
currentstatus="ONLINE" currentstatus="ONLINE"
else else
currentstatus="OFFLINE" currentstatus="OFFLINE"
fi fi
} }
fn_currentstatus_ts3(){ fn_currentstatus_ts3(){
ts3status=$(${executable} status servercfgfullpathfile=${servercfgfullpath}) check_status.sh
if [ "${status}" != "0" ]; then
if [ "${ts3status}" == "Server is running" ]; then currentstatus="ONLINE"
currentstatus="ONLINE" else
else currentstatus="OFFLINE"
currentstatus="OFFLINE" fi
fi
} }
fn_setstatus(){ fn_setstatus(){
@ -146,9 +169,9 @@ fn_setstatus(){
echo "Required status: ${requiredstatus}" echo "Required status: ${requiredstatus}"
counter=0 counter=0
echo "Current status: ${currentstatus}" echo "Current status: ${currentstatus}"
while [ "${requiredstatus}" != "${currentstatus}" ]; do while [ "${requiredstatus}" != "${currentstatus}" ]; do
counter=$((counter+1)) counter=$((counter+1))
fn_currentstatus_tmux fn_currentstatus_tmux
echo -ne "New status: ${currentstatus}\\r" echo -ne "New status: ${currentstatus}\\r"
if [ "${requiredstatus}" == "ONLINE" ]; then if [ "${requiredstatus}" == "ONLINE" ]; then
@ -171,6 +194,44 @@ fn_setstatus(){
sleep 0.5 sleep 0.5
} }
# End of every test will expect the result to either pass or fail
# If the script does not do as intended the whole test will fail
# if excpecting a pass
fn_test_result_pass(){
if [ $? != 0 ]; then
echo "================================="
echo "Expected result: PASS"
echo "Actual result: FAIL"
fn_print_fail_nl "TEST FAILED"
exitcode=1
core_exit.sh
else
echo "================================="
echo "Expected result: PASS"
echo "Actual result: PASS"
fn_print_ok_nl "TEST PASSED"
echo ""
fi
}
# if excpecting a fail
fn_test_result_fail(){
if [ $? == 0 ]; then
echo "================================="
echo "Expected result: FAIL"
echo "Actual result: PASS"
fn_print_fail_nl "TEST FAILED"
exitcode=1
core_exit.sh
else
echo "================================="
echo "Expected result: FAIL"
echo "Actual result: FAIL"
fn_print_ok_nl "TEST PASSED"
echo ""
fi
}
echo "=================================" echo "================================="
echo "TravisCI Tests" echo "TravisCI Tests"
echo "Linux Game Server Manager" echo "Linux Game Server Manager"
@ -178,308 +239,313 @@ echo "by Daniel Gibbs"
echo "https://gameservermanagers.com" echo "https://gameservermanagers.com"
echo "=================================" echo "================================="
echo "" echo ""
sleep 1
echo "=================================" echo "================================="
echo "Server Tests" echo "Server Tests"
echo "Using: ${gamename}" echo "Using: ${gamename}"
echo "Testing Branch: $TRAVIS_BRANCH" echo "Testing Branch: $TRAVIS_BRANCH"
echo "=================================" echo "================================="
echo "" echo ""
sleep 1
mkdir ${rootdir}
echo "0.1 - Create log dir's"
echo "================================="
echo "Description:"
echo "Create log dir's"
echo ""
(install_logs.sh)
echo "0.2 - Enable dev-debug"
echo "================================="
echo "Description:"
echo "Enable dev-debug"
echo ""
(command_dev_debug.sh)
fn_test_result_pass
echo "1.0 - start - no files" echo "1.0 - start - no files"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "test script reaction to missing server files." echo "test script reaction to missing server files."
echo "Command: ./jc2server start"
echo "" echo ""
(command_start.sh) (command_start.sh)
echo "" fn_test_result_fail
echo "Test complete!"
sleep 1
echo "" echo ""
echo "1.1 - getopt" echo "1.1 - getopt"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "displaying options messages." echo "displaying options messages."
echo "Command: ./jc2server"
echo "" echo ""
(core_getopt.sh) (core_getopt.sh)
fn_test_result_pass
echo "" echo ""
echo "Test complete!" echo "1.2 - getopt with incorrect args"
sleep 1 echo "================================="
echo "Description:"
echo "displaying options messages."
echo "Command: ./jc2server abc123"
echo "" echo ""
getopt="abc123"
(core_getopt.sh)
fn_test_result_fail
echo ""
echo "2.0 - install" echo "2.0 - install"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "install ${gamename} server." echo "install ${gamename} server."
fn_autoinstall echo "Command: ./jc2server auto-install"
echo "" (fn_autoinstall)
echo "Test complete!" fn_test_result_pass
sleep 1
echo ""
echo ""
echo "3.1 - start" echo "3.1 - start"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "start ${gamename} server." echo "start ${gamename} server."
echo "Command: ./jc2server start"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
command_start.sh (command_start.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo "" echo ""
echo "3.2 - start - online" echo "3.2 - start - online"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "start ${gamename} server while already running." echo "start ${gamename} server while already running."
echo "Command: ./jc2server start"
requiredstatus="ONLINE" requiredstatus="ONLINE"
fn_setstatus fn_setstatus
(command_start.sh) (command_start.sh)
echo "" fn_test_result_fail
echo "Test complete!"
sleep 1
echo "" echo ""
echo "3.3 - start - updateonstart" echo "3.3 - start - updateonstart"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "will update server on start." echo "will update server on start."
echo "Command: ./jc2server start"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
( (updateonstart="on";command_start.sh)
updateonstart="on" fn_test_result_pass
command_start.sh
)
echo ""
echo "Test complete!"
sleep 1
echo "" echo ""
echo "3.4 - stop" echo "3.4 - stop"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "stop ${gamename} server." echo "stop ${gamename} server."
echo "Command: ./jc2server stop"
requiredstatus="ONLINE" requiredstatus="ONLINE"
fn_setstatus fn_setstatus
command_stop.sh (command_stop.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo "" echo ""
echo "3.5 - stop - offline" echo "3.5 - stop - offline"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "stop ${gamename} server while already stopped." echo "stop ${gamename} server while already stopped."
echo "Command: ./jc2server stop"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
(command_stop.sh) (command_stop.sh)
echo "" fn_test_result_fail
echo "Test complete!"
sleep 1
echo "" echo ""
echo "3.6 - restart" echo "3.6 - restart"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "restart ${gamename}." echo "restart ${gamename}."
echo "Command: ./jc2server restart"
requiredstatus="ONLINE" requiredstatus="ONLINE"
fn_setstatus fn_setstatus
fn_restart (command_restart.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo "" echo ""
echo "3.7 - restart - offline" echo "3.7 - restart - offline"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "restart ${gamename} while already stopped." echo "restart ${gamename} while already stopped."
echo "Command: ./jc2server restart"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
fn_restart (command_restart.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo ""
echo "4.1 - update" echo "4.1 - update"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "check for updates." echo "check for updates."
echo "Command: ./jc2server update"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
update_check.sh (command_update.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo "" echo ""
echo "4.2 - update - change buildid" echo "4.2 - update - change buildid"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "change the buildid tricking SteamCMD to update." echo "change the buildid tricking SteamCMD to update."
echo "Command: ./jc2server update"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
fn_print_info_nl "changed buildid to 0." fn_print_info_nl "changed buildid to 0."
sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf sed -i 's/[0-9]\+/0/' "${filesdir}/steamapps/appmanifest_${appid}.acf"
update_check.sh (command_update.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo "" echo ""
echo "4.3 - update - change buildid - online" echo "4.3 - update - change buildid - online"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "change the buildid tricking SteamCMD to update server while already running." echo "change the buildid tricking SteamCMD to update server while already running."
echo "Command: ./jc2server update"
requiredstatus="ONLINE" requiredstatus="ONLINE"
fn_setstatus fn_setstatus
fn_print_info_nl "changed buildid to 0." fn_print_info_nl "changed buildid to 0."
sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf sed -i 's/[0-9]\+/0/' "${filesdir}/steamapps/appmanifest_${appid}.acf"
update_check.sh (command_update.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo "" echo ""
echo "4.4 - update - remove appmanifest file" echo "4.4 - update - remove appmanifest file"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "removing appmanifest file will cause script to repair." echo "removing appmanifest file will cause script to repair."
echo "Command: ./jc2server update"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
fn_print_info_nl "removed appmanifest_${appid}.acf." fn_print_info_nl "removed appmanifest_${appid}.acf."
rm --verbose "${filesdir}/steamapps/appmanifest_${appid}.acf" rm --verbose "${filesdir}/steamapps/appmanifest_${appid}.acf"
update_check.sh (command_update.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo "" echo ""
echo "4.5 - force-update" echo "4.5 - force-update"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "force-update bypassing update check." echo "force-update bypassing update check."
echo "Command: ./jc2server force-update"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
update_check.sh (forceupdate=1;command_update.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo "" echo ""
echo "4.6 - force-update - online" echo "4.6 - force-update - online"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "force-update bypassing update check server while already running." echo "force-update bypassing update check server while already running."
echo "Command: ./jc2server force-update"
requiredstatus="ONLINE" requiredstatus="ONLINE"
fn_setstatus fn_setstatus
update_check.sh (forceupdate=1;command_update.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo "" echo ""
echo "4.7 - validate" echo "4.7 - validate"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "validate server files." echo "validate server files."
echo "Command: ./jc2server validate"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
command_validate.sh (command_validate.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo "" echo ""
echo "4.8 - validate - online" echo "4.8 - validate - online"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "validate server files while server while already running." echo "validate server files while server while already running."
echo ""
echo "Command: ./jc2server validate"
requiredstatus="ONLINE" requiredstatus="ONLINE"
fn_setstatus fn_setstatus
command_validate.sh (command_validate.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo ""
echo ""
echo "5.1 - monitor - online" echo "5.1 - monitor - online"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "run monitor server while already running." echo "run monitor server while already running."
echo "Command: ./jc2server monitor"
requiredstatus="ONLINE" requiredstatus="ONLINE"
fn_setstatus fn_setstatus
(command_monitor.sh) (command_monitor.sh)
fn_test_result_pass
echo "" echo ""
echo "Test complete!" echo "5.2 - monitor - offline - with lockfile"
sleep 1
echo ""
echo "5.2 - monitor - offline - no lockfile"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "run monitor while server is offline with no lockfile." echo "run monitor while server is offline with lockfile."
echo "Command: ./jc2server monitor"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
fn_print_info_nl "creating lockfile."
date > "${rootdir}/${lockselfname}"
(command_monitor.sh) (command_monitor.sh)
fn_test_result_pass
echo "" echo ""
echo "Test complete!" echo "5.3 - monitor - offline - no lockfile"
sleep 1
echo ""
echo "5.3 - monitor - offline - with lockfile"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "run monitor while server is offline with no lockfile." echo "run monitor while server is offline with no lockfile."
echo "Command: ./jc2server monitor"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
fn_print_info_nl "creating lockfile."
date > "${rootdir}/${lockselfname}"
(command_monitor.sh) (command_monitor.sh)
echo "" fn_test_result_fail
echo "Test complete!"
sleep 1
echo "" echo ""
echo "5.4 - monitor - gsquery.py failure" echo "5.4 - monitor - gsquery.py failure"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "gsquery.py will fail to query port." echo "gsquery.py will fail to query port."
echo "Command: ./jc2server monitor"
requiredstatus="ONLINE" requiredstatus="ONLINE"
fn_setstatus fn_setstatus
sed -i 's/[0-9]\+/0/' "${servercfgfullpath}" sed -i 's/[0-9]\+/0/' "${servercfgfullpath}"
(command_monitor.sh) (command_monitor.sh)
fn_test_result_fail
echo "" echo ""
fn_print_info_nl "Reseting ${servercfg}." fn_print_info_nl "Re-generating ${servercfg}."
install_config.sh install_config.sh
echo "" echo "================================="
echo "Test complete!"
sleep 1
echo ""
echo ""
echo "6.0 - details" echo "6.0 - details"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "display details." echo "display details."
echo "Command: ./jc2server details"
requiredstatus="ONLINE" requiredstatus="ONLINE"
fn_setstatus fn_setstatus
command_details.sh (command_details.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo ""
echo ""
echo "=================================" echo "================================="
echo "Server Tests - Complete!" echo "Server Tests - Complete!"
echo "Using: ${gamename}" echo "Using: ${gamename}"
echo "=================================" echo "================================="
echo ""
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
sleep 1 sleep 1
fn_print_info "Tidying up directories." fn_print_info "Tidying up directories."
sleep 1 sleep 1
rm -rfv ${serverfiles} rm -rfv "${serverfiles}"
echo "END" core_exit.sh

355
tests/tests_ts3server.sh

@ -1,20 +1,46 @@
#!/bin/bash #!/bin/bash
# TravisCI Tests # TravisCI Tests: Teamspeak 3
# Server Management Script # Server Management Script
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: https://gameservermanagers.com # Website: https://gameservermanagers.com
version="071115" version="101716"
if [ -f ".dev-debug" ]; then
exec 5>dev-debug.log
BASH_XTRACEFD="5"
set -x
fi
#### Variables #### #### Variables ####
# Alert Email # Notification Alerts
# (on|off) # (on|off)
# Email
emailalert="off" emailalert="off"
email="" email="[email protected]"
# Pushbullet
# https://www.pushbullet.com/#settings
pushbulletalert="off"
pushbullettoken="accesstoken"
# Start Variables # Start Variables
updateonstart="off" updateonstart="off"
fn_parms(){
parms=""
}
#### Advanced Variables ####
# Github Branch Select
# Allows for the use of different function files
# from a different repo and/or branch.
githubuser="dgibbs64"
githubrepo="linuxgsm"
githubbranch="$TRAVIS_BRANCH"
# Server Details # Server Details
gamename="Teamspeak 3" gamename="Teamspeak 3"
servername="Teamspeak 3 Server" servername="Teamspeak 3 Server"
@ -24,6 +50,9 @@ servicename="ts3-server"
rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
lockselfname=".${servicename}.lock" lockselfname=".${servicename}.lock"
lgsmdir="${rootdir}/lgsm"
functionsdir="${lgsmdir}/functions"
libdir="${lgsmdir}/lib"
filesdir="${rootdir}/serverfiles" filesdir="${rootdir}/serverfiles"
systemdir="${filesdir}" systemdir="${filesdir}"
executabledir="${filesdir}" executabledir="${filesdir}"
@ -34,7 +63,6 @@ servercfgfullpath="${servercfgdir}/${servercfg}"
servercfgdefault="${servercfgdir}/lgsm-default.ini" servercfgdefault="${servercfgdir}/lgsm-default.ini"
backupdir="${rootdir}/backups" backupdir="${rootdir}/backups"
# Logging # Logging
logdays="7" logdays="7"
gamelogdir="${filesdir}/logs" gamelogdir="${filesdir}/logs"
@ -45,67 +73,65 @@ emaillog="${scriptlogdir}/${servicename}-email.log"
scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log" scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
#### Advanced Variables ####
# Github Branch Select
# Allows for the use of different function files
# from a different repo and/or branch.
githubuser="dgibbs64"
githubrepo="linuxgsm"
githubbranch="$TRAVIS_BRANCH"
##### Script ##### ##### Script #####
# Do not edit # Do not edit
fn_getgithubfile(){ # Fetches core_dl for file downloads
filename=$1 fn_fetch_core_dl(){
exec=$2 github_file_url_dir="lgsm/functions"
fileurl=${3:-$filename} github_file_url_name="${functionfile}"
filepath="${rootdir}/${filename}" filedir="${functionsdir}"
filedir=$(dirname "${filepath}") filename="${github_file_url_name}"
# If the function file is missing, then download githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
if [ ! -f "${filepath}" ]; then # If the file is missing, then download
if [ ! -f "${filedir}/${filename}" ]; then
if [ ! -d "${filedir}" ]; then if [ ! -d "${filedir}" ]; then
mkdir "${filedir}" mkdir -p "${filedir}"
fi fi
githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
echo -e " fetching ${filename}...\c" echo -e " fetching ${filename}...\c"
if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then # Check curl exists and use available path
: curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
for curlcmd in ${curlpaths}
do
if [ -x "${curlcmd}" ]; then
break
fi
done
# If curl exists download file
if [ "$(basename ${curlcmd})" == "curl" ]; then
curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
if [ $? -ne 0 ]; then
echo -e "\e[0;31mFAIL\e[0m\n"
echo "${curlfetch}"
echo -e "${githuburl}\n"
exit 1
else
echo -e "\e[0;32mOK\e[0m"
fi
else else
echo -e "\e[0;31mFAIL\e[0m\n" echo -e "\e[0;31mFAIL\e[0m\n"
echo "Curl is not installed!" echo "Curl is not installed!"
echo -e "" echo -e ""
exit exit 1
fi
curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
if [ $? -ne 0 ]; then
echo -e "\e[0;31mFAIL\e[0m\n"
echo "${curl}"
echo -e "${githuburl}\n"
exit
else
echo -e "\e[0;32mOK\e[0m"
fi fi
if [ "${exec}" ]; then chmod +x "${filedir}/${filename}"
chmod +x "${filepath}"
fi
fi
if [ "${exec}" ]; then
source "${filepath}"
fi fi
source "${filedir}/${filename}"
} }
fn_runfunction(){ core_dl.sh(){
fn_getgithubfile "functions/${functionfile}" 1 # Functions are defined in core_functions.sh.
functionfile="${FUNCNAME}"
fn_fetch_core_dl
} }
core_functions.sh(){ core_functions.sh(){
# Functions are defined in core_functions.sh. # Functions are defined in core_functions.sh.
functionfile="${FUNCNAME}" functionfile="${FUNCNAME}"
fn_runfunction fn_fetch_core_dl
} }
core_dl.sh
core_functions.sh core_functions.sh
fn_currentstatus_tmux(){ fn_currentstatus_tmux(){
@ -118,7 +144,7 @@ fn_currentstatus_tmux(){
} }
fn_currentstatus_ts3(){ fn_currentstatus_ts3(){
check_status.sh check_status.sh
if [ "${status}" != "0" ]; then if [ "${status}" != "0" ]; then
currentstatus="ONLINE" currentstatus="ONLINE"
else else
@ -132,15 +158,15 @@ fn_setstatus(){
echo "Required status: ${requiredstatus}" echo "Required status: ${requiredstatus}"
counter=0 counter=0
echo "Current status: ${currentstatus}" echo "Current status: ${currentstatus}"
while [ "${requiredstatus}" != "${currentstatus}" ]; do while [ "${requiredstatus}" != "${currentstatus}" ]; do
counter=$((counter+1)) counter=$((counter+1))
fn_currentstatus_ts3 fn_currentstatus_ts3
echo -ne "New status: ${currentstatus}\\r" echo -ne "New status: ${currentstatus}\\r"
if [ "${requiredstatus}" == "ONLINE" ]; then if [ "${requiredstatus}" == "ONLINE" ]; then
(command_start.sh) (command_start.sh > /dev/null 2>&1)
else else
(command_stop.sh) (command_stop.sh > /dev/null 2>&1)
fi fi
if [ "${counter}" -gt "5" ]; then if [ "${counter}" -gt "5" ]; then
currentstatus="FAIL" currentstatus="FAIL"
@ -157,6 +183,44 @@ fn_setstatus(){
sleep 0.5 sleep 0.5
} }
# End of every test will expect the result to either pass or fail
# If the script does not do as intended the whole test will fail
# if excpecting a pass
fn_test_result_pass(){
if [ $? != 0 ]; then
echo "================================="
echo "Expected result: PASS"
echo "Actual result: FAIL"
fn_print_fail_nl "TEST FAILED"
exitcode=1
core_exit.sh
else
echo "================================="
echo "Expected result: PASS"
echo "Actual result: PASS"
fn_print_ok_nl "TEST PASSED"
echo ""
fi
}
# if excpecting a fail
fn_test_result_fail(){
if [ $? == 0 ]; then
echo "================================="
echo "Expected result: FAIL"
echo "Actual result: PASS"
fn_print_fail_nl "TEST FAILED"
exitcode=1
core_exit.sh
else
echo "================================="
echo "Expected result: FAIL"
echo "Actual result: FAIL"
fn_print_ok_nl "TEST PASSED"
echo ""
fi
}
echo "=================================" echo "================================="
echo "TravisCI Tests" echo "TravisCI Tests"
echo "Linux Game Server Manager" echo "Linux Game Server Manager"
@ -164,232 +228,213 @@ echo "by Daniel Gibbs"
echo "https://gameservermanagers.com" echo "https://gameservermanagers.com"
echo "=================================" echo "================================="
echo "" echo ""
sleep 1
echo "=================================" echo "================================="
echo "Server Tests" echo "Server Tests"
echo "Using: ${gamename}" echo "Using: ${gamename}"
echo "Testing Branch: $TRAVIS_BRANCH"
echo "=================================" echo "================================="
echo "" echo ""
sleep 1
echo "0.1 - Create log dir's"
echo "================================="
echo "Description:"
echo "Create log dir's"
echo ""
(install_logs.sh)
echo "0.2 - Enable dev-debug"
echo "================================="
echo "Description:"
echo "Enable dev-debug"
echo ""
(command_dev_debug.sh)
fn_test_result_pass
echo "1.0 - start - no files" echo "1.0 - start - no files"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "test script reaction to missing server files." echo "test script reaction to missing server files."
echo "Command: ./ts3server start"
echo "" echo ""
(command_start.sh) (command_start.sh)
echo "" fn_test_result_fail
echo "Test complete!"
sleep 1
echo "" echo ""
echo "1.1 - getopt" echo "1.1 - getopt"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "displaying options messages." echo "displaying options messages."
echo "Command: ./ts3server"
echo "" echo ""
(core_getopt.sh) (core_getopt.sh)
fn_test_result_pass
echo "" echo ""
echo "Test complete!" echo "1.2 - getopt with incorrect args"
sleep 1 echo "================================="
echo "Description:"
echo "displaying options messages."
echo "Command: ./ts3server abc123"
echo "" echo ""
getopt="abc123"
(core_getopt.sh)
fn_test_result_fail
echo ""
echo "2.0 - install" echo "2.0 - install"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "install ${gamename} server." echo "install ${gamename} server."
fn_autoinstall echo "Command: ./ts3server auto-install"
echo "" (fn_autoinstall)
echo "Test complete!" fn_test_result_pass
sleep 1
echo ""
echo ""
echo "3.1 - start" echo "3.1 - start"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "start ${gamename} server." echo "start ${gamename} server."
echo "Command: ./ts3server start"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
command_start.sh (command_start.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo "" echo ""
echo "3.2 - start - online" echo "3.2 - start - online"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "start ${gamename} server while already running." echo "start ${gamename} server while already running."
echo "Command: ./ts3server start"
requiredstatus="ONLINE" requiredstatus="ONLINE"
fn_setstatus fn_setstatus
(command_start.sh) (command_start.sh)
echo "" fn_test_result_fail
echo "Test complete!"
sleep 1
echo "" echo ""
echo "3.3 - start - updateonstart" echo "3.3 - start - updateonstart"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "will update server on start." echo "will update server on start."
echo "Command: ./ts3server start"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
( (updateonstart="on";command_start.sh)
updateonstart="on" fn_test_result_pass
command_start.sh
)
echo ""
echo "Test complete!"
sleep 1
echo "" echo ""
echo "3.4 - stop" echo "3.4 - stop"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "stop ${gamename} server." echo "stop ${gamename} server."
echo "Command: ./ts3server stop"
requiredstatus="ONLINE" requiredstatus="ONLINE"
fn_setstatus fn_setstatus
command_stop.sh (command_stop.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo "" echo ""
echo "3.5 - stop - offline" echo "3.5 - stop - offline"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "stop ${gamename} server while already stopped." echo "stop ${gamename} server while already stopped."
echo "Command: ./ts3server stop"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
(command_stop.sh) (command_stop.sh)
echo "" fn_test_result_fail
echo "Test complete!"
sleep 1
echo "" echo ""
echo "3.6 - restart" echo "3.6 - restart"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "restart ${gamename}." echo "restart ${gamename}."
echo "Command: ./ts3server restart"
requiredstatus="ONLINE" requiredstatus="ONLINE"
fn_setstatus fn_setstatus
fn_restart (command_restart.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo "" echo ""
echo "3.7 - restart - offline" echo "3.7 - restart - offline"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "restart ${gamename} while already stopped." echo "restart ${gamename} while already stopped."
echo "Command: ./ts3server restart"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
fn_restart (command_restart.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo ""
echo "4.1 - update" echo "4.1 - update"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "check for updates." echo "check for updates."
echo "Command: ./jc2server update"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
update_check.sh (command_update.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo ""
echo "4.1 - update - old version"
echo "================================="
echo "Description:"
echo "change the version number tricking LGSM to update."
requiredstatus="OFFLINE"
sed -i 's/[0-9]\+/0/g' ${gamelogdir}/ts3server*_0.log
fn_setstatus
update_check.sh
echo ""
echo "Test complete!"
sleep 1
echo ""
echo ""
echo "5.1 - monitor - online" echo "5.1 - monitor - online"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "run monitor server while already running." echo "run monitor server while already running."
echo "Command: ./ts3server monitor"
requiredstatus="ONLINE" requiredstatus="ONLINE"
fn_setstatus fn_setstatus
(command_monitor.sh) (command_monitor.sh)
fn_test_result_pass
echo "" echo ""
echo "Test complete!" echo "5.2 - monitor - offline - with lockfile"
sleep 1
echo ""
echo "5.2 - monitor - offline - no lockfile"
echo "================================="
echo "Description:"
echo "run monitor while server is offline with no lockfile."
requiredstatus="OFFLINE"
fn_setstatus
(command_monitor.sh)
echo ""
echo "Test complete!"
sleep 1
echo ""
echo "5.3 - monitor - offline - with lockfile"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "run monitor while server is offline with no lockfile." echo "run monitor while server is offline with lockfile."
echo "Command: ./ts3server monitor"
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
fn_print_info_nl "creating lockfile." fn_print_info_nl "creating lockfile."
date > "${rootdir}/${lockselfname}" date > "${rootdir}/${lockselfname}"
(command_monitor.sh) (command_monitor.sh)
fn_test_result_pass
echo "" echo ""
echo "Test complete!" echo "5.3 - monitor - offline - no lockfile"
sleep 1
echo ""
echo "5.4 - monitor - gsquery.py failure"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "gsquery.py will fail to query port." echo "run monitor while server is offline with no lockfile."
requiredstatus="ONLINE" echo "Command: ./ts3server monitor"
requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
sed -i 's/[0-9]\+/0/' "${servercfgfullpath}"
(command_monitor.sh) (command_monitor.sh)
echo "" fn_test_result_fail
fn_print_info_nl "Reseting ${servercfg}."
install_config.sh
echo ""
echo "Test complete!"
sleep 1
echo ""
echo ""
echo "6.0 - details" echo "6.0 - details"
echo "=================================" echo "================================="
echo "Description:" echo "Description:"
echo "display details." echo "display details."
echo "Command: ./ts3server details"
requiredstatus="ONLINE" requiredstatus="ONLINE"
fn_setstatus fn_setstatus
command_details.sh (command_details.sh)
echo "" fn_test_result_pass
echo "Test complete!"
sleep 1
echo ""
echo ""
echo "=================================" echo "================================="
echo "Server Tests - Complete!" echo "Server Tests - Complete!"
echo "Using: ${gamename}" echo "Using: ${gamename}"
echo "=================================" echo "================================="
echo ""
requiredstatus="OFFLINE" requiredstatus="OFFLINE"
fn_setstatus fn_setstatus
sleep 1 sleep 1
fn_print_info "Tidying up directories." fn_print_info "Tidying up directories."
sleep 1 sleep 1
rm -rfv ${serverfiles} rm -rfv "${serverfiles}"
echo "END" core_exit.sh

Loading…
Cancel
Save