Browse Source

feat(core): convert ${curlpath} to using curl and improve code standards (#2616)

pull/2617/head
Daniel Gibbs 5 years ago
committed by GitHub
parent
commit
835fdee88e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      lgsm/functions/alert_discord.sh
  2. 2
      lgsm/functions/alert_email.sh
  3. 4
      lgsm/functions/alert_ifttt.sh
  4. 4
      lgsm/functions/alert_mailgun.sh
  5. 4
      lgsm/functions/alert_pushbullet.sh
  6. 4
      lgsm/functions/alert_pushover.sh
  7. 2
      lgsm/functions/alert_slack.sh
  8. 4
      lgsm/functions/alert_telegram.sh
  9. 2
      lgsm/functions/check_config.sh
  10. 8
      lgsm/functions/check_deps.sh
  11. 2
      lgsm/functions/check_executable.sh
  12. 2
      lgsm/functions/check_logs.sh
  13. 11
      lgsm/functions/check_permissions.sh
  14. 2
      lgsm/functions/check_root.sh
  15. 2
      lgsm/functions/check_status.sh
  16. 2
      lgsm/functions/check_system_dir.sh
  17. 2
      lgsm/functions/check_system_requirements.sh
  18. 2
      lgsm/functions/command_backup.sh
  19. 2
      lgsm/functions/command_console.sh
  20. 2
      lgsm/functions/command_debug.sh
  21. 2
      lgsm/functions/command_details.sh
  22. 2
      lgsm/functions/command_dev_debug.sh
  23. 6
      lgsm/functions/command_dev_detect_deps.sh
  24. 4
      lgsm/functions/command_dev_detect_glibc.sh
  25. 4
      lgsm/functions/command_dev_detect_ldd.sh
  26. 2
      lgsm/functions/command_dev_query_raw.sh
  27. 2
      lgsm/functions/command_donate.sh
  28. 18
      lgsm/functions/command_fastdl.sh
  29. 2
      lgsm/functions/command_install.sh
  30. 2
      lgsm/functions/command_install_resources_mta.sh
  31. 2
      lgsm/functions/command_mods_install.sh
  32. 4
      lgsm/functions/command_mods_remove.sh
  33. 10
      lgsm/functions/command_mods_update.sh
  34. 4
      lgsm/functions/command_monitor.sh
  35. 8
      lgsm/functions/command_postdetails.sh
  36. 2
      lgsm/functions/command_restart.sh
  37. 8
      lgsm/functions/command_start.sh
  38. 4
      lgsm/functions/command_stop.sh
  39. 2
      lgsm/functions/command_test_alert.sh
  40. 2
      lgsm/functions/command_ts3_server_pass.sh
  41. 2
      lgsm/functions/command_update.sh
  42. 2
      lgsm/functions/command_update_functions.sh
  43. 17
      lgsm/functions/command_update_linuxgsm.sh
  44. 4
      lgsm/functions/command_validate.sh
  45. 2
      lgsm/functions/command_wipe.sh
  46. 2
      lgsm/functions/compress_unreal2_maps.sh
  47. 2
      lgsm/functions/compress_ut99_maps.sh
  48. 14
      lgsm/functions/core_dl.sh
  49. 250
      lgsm/functions/core_functions.sh
  50. 10
      lgsm/functions/core_getopt.sh
  51. 2
      lgsm/functions/fix_arma3.sh
  52. 2
      lgsm/functions/fix_csgo.sh
  53. 2
      lgsm/functions/fix_dst.sh
  54. 2
      lgsm/functions/fix_kf.sh
  55. 2
      lgsm/functions/fix_kf2.sh
  56. 2
      lgsm/functions/fix_mta.sh
  57. 2
      lgsm/functions/fix_ro.sh
  58. 2
      lgsm/functions/fix_sfc.sh
  59. 2
      lgsm/functions/fix_ss3.sh
  60. 2
      lgsm/functions/fix_steamcmd.sh
  61. 2
      lgsm/functions/fix_terraria.sh
  62. 2
      lgsm/functions/fix_tf2.sh
  63. 2
      lgsm/functions/fix_ts3.sh
  64. 2
      lgsm/functions/fix_ut.sh
  65. 2
      lgsm/functions/fix_ut2k4.sh
  66. 2
      lgsm/functions/fix_ut3.sh
  67. 2
      lgsm/functions/fix_zmr.sh
  68. 16
      lgsm/functions/info_config.sh
  69. 34
      lgsm/functions/info_distro.sh
  70. 2
      lgsm/functions/info_parms.sh
  71. 8
      lgsm/functions/info_stats.sh
  72. 2
      lgsm/functions/install_complete.sh
  73. 2
      lgsm/functions/install_config.sh
  74. 2
      lgsm/functions/install_dst_token.sh
  75. 2
      lgsm/functions/install_gslt.sh
  76. 2
      lgsm/functions/install_header.sh
  77. 14
      lgsm/functions/install_logs.sh
  78. 2
      lgsm/functions/install_mta_resources.sh
  79. 2
      lgsm/functions/install_retry.sh
  80. 2
      lgsm/functions/install_server_dir.sh
  81. 4
      lgsm/functions/install_server_files.sh
  82. 2
      lgsm/functions/install_squad_license.sh
  83. 2
      lgsm/functions/install_stats.sh
  84. 2
      lgsm/functions/install_ts3db.sh
  85. 2
      lgsm/functions/install_ut2k4_key.sh
  86. 2
      lgsm/functions/logs.sh
  87. 26
      lgsm/functions/mods_core.sh
  88. 16
      lgsm/functions/mods_list.sh
  89. 2
      lgsm/functions/query_gamedig.sh
  90. 4
      lgsm/functions/update_factorio.sh
  91. 8
      lgsm/functions/update_minecraft.sh
  92. 8
      lgsm/functions/update_mta.sh
  93. 4
      lgsm/functions/update_mumble.sh
  94. 4
      lgsm/functions/update_steamcmd.sh
  95. 14
      lgsm/functions/update_ts3.sh
  96. 19
      linuxgsm.sh
  97. 19
      tests/tests_fctrserver.sh
  98. 18
      tests/tests_jc2server.sh
  99. 19
      tests/tests_mcserver.sh
  100. 21
      tests/tests_ts3server.sh

6
lgsm/functions/alert_discord.sh

@ -10,8 +10,8 @@ if ! command -v jq > /dev/null; then
fn_script_log_fatal "Sending Discord alert: jq is missing." fn_script_log_fatal "Sending Discord alert: jq is missing."
fi fi
escaped_servername="$(echo -n "${servername}" | jq -sRr "@json")" escaped_servername=$(echo -n "${servername}" | jq -sRr "@json")
escaped_alertbody="$(echo -n "${alertbody}" | jq -sRr "@json")" escaped_alertbody=$(echo -n "${alertbody}" | jq -sRr "@json")
json=$(cat <<EOF json=$(cat <<EOF
{ {
@ -51,7 +51,7 @@ EOF
fn_print_dots "Sending Discord alert" fn_print_dots "Sending Discord alert"
discordsend=$(${curlpath} -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "$json" | jq -c .)" "${discordwebhook}") discordsend=$(curl -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "$json" | jq -c .)" "${discordwebhook}")
if [ -n "${discordsend}" ]; then if [ -n "${discordsend}" ]; then
fn_print_fail_nl "Sending Discord alert: ${discordsend}" fn_print_fail_nl "Sending Discord alert: ${discordsend}"

2
lgsm/functions/alert_email.sh

@ -6,7 +6,7 @@
local commandname="ALERT" local commandname="ALERT"
local commandaction="Alert" local commandaction="Alert"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_print_dots "Sending Email alert: ${email}" fn_print_dots "Sending Email alert: ${email}"
fn_sleep_time fn_sleep_time

4
lgsm/functions/alert_ifttt.sh

@ -6,7 +6,7 @@
local commandname="ALERT" local commandname="ALERT"
local commandaction="Alert" local commandaction="Alert"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
json=$(cat <<EOF json=$(cat <<EOF
{ {
@ -18,7 +18,7 @@ EOF
) )
fn_print_dots "Sending IFTTT alert" fn_print_dots "Sending IFTTT alert"
iftttsend=$(${curlpath} -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://maker.ifttt.com/trigger/${iftttevent}/with/key/${ifttttoken}" | grep "Bad Request") iftttsend=$(curl -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://maker.ifttt.com/trigger/${iftttevent}/with/key/${ifttttoken}" | grep "Bad Request")
if [ -n "${iftttsend}" ]; then if [ -n "${iftttsend}" ]; then
fn_print_fail_nl "Sending IFTTT alert: ${pushbulletsend}" fn_print_fail_nl "Sending IFTTT alert: ${pushbulletsend}"

4
lgsm/functions/alert_mailgun.sh

@ -6,11 +6,11 @@
local commandname="ALERT" local commandname="ALERT"
local commandaction="Alert" local commandaction="Alert"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_print_dots "Sending Email alert: Mailgun: ${email}" fn_print_dots "Sending Email alert: Mailgun: ${email}"
mailgunsend=$(${curlpath} -s --user "api:${mailguntoken}" \ mailgunsend=$(curl -s --user "api:${mailguntoken}" \
-F from="LinuxGSM <${mailgunemailfrom}>" \ -F from="LinuxGSM <${mailgunemailfrom}>" \
-F to="LinuxGSM Admin <${mailgunemail}>" \ -F to="LinuxGSM Admin <${mailgunemail}>" \
-F subject="${alertemoji} ${alertsubject} ${alertemoji}" \ -F subject="${alertemoji} ${alertsubject} ${alertemoji}" \

4
lgsm/functions/alert_pushbullet.sh

@ -6,7 +6,7 @@
local commandname="ALERT" local commandname="ALERT"
local commandaction="Alert" local commandaction="Alert"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
json=$(cat <<EOF json=$(cat <<EOF
{ {
@ -19,7 +19,7 @@ EOF
) )
fn_print_dots "Sending Pushbullet alert" fn_print_dots "Sending Pushbullet alert"
pushbulletsend=$(${curlpath} -sSL -u """${pushbullettoken}"":" -H "Content-Type: application/json" -X POST -d """${json}""" "https://api.pushbullet.com/v2/pushes" | grep "error_code") pushbulletsend=$(curl -sSL -u """${pushbullettoken}"":" -H "Content-Type: application/json" -X POST -d """${json}""" "https://api.pushbullet.com/v2/pushes" | grep "error_code")
if [ -n "${pushbulletsend}" ]; then if [ -n "${pushbulletsend}" ]; then
fn_print_fail_nl "Sending Pushbullet alert: ${pushbulletsend}" fn_print_fail_nl "Sending Pushbullet alert: ${pushbulletsend}"

4
lgsm/functions/alert_pushover.sh

@ -6,7 +6,7 @@
local commandname="ALERT" local commandname="ALERT"
local commandaction="Alert" local commandaction="Alert"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_print_dots "Sending Pushover alert" fn_print_dots "Sending Pushover alert"
@ -23,7 +23,7 @@ else
alertpriority="0" alertpriority="0"
fi fi
pushoversend=$(${curlpath} -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alertemoji} ${alertsubject} ${alertemoji}" -F message=" <b>Message</b><br>${alertbody}<br><br><b>Game</b><br>${gamename}<br><br><b>Server name</b><br>${servername}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>Server IP</b><br><a href='https://www.gametracker.com/server_info/${alertip}:${port}'>${alertip}:${port}</a><br><br><b>More info</b><br><a href='${alerturl}'>${alerturl}</a>" "https://api.pushover.net/1/messages.json" | grep errors) pushoversend=$(curl -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alertemoji} ${alertsubject} ${alertemoji}" -F message=" <b>Message</b><br>${alertbody}<br><br><b>Game</b><br>${gamename}<br><br><b>Server name</b><br>${servername}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>Server IP</b><br><a href='https://www.gametracker.com/server_info/${alertip}:${port}'>${alertip}:${port}</a><br><br><b>More info</b><br><a href='${alerturl}'>${alerturl}</a>" "https://api.pushover.net/1/messages.json" | grep errors)
if [ -n "${pushoversend}" ]; then if [ -n "${pushoversend}" ]; then
fn_print_fail_nl "Sending Pushover alert: ${pushoversend}" fn_print_fail_nl "Sending Pushover alert: ${pushoversend}"

2
lgsm/functions/alert_slack.sh

@ -65,7 +65,7 @@ EOF
fn_print_dots "Sending Slack alert" fn_print_dots "Sending Slack alert"
slacksend=$(${curlpath} -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "$json" | jq -c .)" "${slackwebhook}") slacksend=$(curl -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "$json" | jq -c .)" "${slackwebhook}")
if [ "${slacksend}" == "ok" ]; then if [ "${slacksend}" == "ok" ]; then
fn_print_ok_nl "Sending Slack alert" fn_print_ok_nl "Sending Slack alert"

4
lgsm/functions/alert_telegram.sh

@ -6,7 +6,7 @@
local commandname="ALERT" local commandname="ALERT"
local commandaction="Alert" local commandaction="Alert"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
json=$(cat <<EOF json=$(cat <<EOF
{ {
@ -18,7 +18,7 @@ EOF
) )
fn_print_dots "Sending Telegram alert" fn_print_dots "Sending Telegram alert"
telegramsend=$(${curlpath} -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://api.telegram.org/bot${telegramtoken}/sendMessage" "${curlcustomstring}" | grep "error_code") telegramsend=$(curl -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://api.telegram.org/bot${telegramtoken}/sendMessage" "${curlcustomstring}" | grep "error_code")
if [ -n "${telegramsend}" ]; then if [ -n "${telegramsend}" ]; then
fn_print_fail_nl "Sending Telegram alert: ${telegramsend}" fn_print_fail_nl "Sending Telegram alert: ${telegramsend}"

2
lgsm/functions/check_config.sh

@ -5,7 +5,7 @@
# Description: Checks if the server config is missing and warns the user if needed. # Description: Checks if the server config is missing and warns the user if needed.
local commandname="CHECK" local commandname="CHECK"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
if [ ! -e "${servercfgfullpath}" ]; then if [ ! -e "${servercfgfullpath}" ]; then
if [ "${shortname}" != "hw" ]&&[ "${shortname}" != "ut3" ]&&[ "${shortname}" != "kf2" ]; then if [ "${shortname}" != "hw" ]&&[ "${shortname}" != "ut3" ]&&[ "${shortname}" != "kf2" ]; then

8
lgsm/functions/check_deps.sh

@ -160,7 +160,7 @@ fn_deps_detector(){
depstatus=1 depstatus=1
jquniversemissing=1 jquniversemissing=1
elif [ "${deptocheck}" == "mono-complete" ]; then elif [ "${deptocheck}" == "mono-complete" ]; then
if [ "$(command -v mono 2>/dev/null)" ]&&[ "$(mono --version 2>&1 | grep -Po '(?<=version )\d')" -ge 5 ]; then if [ -n "$(command -v mono 2>/dev/null)" ]&&[ "$(mono --version 2>&1 | grep -Po '(?<=version )\d')" -ge 5 ]; then
# Mono >= 5.0.0 already installed. # Mono >= 5.0.0 already installed.
depstatus=0 depstatus=0
else else
@ -337,7 +337,7 @@ fn_deps_build_debian(){
# LinuxGSM requirements. # LinuxGSM requirements.
array_deps_required=( curl wget ca-certificates file bsdmainutils util-linux python3 tar bzip2 gzip unzip binutils bc jq ) array_deps_required=( curl wget ca-certificates file bsdmainutils util-linux python3 tar bzip2 gzip unzip binutils bc jq )
if [ "$(command -v tmux 2>/dev/null)" ]; then if [ -n "$(command -v tmux 2>/dev/null)" ]; then
tmuxcheck=1 # Added for users compiling tmux from source to bypass check. tmuxcheck=1 # Added for users compiling tmux from source to bypass check.
else else
array_deps_required+=( tmux ) array_deps_required+=( tmux )
@ -402,7 +402,7 @@ fn_deps_build_debian(){
array_deps_required+=( libstdc++5:i386 ) array_deps_required+=( libstdc++5:i386 )
# Project Zomboid # Project Zomboid
elif [ "${shortname}" == "pz" ]; then elif [ "${shortname}" == "pz" ]; then
if [ -n "$(java -version 2>&1 | grep "version")" ]; then if java -version 2>&1 | grep "version"; then
# Added for users using Oracle JRE to bypass the check. # Added for users using Oracle JRE to bypass the check.
javacheck=1 javacheck=1
array_deps_required+=( rng-tools ) array_deps_required+=( rng-tools )
@ -461,7 +461,7 @@ fn_deps_build_redhat(){
fi fi
# All servers except ts3 require tmux. # All servers except ts3 require tmux.
if [ "$(command -v tmux 2>/dev/null)" ]; then if [ -n "$(command -v tmux 2>/dev/null)" ]; then
# Added for users compiling tmux from source to bypass check. # Added for users compiling tmux from source to bypass check.
tmuxcheck=1 tmuxcheck=1
else else

2
lgsm/functions/check_executable.sh

@ -5,7 +5,7 @@
# Description: Checks if server executable exists. # Description: Checks if server executable exists.
local commandname="CHECK" local commandname="CHECK"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
# Check if executable exists # Check if executable exists
if [ ! -f "${executabledir}/${execname}" ]; then if [ ! -f "${executabledir}/${execname}" ]; then

2
lgsm/functions/check_logs.sh

@ -5,7 +5,7 @@
# Description: Checks if log files exist. # Description: Checks if log files exist.
local commandname="CHECK" local commandname="CHECK"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_check_logs(){ fn_check_logs(){
fn_print_dots "Checking for log files" fn_print_dots "Checking for log files"

11
lgsm/functions/check_permissions.sh

@ -74,7 +74,7 @@ fn_check_permissions(){
# Check rootdir permissions. # Check rootdir permissions.
if [ -n "${rootdir}" ]; then if [ -n "${rootdir}" ]; then
# Get permission numbers on directory under the form 775. # Get permission numbers on directory under the form 775.
rootdirperm="$(stat -c %a "${rootdir}")" rootdirperm=$(stat -c %a "${rootdir}")
# Grab the first and second digit for user and group permission. # Grab the first and second digit for user and group permission.
userrootdirperm="${rootdirperm:0:1}" userrootdirperm="${rootdirperm:0:1}"
grouprootdirperm="${rootdirperm:1:1}" grouprootdirperm="${rootdirperm:1:1}"
@ -94,10 +94,10 @@ fn_check_permissions(){
fi fi
# Check if executable is executable and attempt to fix it. # Check if executable is executable and attempt to fix it.
# First get executable name. # First get executable name.
execname="$(basename "${executable}")" execname=$(basename "${executable}")
if [ -f "${executabledir}/${execname}" ]; then if [ -f "${executabledir}/${execname}" ]; then
# Get permission numbers on file under the form 775. # Get permission numbers on file under the form 775.
execperm="$(stat -c %a "${executabledir}/${execname}")" execperm=$(stat -c %a "${executabledir}/${execname}")
# Grab the first and second digit for user and group permission. # Grab the first and second digit for user and group permission.
userexecperm="${execperm:0:1}" userexecperm="${execperm:0:1}"
groupexecperm="${execperm:1:1}" groupexecperm="${execperm:1:1}"
@ -118,7 +118,7 @@ fn_check_permissions(){
chmod u+x,g+x "${executabledir}/${execname}" chmod u+x,g+x "${executabledir}/${execname}"
# Second check to see if it's been successfully applied. # Second check to see if it's been successfully applied.
# Get permission numbers on file under the form 775. # Get permission numbers on file under the form 775.
execperm="$(stat -c %a "${executabledir}/${execname}")" execperm=$(stat -c %a "${executabledir}/${execname}")
# Grab the first and second digit for user and group permission. # Grab the first and second digit for user and group permission.
userexecperm="${execperm:0:1}" userexecperm="${execperm:0:1}"
groupexecperm="${execperm:1:1}" groupexecperm="${execperm:1:1}"
@ -181,8 +181,7 @@ fn_sys_perm_fix_manually_msg(){
# Attempt to fix /sys related permission errors if sudo is available, exits otherwise. # Attempt to fix /sys related permission errors if sudo is available, exits otherwise.
fn_sys_perm_errors_fix(){ fn_sys_perm_errors_fix(){
sudo -n true > /dev/null 2>&1 if sudo -n true > /dev/null 2>&1; then
if [ $? -eq 0 ]; then
fn_print_dots "Automatically fixing /sys permissions" fn_print_dots "Automatically fixing /sys permissions"
fn_script_log_info "Automatically fixing /sys permissions." fn_script_log_info "Automatically fixing /sys permissions."
if [ "${sysdirpermerror}" == "1" ]; then if [ "${sysdirpermerror}" == "1" ]; then

2
lgsm/functions/check_root.sh

@ -5,7 +5,7 @@
# Description: Checks if the user tried to run the script as root. # Description: Checks if the user tried to run the script as root.
local commandname="CHECK" local commandname="CHECK"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
if [ "$(whoami)" = "root" ]; then if [ "$(whoami)" = "root" ]; then
if [ "${function_selfname}" != "command_install.sh" ]; then if [ "${function_selfname}" != "command_install.sh" ]; then

2
lgsm/functions/check_status.sh

@ -6,6 +6,6 @@
# Description: Checks the process status of the server. Either online or offline. # Description: Checks the process status of the server. Either online or offline.
local commandname="CHECK" local commandname="CHECK"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
status=$(tmux list-sessions -F "#{session_name}" 2>/dev/null | grep -Ecx "^${selfname}") status=$(tmux list-sessions -F "#{session_name}" 2>/dev/null | grep -Ecx "^${selfname}")

2
lgsm/functions/check_system_dir.sh

@ -5,7 +5,7 @@
# Description: Checks if systemdir/serverfiles is accessible. # Description: Checks if systemdir/serverfiles is accessible.
local commandname="CHECK" local commandname="CHECK"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
if [ "${function_selfname}" != "command_validate.sh" ]; then if [ "${function_selfname}" != "command_validate.sh" ]; then
checkdir="${serverfiles}" checkdir="${serverfiles}"

2
lgsm/functions/check_system_requirements.sh

@ -6,7 +6,7 @@
# Description: Checks RAM requirements # Description: Checks RAM requirements
local commandname="CHECK" local commandname="CHECK"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
info_distro.sh info_distro.sh

2
lgsm/functions/command_backup.sh

@ -7,7 +7,7 @@
local commandname="BACKUP" local commandname="BACKUP"
local commandaction="Backup" local commandaction="Backup"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
check.sh check.sh

2
lgsm/functions/command_console.sh

@ -6,7 +6,7 @@
local commandname="CONSOLE" local commandname="CONSOLE"
local commandaction="Console" local commandaction="Console"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
check.sh check.sh
fn_print_header fn_print_header

2
lgsm/functions/command_debug.sh

@ -6,7 +6,7 @@
local commandname="DEBUG" local commandname="DEBUG"
local commandaction="Debug" local commandaction="Debug"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
# Trap to remove lockfile on quit. # Trap to remove lockfile on quit.
fn_lockfile_trap(){ fn_lockfile_trap(){

2
lgsm/functions/command_details.sh

@ -7,7 +7,7 @@
local commandname="DETAILS" local commandname="DETAILS"
local commandaction="Details" local commandaction="Details"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
# Run checks and gathers details to display. # Run checks and gathers details to display.
check.sh check.sh

2
lgsm/functions/command_dev_debug.sh

@ -6,7 +6,7 @@
local commandname="DEV-DEBUG" local commandname="DEV-DEBUG"
local commandaction="Dev-Debug" local commandaction="Dev-Debug"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
if [ -f "${rootdir}/.dev-debug" ]; then if [ -f "${rootdir}/.dev-debug" ]; then
rm "${rootdir}/.dev-debug" rm "${rootdir}/.dev-debug"

6
lgsm/functions/command_dev_detect_deps.sh

@ -6,16 +6,16 @@
local commandname="DETECT-DEPS" local commandname="DETECT-DEPS"
local commandaction="Detect-Deps" local commandaction="Detect-Deps"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
echo -e "=================================" echo -e "================================="
echo -e "Dependencies Checker" echo -e "Dependencies Checker"
echo -e "=================================" echo -e "================================="
echo -e "Checking directory: " echo -e "Checking directory: "
echo -e "${serverfiles}" echo -e "${serverfiles}"
if [ "$(command -v eu-readelf 2>/dev/null)" ]; then if [ -n "$(command -v eu-readelf 2>/dev/null)" ]; then
readelf=eu-readelf readelf=eu-readelf
elif [ "$(command -v readelf 2>/dev/null)" ]; then elif [ -n "$(command -v readelf 2>/dev/null)" ]; then
readelf=readelf readelf=readelf
else else
echo -e "readelf/eu-readelf not installed" echo -e "readelf/eu-readelf not installed"

4
lgsm/functions/command_dev_detect_glibc.sh

@ -7,7 +7,7 @@
local commandname="DETECT-GLIBC" local commandname="DETECT-GLIBC"
local commandaction="Detect-Glibc" local commandaction="Detect-Glibc"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
echo -e "=================================" echo -e "================================="
echo -e "glibc Requirements Checker" echo -e "glibc Requirements Checker"
@ -20,7 +20,7 @@ if [ -z "$(command -v objdump)" ]; then
fi fi
if [ -z "${serverfiles}" ]; then if [ -z "${serverfiles}" ]; then
dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" dir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
fi fi
if [ -d "${serverfiles}" ]; then if [ -d "${serverfiles}" ]; then

4
lgsm/functions/command_dev_detect_ldd.sh

@ -7,14 +7,14 @@
local commandname="DETECT-LDD" local commandname="DETECT-LDD"
local commandaction="Detect-LDD" local commandaction="Detect-LDD"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
echo -e "=================================" echo -e "================================="
echo -e "Shared Object dependencies Checker" echo -e "Shared Object dependencies Checker"
echo -e "=================================" echo -e "================================="
if [ -z "${serverfiles}" ]; then if [ -z "${serverfiles}" ]; then
dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" dir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
fi fi
if [ -d "${serverfiles}" ]; then if [ -d "${serverfiles}" ]; then

2
lgsm/functions/command_dev_query_raw.sh

@ -6,7 +6,7 @@
local commandname="QUERY-RAW" local commandname="QUERY-RAW"
local commandaction="Query Raw" local commandaction="Query Raw"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
echo -e "" echo -e ""
echo -e "Query Port - Raw Output" echo -e "Query Port - Raw Output"

2
lgsm/functions/command_donate.sh

@ -6,7 +6,7 @@
local commandname="CONSOLE" local commandname="CONSOLE"
local commandaction="Console" local commandaction="Console"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_print_ascii_logo fn_print_ascii_logo
echo -e "${lightyellow}Support LinuxGSM${default}" echo -e "${lightyellow}Support LinuxGSM${default}"

18
lgsm/functions/command_fastdl.sh

@ -7,7 +7,7 @@
local commandname="FASTDL" local commandname="FASTDL"
local commandaction="FastDL" local commandaction="FastDL"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
check.sh check.sh
@ -135,7 +135,7 @@ fn_human_readable_file_size(){
local factor="${item%:*}" local factor="${item%:*}"
local abbrev="${item#*:}" local abbrev="${item#*:}"
if [[ "${bytes}" -ge "${factor}" ]]; then if [[ "${bytes}" -ge "${factor}" ]]; then
local size="$(bc -l <<< "${bytes} / ${factor}")" local size=$(bc -l <<< "${bytes} / ${factor}")
printf "%.*f %s\n" "${precision}" "${size}" "${abbrev}" printf "%.*f %s\n" "${precision}" "${size}" "${abbrev}"
break break
fi fi
@ -161,9 +161,9 @@ fn_fastdl_preview(){
while read -r ext; do while read -r ext; do
((fileswc++)) ((fileswc++))
tput rc; tput el tput rc; tput el
printf "gathering ${allowed_extention} : ${fileswc}..." echo -e "gathering ${allowed_extention} : ${fileswc}..."
echo -e "${ext}" >> "${tmpdir}/fastdl_files_to_compress.txt" echo -e "${ext}" >> "${tmpdir}/fastdl_files_to_compress.txt"
done < <(find . -type f -iname ${allowed_extention}) done < <(find . -type f -iname "${allowed_extention}")
if [ ${fileswc} != 0 ]; then if [ ${fileswc} != 0 ]; then
fn_print_ok_eol_nl fn_print_ok_eol_nl
else else
@ -192,7 +192,7 @@ fn_fastdl_preview(){
while read -r ext; do while read -r ext; do
((fileswc++)) ((fileswc++))
tput rc; tput el tput rc; tput el
printf "gathering ${directory} ${allowed_extention} : ${fileswc}..." echo -e "gathering ${directory} ${allowed_extention} : ${fileswc}..."
echo -e "${ext}" >> "${tmpdir}/fastdl_files_to_compress.txt" echo -e "${ext}" >> "${tmpdir}/fastdl_files_to_compress.txt"
done < <(find "${systemdir}/${directory}" -type f -iname ${allowed_extention}) done < <(find "${systemdir}/${directory}" -type f -iname ${allowed_extention})
tput rc; tput el tput rc; tput el
@ -305,9 +305,9 @@ fn_fastdl_gmod(){
if [ -f "${tmpdir}/fastdl_files_to_compress.txt" ]; then if [ -f "${tmpdir}/fastdl_files_to_compress.txt" ]; then
totalfiles=$(wc -l < "${tmpdir}/fastdl_files_to_compress.txt") totalfiles=$(wc -l < "${tmpdir}/fastdl_files_to_compress.txt")
# Calculates total file size. # Calculates total file size.
while read dufile; do while read -r dufile; do
filesize=$(du -b "${dufile}" | awk '{ print $1 }') filesize=$(du -b "${dufile}" | awk '{ print $1 }')
filesizetotal=$(( ${filesizetotal} + ${filesize} )) filesizetotal=$((filesizetotal + filesize))
done <"${tmpdir}/fastdl_files_to_compress.txt" done <"${tmpdir}/fastdl_files_to_compress.txt"
fi fi
} }
@ -334,7 +334,7 @@ fn_fastdl_source(){
while read -r fastdlfile; do while read -r fastdlfile; do
((fileswc++)) ((fileswc++))
tput rc; tput el tput rc; tput el
printf "copying ${directory} ${allowed_extention} : ${fileswc}..." echo -e "copying ${directory} ${allowed_extention} : ${fileswc}..."
fn_sleep_time fn_sleep_time
# get relative path of file in the dir # get relative path of file in the dir
tmprelfilepath="${fastdlfile#"${systemdir}/"}" tmprelfilepath="${fastdlfile#"${systemdir}/"}"
@ -352,7 +352,7 @@ fn_fastdl_source(){
else else
fn_script_log_pass "Copying ${fastdlfile} > ${fastdldir}/${copytodir}" fn_script_log_pass "Copying ${fastdlfile} > ${fastdldir}/${copytodir}"
fi fi
done < <(find "${systemdir}/${directory}" -type f -iname ${allowed_extention}) done < <(find "${systemdir}/${directory}" -type f -iname "${allowed_extention}")
if [ ${fileswc} != 0 ]; then if [ ${fileswc} != 0 ]; then
fn_print_ok_eol_nl fn_print_ok_eol_nl
fi fi

2
lgsm/functions/command_install.sh

@ -7,7 +7,7 @@
local commandname="INSTALL" local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
check.sh check.sh
if [ "$(whoami)" = "root" ]; then if [ "$(whoami)" = "root" ]; then

2
lgsm/functions/command_install_resources_mta.sh

@ -6,7 +6,7 @@
local commandname="DEFAULT_RESOURCES" local commandname="DEFAULT_RESOURCES"
local commandaction="Default Resources" local commandaction="Default Resources"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_install_resources(){ fn_install_resources(){
echo -e "" echo -e ""

2
lgsm/functions/command_mods_install.sh

@ -7,7 +7,7 @@
local commandname="MODS" local commandname="MODS"
local commandaction="addons/mods" local commandaction="addons/mods"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
check.sh check.sh
mods_core.sh mods_core.sh

4
lgsm/functions/command_mods_remove.sh

@ -7,7 +7,7 @@
local commandname="MODS" local commandname="MODS"
local commandaction="Mods Remove" local commandaction="Mods Remove"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
check.sh check.sh
mods_core.sh mods_core.sh
@ -64,7 +64,7 @@ modfileline="1"
tput sc tput sc
while [ "${modfileline}" -le "${modsfilelistsize}" ]; do while [ "${modfileline}" -le "${modsfilelistsize}" ]; do
# Current line defines current file to remove. # Current line defines current file to remove.
currentfileremove="$(sed "${modfileline}q;d" "${modsdir}/${modcommand}-files.txt")" currentfileremove=$(sed "${modfileline}q;d" "${modsdir}/${modcommand}-files.txt")
# If file or directory exists, then remove it. # If file or directory exists, then remove it.
if [ -f "${modinstalldir}/${currentfileremove}" ]||[ -d "${modinstalldir}/${currentfileremove}" ]; then if [ -f "${modinstalldir}/${currentfileremove}" ]||[ -d "${modinstalldir}/${currentfileremove}" ]; then

10
lgsm/functions/command_mods_update.sh

@ -7,7 +7,7 @@
local commandname="MODS" local commandname="MODS"
local commandaction="Mods Update" local commandaction="Mods Update"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
check.sh check.sh
mods_core.sh mods_core.sh
@ -19,11 +19,11 @@ fn_remove_cfg_files(){
echo -e "the following files/directories will be preserved:" echo -e "the following files/directories will be preserved:"
fn_sleep_time fn_sleep_time
# Count how many files there are to remove. # Count how many files there are to remove.
filestopreserve="$(echo -e "${modkeepfiles}" | awk -F ';' '{ print NF }')" filestopreserve=$(echo -e "${modkeepfiles}" | awk -F ';' '{ print NF }')
# Test all subvalues of "modkeepfiles" using the ";" separator. # Test all subvalues of "modkeepfiles" using the ";" separator.
for ((preservefilesindex=1; preservefilesindex < ${filestopreserve}; preservefilesindex++)); do for ((preservefilesindex=1; preservefilesindex < filestopreserve; preservefilesindex++)); do
# Put the current file we are looking for into a variable. # Put the current file we are looking for into a variable.
filetopreserve="$(echo -e "${modkeepfiles}" | awk -F ';' -v x=${preservefilesindex} '{ print $x }' )" filetopreserve=$(echo -e "${modkeepfiles}" | awk -F ';' -v x=${preservefilesindex} '{ print $x }' )
echo -e " * serverfiles/${filetopreserve}" echo -e " * serverfiles/${filetopreserve}"
# If it matches an existing file that have been extracted delete the file. # If it matches an existing file that have been extracted delete the file.
if [ -f "${extractdir}/${filetopreserve}" ]||[ -d "${extractdir}/${filetopreserve}" ]; then if [ -f "${extractdir}/${filetopreserve}" ]||[ -d "${extractdir}/${filetopreserve}" ]; then
@ -71,7 +71,7 @@ done
# Reset line value. # Reset line value.
installedmodsline="1" installedmodsline="1"
while [ "${installedmodsline}" -le "${installedmodscount}" ]; do while [ "${installedmodsline}" -le "${installedmodscount}" ]; do
currentmod="$(sed "${installedmodsline}q;d" "${modsinstalledlistfullpath}")" currentmod=$(sed "${installedmodsline}q;d" "${modsinstalledlistfullpath}")
if [ -n "${currentmod}" ]; then if [ -n "${currentmod}" ]; then
fn_mod_get_info fn_mod_get_info
# Don not update mod if the policy is set to "NOUPDATE". # Don not update mod if the policy is set to "NOUPDATE".

4
lgsm/functions/command_monitor.sh

@ -8,7 +8,7 @@
local commandname="MONITOR" local commandname="MONITOR"
local commandaction="Monitor" local commandaction="Monitor"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" 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.
@ -211,7 +211,7 @@ fn_monitor_loop(){
do do
# Will check if gamedig is installed and bypass if not. # Will check if gamedig is installed and bypass if not.
if [ "${querymethod}" == "gamedig" ]; then if [ "${querymethod}" == "gamedig" ]; then
if [ "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ]; then if [ -n "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ]; then
if [ -z "${monitorpass}" ]; then if [ -z "${monitorpass}" ]; then
fn_monitor_query fn_monitor_query
fi fi

8
lgsm/functions/command_postdetails.sh

@ -7,7 +7,7 @@
local commandname="POSTDETAILS" local commandname="POSTDETAILS"
local commandaction="Postdetails" local commandaction="Postdetails"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
# Set posttarget to the appropriately-defined post destination. # Set posttarget to the appropriately-defined post destination.
@ -80,12 +80,12 @@ fi
if [ "${posttarget}" == "http://pastebin.com" ] ; then if [ "${posttarget}" == "http://pastebin.com" ] ; then
fn_print_dots "Posting details to pastbin.com for ${postexpire}" fn_print_dots "Posting details to pastbin.com for ${postexpire}"
# grab the return from 'value' from an initial visit to pastebin. # grab the return from 'value' from an initial visit to pastebin.
csrftoken=$(${curlpath} -s "${posttarget}" | csrftoken=$(curl -s "${posttarget}" |
sed -n 's/^.*input type="hidden" name="csrf_token_post" value="\(.*\)".*$/\1/p') sed -n 's/^.*input type="hidden" name="csrf_token_post" value="\(.*\)".*$/\1/p')
# #
# Use the csrftoken to then post the content. # Use the csrftoken to then post the content.
# #
link=$(${curlpath} -s "${posttarget}/post.php" -D - -F "submit_hidden=submit_hidden" \ link=$(curl -s "${posttarget}/post.php" -D - -F "submit_hidden=submit_hidden" \
-F "post_key=${csrftoken}" -F "paste_expire_date=${postexpire}" \ -F "post_key=${csrftoken}" -F "paste_expire_date=${postexpire}" \
-F "paste_name=${gamename} Debug Info" \ -F "paste_name=${gamename} Debug Info" \
-F "paste_format=8" -F "paste_private=0" \ -F "paste_format=8" -F "paste_private=0" \
@ -101,7 +101,7 @@ elif [ "${posttarget}" == "https://hastebin.com" ] ; then
# hastebin is a bit simpler. If successful, the returned result # hastebin is a bit simpler. If successful, the returned result
# should look like: {"something":"key"}, putting the reference that # should look like: {"something":"key"}, putting the reference that
# we need in "key". TODO - error handling. -CedarLUG # we need in "key". TODO - error handling. -CedarLUG
link=$(${curlpath} -H "HTTP_X_REQUESTED_WITH:XMLHttpRequest" -s -d "$(<${postdetailslog})" "${posttarget}/documents" | cut -d\" -f4) link=$(curl -H "HTTP_X_REQUESTED_WITH:XMLHttpRequest" -s -d "$(<${postdetailslog})" "${posttarget}/documents" | cut -d\" -f4)
fn_print_ok_nl "Posting details to hastebin.com for ${postexpire}" fn_print_ok_nl "Posting details to hastebin.com for ${postexpire}"
pdurl="${posttarget}/${link}" pdurl="${posttarget}/${link}"
echo -e "Please share the following url for support: ${pdurl}" echo -e "Please share the following url for support: ${pdurl}"

2
lgsm/functions/command_restart.sh

@ -6,7 +6,7 @@
local commandname="RESTART" local commandname="RESTART"
local commandaction="Restarting" local commandaction="Restarting"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
info_config.sh info_config.sh
exitbypass=1 exitbypass=1

8
lgsm/functions/command_start.sh

@ -7,7 +7,7 @@
local commandname="START" local commandname="START"
local commandaction="Starting" local commandaction="Starting"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_start_teamspeak3(){ fn_start_teamspeak3(){
if [ ! -e "${servercfgfullpath}" ]; then if [ ! -e "${servercfgfullpath}" ]; then
@ -70,7 +70,7 @@ fn_start_tmux(){
touch "${consolelog}" touch "${consolelog}"
# Get tmux version. # Get tmux version.
tmuxversion="$(tmux -V | sed "s/tmux //" | sed -n '1 p')" tmuxversion=$(tmux -V | sed "s/tmux //" | sed -n '1 p')
# Tmux compiled from source will return "master", therefore ignore it. # Tmux compiled from source will return "master", therefore ignore it.
if [ "$(tmux -V | sed "s/tmux //" | sed -n '1 p')" == "master" ]; then if [ "$(tmux -V | sed "s/tmux //" | sed -n '1 p')" == "master" ]; then
fn_script_log "Tmux version: master (user compiled)" fn_script_log "Tmux version: master (user compiled)"
@ -80,7 +80,7 @@ fn_start_tmux(){
fi fi
elif [ -n "${tmuxversion}" ]; then elif [ -n "${tmuxversion}" ]; then
# Get the digit version of tmux. # Get the digit version of tmux.
tmuxversion="$(tmux -V | sed "s/tmux //" | sed -n '1 p' | tr -cd '[:digit:]')" tmuxversion=$(tmux -V | sed "s/tmux //" | sed -n '1 p' | tr -cd '[:digit:]')
# tmux pipe-pane not supported in tmux versions < 1.6. # tmux pipe-pane not supported in tmux versions < 1.6.
if [ "${tmuxversion}" -lt "16" ]; then if [ "${tmuxversion}" -lt "16" ]; then
echo -e "Console logging disabled: Tmux => 1.6 required echo -e "Console logging disabled: Tmux => 1.6 required
@ -131,7 +131,7 @@ fn_sleep_time
echo -e "" echo -e ""
echo -e "Fix" echo -e "Fix"
echo -e "=================================" echo -e "================================="
if [ ! "$(grep "tty:" /etc/group|grep "$(whoami)")" ]; then if ! grep "tty:" /etc/group | grep "$(whoami)"; then
echo -e "$(whoami) is not part of the tty group." echo -e "$(whoami) is not part of the tty group."
fn_script_log_info "$(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)

4
lgsm/functions/command_stop.sh

@ -7,7 +7,7 @@
local commandname="STOP" local commandname="STOP"
local commandaction="Stopping" local commandaction="Stopping"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
# Attempts graceful shutdown by sending 'CTRL+c'. # Attempts graceful shutdown by sending 'CTRL+c'.
fn_stop_graceful_ctrlc(){ fn_stop_graceful_ctrlc(){
@ -126,7 +126,7 @@ fn_stop_graceful_sdtd(){
fn_script_log_info "Graceful: telnet" fn_script_log_info "Graceful: telnet"
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}"
elif [ "$(command -v expect 2>/dev/null)" ]; then elif [ -n "$(command -v expect 2>/dev/null)" ]; then
# 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}:${telnetport}" fn_print_dots "Graceful: telnet: ${telnetip}:${telnetport}"

2
lgsm/functions/command_test_alert.sh

@ -6,7 +6,7 @@
local commandname="ALERT" local commandname="ALERT"
local commandaction="Alert" local commandaction="Alert"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_print_dots "${servername}" fn_print_dots "${servername}"
check.sh check.sh

2
lgsm/functions/command_ts3_server_pass.sh

@ -7,7 +7,7 @@
local commandname="PASSWORD-CHANGE" local commandname="PASSWORD-CHANGE"
local commandaction="Password Change" local commandaction="Password Change"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_serveradmin_password_prompt(){ fn_serveradmin_password_prompt(){
fn_print_header fn_print_header

2
lgsm/functions/command_update.sh

@ -6,7 +6,7 @@
local commandname="UPDATE" local commandname="UPDATE"
local commandaction="Update" local commandaction="Update"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_print_dots "" fn_print_dots ""
check.sh check.sh

2
lgsm/functions/command_update_functions.sh

@ -6,7 +6,7 @@
# Legacy Command # Legacy Command
command_update_linuxgsm.sh(){ command_update_linuxgsm.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }

17
lgsm/functions/command_update_linuxgsm.sh

@ -6,7 +6,7 @@
local commandname="UPDATE LINUXGSM" local commandname="UPDATE LINUXGSM"
local commandaction="Update LinuxGSM" local commandaction="Update LinuxGSM"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_print_dots "Updating LinuxGSM" fn_print_dots "Updating LinuxGSM"
check.sh check.sh
@ -16,7 +16,7 @@ echo -en "\n"
if [ -z "${legacymode}" ]; then if [ -z "${legacymode}" ]; then
# Check and update _default.cfg. # Check and update _default.cfg.
echo -en " checking config _default.cfg...\c" echo -en " checking config _default.cfg...\c"
config_file_diff=$(diff "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" <(${curlpath} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg")) config_file_diff=$(diff "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" <(curl -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/config-default/config-lgsm/${gameservername}/_default.cfg"))
if [ "${config_file_diff}" != "" ]; then if [ "${config_file_diff}" != "" ]; then
fn_print_update_eol_nl fn_print_update_eol_nl
fn_script_log_info "checking config _default.cfg: UPDATE" fn_script_log_info "checking config _default.cfg: UPDATE"
@ -30,7 +30,7 @@ if [ -z "${legacymode}" ]; then
fi fi
echo -en " checking linuxgsm.sh...\c" echo -en " checking linuxgsm.sh...\c"
tmp_script_diff=$(diff "${tmpdir}/linuxgsm.sh" <(${curlpath} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh")) tmp_script_diff=$(diff "${tmpdir}/linuxgsm.sh" <(curl -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/linuxgsm.sh"))
if [ "${tmp_script_diff}" != "" ]; then if [ "${tmp_script_diff}" != "" ]; then
fn_print_update_eol_nl fn_print_update_eol_nl
fn_script_log_info "checking linuxgsm.sh: UPDATE" fn_script_log_info "checking linuxgsm.sh: UPDATE"
@ -56,11 +56,13 @@ if [ -z "${legacymode}" ]; then
echo -e " Backup: ${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak" echo -e " Backup: ${backupdir}/script/${selfname}-$(date +"%m_%d_%Y_%M").bak"
fi fi
echo -en " fetching ${selfname}...\c" echo -en " fetching ${selfname}...\c"
exitcode=$?
cp "${tmpdir}/linuxgsm.sh" "${rootdir}/${selfname}" cp "${tmpdir}/linuxgsm.sh" "${rootdir}/${selfname}"
sed -i "s/shortname=\"core\"/shortname=\"${shortname}\"/g" "${rootdir}/${selfname}" sed -i "s/shortname=\"core\"/shortname=\"${shortname}\"/g" "${rootdir}/${selfname}"
sed -i "s/gameservername=\"core\"/gameservername=\"${gameservername}\"/g" "${rootdir}/${selfname}" sed -i "s/gameservername=\"core\"/gameservername=\"${gameservername}\"/g" "${rootdir}/${selfname}"
sed -i "s/gamename=\"core\"/gamename=\"${gamename}\"/g" "${rootdir}/${selfname}" sed -i "s/gamename=\"core\"/gamename=\"${gamename}\"/g" "${rootdir}/${selfname}"
if [ $? -ne 0 ]; then
if [ "${exitcode}" == "0" ]; then
fn_print_fail_eol_nl fn_print_fail_eol_nl
core_exit.sh core_exit.sh
else else
@ -79,15 +81,14 @@ if [ -n "${functionsdir}" ]; then
do do
echo -en " checking function ${functionfile}...\c" echo -en " checking function ${functionfile}...\c"
github_file_url_dir="lgsm/functions" github_file_url_dir="lgsm/functions"
get_function_file=$(${curlpath} --fail -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}") get_function_file=$(curl --fail -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")
exitcode=$? exitcode=$?
function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlpath} --fail -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) function_file_diff=$(diff "${functionsdir}/${functionfile}" <(curl --fail -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}"))
if [ ${exitcode} -ne 0 ]; then if [ ${exitcode} -ne 0 ]; then
fn_print_fail_eol_nl fn_print_fail_eol_nl
echo -en " removing unknown function ${functionfile}...\c" echo -en " removing unknown function ${functionfile}...\c"
fn_script_log_fatal "removing unknown function ${functionfile}" fn_script_log_fatal "removing unknown function ${functionfile}"
rm -f "${functionfile}" if ! rm -f "${functionfile}"; then
if [ $? -ne 0 ]; then
fn_print_fail_eol_nl fn_print_fail_eol_nl
core_exit.sh core_exit.sh
else else

4
lgsm/functions/command_validate.sh

@ -6,7 +6,7 @@
local commandname="VALIDATE" local commandname="VALIDATE"
local commandaction="Validate" local commandaction="Validate"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_validation(){ fn_validation(){
fn_print_info "Validating files: SteamCMD" fn_print_info "Validating files: SteamCMD"
@ -18,7 +18,7 @@ fn_validation(){
cd "${steamcmddir}" || exit cd "${steamcmddir}" || exit
# Detects if unbuffer command is available for 32 bit distributions only. # Detects if unbuffer command is available for 32 bit distributions only.
info_distro.sh info_distro.sh
if [ "$(command -v stdbuf)" ]&&[ "${arch}" != "x86_64" ]; then if [ -n "$(command -v stdbuf)" ]&&[ "${arch}" != "x86_64" ]; then
unbuffer="stdbuf -i0 -o0 -e0" unbuffer="stdbuf -i0 -o0 -e0"
fi fi

2
lgsm/functions/command_wipe.sh

@ -7,7 +7,7 @@
local commandname="WIPE" local commandname="WIPE"
local commandaction="Wipe" local commandaction="Wipe"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
check.sh check.sh
fn_print_header fn_print_header

2
lgsm/functions/compress_unreal2_maps.sh

@ -5,7 +5,7 @@
# Description: Compresses unreal maps. # Description: Compresses unreal maps.
local commandaction="Unreal Map Compressor" local commandaction="Unreal Map Compressor"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
check.sh check.sh
fn_print_header fn_print_header

2
lgsm/functions/compress_ut99_maps.sh

@ -5,7 +5,7 @@
# Description: Compresses unreal maps. # Description: Compresses unreal maps.
local commandaction="Unreal Map Compressor" local commandaction="Unreal Map Compressor"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
check.sh check.sh
fn_print_header fn_print_header

14
lgsm/functions/core_dl.sh

@ -19,7 +19,7 @@
local commandname="DOWNLOAD" local commandname="DOWNLOAD"
local commandaction="Download" local commandaction="Download"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
# Emptys contents of the LinuxGSM tmpdir. # Emptys contents of the LinuxGSM tmpdir.
fn_clear_tmp(){ fn_clear_tmp(){
@ -133,11 +133,11 @@ fn_fetch_file(){
echo -en "downloading ${local_filename}..." echo -en "downloading ${local_filename}..."
fn_sleep_time fn_sleep_time
echo -en "\033[1K" echo -en "\033[1K"
curlcmd=$(${curlpath} --progress-bar --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}") curlcmd=$(curl --progress-bar --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}")
echo -en "downloading ${local_filename}..." echo -en "downloading ${local_filename}..."
else else
echo -en " fetching ${local_filename}...\c" echo -en " fetching ${local_filename}...\c"
curlcmd=$(${curlpath} -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1) curlcmd=$(curl -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1)
fi fi
local exitcode=$? local exitcode=$?
if [ ${exitcode} -ne 0 ]; then if [ ${exitcode} -ne 0 ]; then
@ -168,7 +168,7 @@ fn_fetch_file(){
fn_dl_md5 fn_dl_md5
# Execute file if run is set. # Execute file if run is set.
if [ "${run}" == "run" ]; then if [ "${run}" == "run" ]; then
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "${local_filedir}/${local_filename}" source "${local_filedir}/${local_filename}"
fi fi
fi fi
@ -255,10 +255,8 @@ fn_update_function(){
fn_fetch_file "${remote_fileurl}" "${local_filedir}" "${local_filename}" "${chmodx}" "${run}" "${forcedl}" "${md5}" fn_fetch_file "${remote_fileurl}" "${local_filedir}" "${local_filename}" "${chmodx}" "${run}" "${forcedl}" "${md5}"
} }
# Defines curl path. # Check that curl is installed
curlpath=$(command -v curl 2>/dev/null) if [ -z "$(command -v curl 2>/dev/null)" ]; then
if [ "$(basename "${curlpath}")" != "curl" ]; then
echo -e "[ FAIL ] Curl is not installed" echo -e "[ FAIL ] Curl is not installed"
exit 1 exit 1
fi fi

250
lgsm/functions/core_functions.sh

@ -8,7 +8,7 @@
# Core # Core
core_dl.sh(){ core_dl.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
if [ "$(type fn_fetch_core_dl 2>/dev/null)" ]; then if [ "$(type fn_fetch_core_dl 2>/dev/null)" ]; then
fn_fetch_core_dl "lgsm/functions" "core_dl.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5" fn_fetch_core_dl "lgsm/functions" "core_dl.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5"
else else
@ -17,7 +17,7 @@ fi
} }
core_messages.sh(){ core_messages.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
if [ "$(type fn_fetch_core_dl 2>/dev/null)" ]; then if [ "$(type fn_fetch_core_dl 2>/dev/null)" ]; then
fn_fetch_core_dl "lgsm/functions" "core_messages.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5" fn_fetch_core_dl "lgsm/functions" "core_messages.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5"
else else
@ -26,7 +26,7 @@ fi
} }
core_legacy.sh(){ core_legacy.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
if [ "$(type fn_fetch_core_dl 2>/dev/null)" ]; then if [ "$(type fn_fetch_core_dl 2>/dev/null)" ]; then
fn_fetch_core_dl "lgsm/functions" "core_legacy.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5" fn_fetch_core_dl "lgsm/functions" "core_legacy.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5"
else else
@ -35,538 +35,538 @@ fi
} }
core_exit.sh(){ core_exit.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
core_getopt.sh(){ core_getopt.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
core_trap.sh(){ core_trap.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
# Commands # Commands
command_backup.sh(){ command_backup.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_console.sh(){ command_console.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_debug.sh(){ command_debug.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_details.sh(){ command_details.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_donate.sh(){ command_donate.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_postdetails.sh(){ command_postdetails.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_test_alert.sh(){ command_test_alert.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_monitor.sh(){ command_monitor.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_start.sh(){ command_start.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_stop.sh(){ command_stop.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_validate.sh(){ command_validate.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_install.sh(){ command_install.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_install_resources_mta.sh(){ command_install_resources_mta.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_squad_license.sh(){ install_squad_license.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_mods_install.sh(){ command_mods_install.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_mods_update.sh(){ command_mods_update.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_mods_remove.sh(){ command_mods_remove.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_fastdl.sh(){ command_fastdl.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_ts3_server_pass.sh(){ command_ts3_server_pass.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_restart.sh(){ command_restart.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_wipe.sh(){ command_wipe.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
# Checks # Checks
check.sh(){ check.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
check_config.sh(){ check_config.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
check_deps.sh(){ check_deps.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
check_executable.sh(){ check_executable.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
check_glibc.sh(){ check_glibc.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
check_ip.sh(){ check_ip.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
check_logs.sh(){ check_logs.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
check_permissions.sh(){ check_permissions.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
check_root.sh(){ check_root.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
check_status.sh(){ check_status.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
check_steamcmd.sh(){ check_steamcmd.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
check_system_dir.sh(){ check_system_dir.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
check_system_requirements.sh(){ check_system_requirements.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
check_tmuxception.sh(){ check_tmuxception.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
# Compress # Compress
compress_unreal2_maps.sh(){ compress_unreal2_maps.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
compress_ut99_maps.sh(){ compress_ut99_maps.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
# Mods # Mods
mods_list.sh(){ mods_list.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
mods_core.sh(){ mods_core.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
# Dev # Dev
command_dev_clear_functions.sh(){ command_dev_clear_functions.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_dev_debug.sh(){ command_dev_debug.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_dev_detect_deps.sh(){ command_dev_detect_deps.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_dev_detect_glibc.sh(){ command_dev_detect_glibc.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_dev_detect_ldd.sh(){ command_dev_detect_ldd.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_dev_query_raw.sh(){ command_dev_query_raw.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
# Fix # Fix
fix.sh(){ fix.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_ark.sh(){ fix_ark.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_arma3.sh(){ fix_arma3.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_csgo.sh(){ fix_csgo.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_dst.sh(){ fix_dst.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_ges.sh(){ fix_ges.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_ins.sh(){ fix_ins.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_kf.sh(){ fix_kf.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_kf2.sh(){ fix_kf2.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_mta.sh(){ fix_mta.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_ro.sh(){ fix_ro.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_rust.sh(){ fix_rust.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_rw.sh(){ fix_rw.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_sfc.sh(){ fix_sfc.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_steamcmd.sh(){ fix_steamcmd.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_terraria.sh(){ fix_terraria.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_tf2.sh(){ fix_tf2.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_ut3.sh(){ fix_ut3.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_rust.sh(){ fix_rust.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_sdtd.sh(){ fix_sdtd.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_sof2.sh(){ fix_sof2.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_ss3.sh(){ fix_ss3.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_ts3.sh(){ fix_ts3.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_ut2k4.sh(){ fix_ut2k4.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_ut.sh(){ fix_ut.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_unt.sh(){ fix_unt.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_wurm.sh(){ fix_wurm.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fix_zmr.sh(){ fix_zmr.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
# Info # Info
info_stats.sh(){ info_stats.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
info_config.sh(){ info_config.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
info_distro.sh(){ info_distro.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
info_gamedig.sh(){ info_gamedig.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
info_messages.sh(){ info_messages.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
info_parms.sh(){ info_parms.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
# Alert # Alert
alert.sh(){ alert.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
alert_discord.sh(){ alert_discord.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
alert_email.sh(){ alert_email.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
alert_ifttt.sh(){ alert_ifttt.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
alert_mailgun.sh(){ alert_mailgun.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
alert_pushbullet.sh(){ alert_pushbullet.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
alert_pushover.sh(){ alert_pushover.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
alert_telegram.sh(){ alert_telegram.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
alert_slack.sh(){ alert_slack.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
# Logs # Logs
logs.sh(){ logs.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
# Query # Query
query_gamedig.sh(){ query_gamedig.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
# Update # Update
command_update_functions.sh(){ command_update_functions.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_update_linuxgsm.sh(){ command_update_linuxgsm.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
command_update.sh(){ command_update.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
update_ts3.sh(){ update_ts3.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
update_minecraft.sh(){ update_minecraft.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
update_mumble.sh(){ update_mumble.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
update_mta.sh(){ update_mta.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
update_factorio.sh(){ update_factorio.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
update_steamcmd.sh(){ update_steamcmd.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
fn_update_functions.sh(){ fn_update_functions.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
@ -580,96 +580,96 @@ command_install.sh
} }
install_complete.sh(){ install_complete.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_config.sh(){ install_config.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_factorio_save.sh(){ install_factorio_save.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_dst_token.sh(){ install_dst_token.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_eula.sh(){ install_eula.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_gsquery.sh(){ install_gsquery.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_gslt.sh(){ install_gslt.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_header.sh(){ install_header.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_logs.sh(){ install_logs.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_retry.sh(){ install_retry.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_server_dir.sh(){ install_server_dir.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_server_files.sh(){ install_server_files.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_stats.sh(){ install_stats.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_steamcmd.sh(){ install_steamcmd.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_ts3.sh(){ install_ts3.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_ts3db.sh(){ install_ts3db.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_ut2k4.sh(){ install_ut2k4.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_dl_ut2k4.sh(){ install_dl_ut2k4.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }
install_ut2k4_key.sh(){ install_ut2k4_key.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_fetch_function fn_fetch_function
} }

10
lgsm/functions/core_getopt.sh

@ -4,7 +4,7 @@
# Website: https://linuxgsm.com # Website: https://linuxgsm.com
# Description: getopt arguments. # Description: getopt arguments.
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
### Define all commands here. ### Define all commands here.
## User commands | Trigger commands | Description ## User commands | Trigger commands | Description
@ -143,8 +143,8 @@ currentopt+=( "${cmd_donate[@]}" )
optcommands=() optcommands=()
index="0" index="0"
for ((index="0"; index < ${#currentopt[@]}; index+=3)); do for ((index="0"; index < ${#currentopt[@]}; index+=3)); do
cmdamount="$(echo -e "${currentopt[index]}" | awk -F ';' '{ print NF }')" cmdamount=$(echo -e "${currentopt[index]}" | awk -F ';' '{ print NF }')
for ((cmdindex=1; cmdindex <= ${cmdamount}; cmdindex++)); do for ((cmdindex=1; cmdindex <= cmdamount; cmdindex++)); do
optcommands+=( "$(echo -e "${currentopt[index]}" | awk -F ';' -v x=${cmdindex} '{ print $x }')" ) optcommands+=( "$(echo -e "${currentopt[index]}" | awk -F ';' -v x=${cmdindex} '{ print $x }')" )
done done
done done
@ -180,8 +180,8 @@ for i in "${optcommands[@]}"; do
# Seek and run command. # Seek and run command.
index="0" index="0"
for ((index="0"; index < ${#currentopt[@]}; index+=3)); do for ((index="0"; index < ${#currentopt[@]}; index+=3)); do
currcmdamount="$(echo -e "${currentopt[index]}" | awk -F ';' '{ print NF }')" currcmdamount=$(echo -e "${currentopt[index]}" | awk -F ';' '{ print NF }')
for ((currcmdindex=1; currcmdindex <= ${currcmdamount}; currcmdindex++)); do for ((currcmdindex=1; currcmdindex <= currcmdamount; currcmdindex++)); do
if [ "$(echo -e "${currentopt[index]}" | awk -F ';' -v x=${currcmdindex} '{ print $x }')" == "${getopt}" ]; then if [ "$(echo -e "${currentopt[index]}" | awk -F ';' -v x=${currcmdindex} '{ print $x }')" == "${getopt}" ]; then
# Run command. # Run command.
eval "${currentopt[index+1]}" eval "${currentopt[index+1]}"

2
lgsm/functions/fix_arma3.sh

@ -6,7 +6,7 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" 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

2
lgsm/functions/fix_csgo.sh

@ -6,7 +6,7 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" 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 "${serverfiles}/steam_appid.txt" ]; then if [ ! -f "${serverfiles}/steam_appid.txt" ]; then

2
lgsm/functions/fix_dst.sh

@ -6,7 +6,7 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" 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.

2
lgsm/functions/fix_kf.sh

@ -6,7 +6,7 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
echo -e "Applying WebAdmin ROOst.css fix." echo -e "Applying WebAdmin ROOst.css fix."
echo -e "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" echo -e "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13"

2
lgsm/functions/fix_kf2.sh

@ -6,7 +6,7 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_parms(){ fn_parms(){
parms="\"${defaultmap}?Game=KFGameContent.KFGameInfo_VersusSurvival\"" parms="\"${defaultmap}?Game=KFGameContent.KFGameInfo_VersusSurvival\""

2
lgsm/functions/fix_mta.sh

@ -6,7 +6,7 @@
# Description: Installs the libmysqlclient for database functions on the server # Description: Installs the libmysqlclient for database functions on the server
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
if [ ! -f "${lgsmdir}/lib/libmysqlclient.so.16" ]; then if [ ! -f "${lgsmdir}/lib/libmysqlclient.so.16" ]; then
fixname="libmysqlclient16" fixname="libmysqlclient16"

2
lgsm/functions/fix_ro.sh

@ -6,7 +6,7 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
echo -e "Applying WebAdmin ROOst.css fix." echo -e "Applying WebAdmin ROOst.css fix."
echo -e "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" echo -e "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13"

2
lgsm/functions/fix_sfc.sh

@ -6,7 +6,7 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
if [ ! -f "${serverfiles}/bin/datacache.so" ]; then if [ ! -f "${serverfiles}/bin/datacache.so" ]; then
ln -s "${serverfiles}/bin/datacache_srv.so" "${serverfiles}/bin/datacache.so" ln -s "${serverfiles}/bin/datacache_srv.so" "${serverfiles}/bin/datacache.so"

2
lgsm/functions/fix_ss3.sh

@ -6,7 +6,7 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
# Fixes https://steamcommunity.com/app/41070/discussions/0/353916981477716386/ # Fixes https://steamcommunity.com/app/41070/discussions/0/353916981477716386/
if [ "$(diff "${steamcmddir}/linux32/steamclient.so" "${serverfiles}/Bin/steamclient.so" >/dev/null)" ]; then if [ "$(diff "${steamcmddir}/linux32/steamclient.so" "${serverfiles}/Bin/steamclient.so" >/dev/null)" ]; then

2
lgsm/functions/fix_steamcmd.sh

@ -6,7 +6,7 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" 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

2
lgsm/functions/fix_terraria.sh

@ -6,6 +6,6 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
export TERM=xterm export TERM=xterm

2
lgsm/functions/fix_tf2.sh

@ -6,7 +6,7 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
# Fixes: Team Fortress 2 Segmentation fault for Red-Hat Distros #2062. # Fixes: Team Fortress 2 Segmentation fault for Red-Hat Distros #2062.
if [ -f "/etc/redhat-release" ]&&[ ! -f "${serverfiles}/bin/libcurl-gnutls.so.4" ]; then if [ -f "/etc/redhat-release" ]&&[ ! -f "${serverfiles}/bin/libcurl-gnutls.so.4" ]; then

2
lgsm/functions/fix_ts3.sh

@ -6,7 +6,7 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
# Fixes: makes libmariadb2 available #1924. # Fixes: makes libmariadb2 available #1924.
if [ ! -f "${serverfiles}/libmariadb.so.2" ]; then if [ ! -f "${serverfiles}/libmariadb.so.2" ]; then

2
lgsm/functions/fix_ut.sh

@ -6,7 +6,7 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
#Set Binary Executable #Set Binary Executable
echo -e "chmod +x ${executabledir}/${executable}" echo -e "chmod +x ${executabledir}/${executable}"

2
lgsm/functions/fix_ut2k4.sh

@ -6,7 +6,7 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
echo -e "applying WebAdmin ut2003.css fix." echo -e "applying WebAdmin ut2003.css fix."
echo -e "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" echo -e "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13"

2
lgsm/functions/fix_ut3.sh

@ -6,7 +6,7 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_parms(){ fn_parms(){
parms="server VCTF-Suspense?Game=UTGameContent.UTVehicleCTFGame_Content?bIsDedicated=true?bIsLanMatch=false?bUsesStats=false?bShouldAdvertise=false?PureServer=1?bAllowJoinInProgress=true?ConfigSubDir=${selfname} -port=${port} -queryport=${queryport} -multihome=${ip} -nohomedir -unattended -log=${gamelog}" parms="server VCTF-Suspense?Game=UTGameContent.UTVehicleCTFGame_Content?bIsDedicated=true?bIsLanMatch=false?bUsesStats=false?bShouldAdvertise=false?PureServer=1?bAllowJoinInProgress=true?ConfigSubDir=${selfname} -port=${port} -queryport=${queryport} -multihome=${ip} -nohomedir -unattended -log=${gamelog}"

2
lgsm/functions/fix_zmr.sh

@ -6,7 +6,7 @@
local commandname="FIX" local commandname="FIX"
local commandaction="Fix" local commandaction="Fix"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
if [ ! -f "${serverfiles}/bin/datacache.so" ]; then if [ ! -f "${serverfiles}/bin/datacache.so" ]; then
ln -s "${serverfiles}/bin/datacache_srv.so" "${serverfiles}/bin/datacache.so" ln -s "${serverfiles}/bin/datacache_srv.so" "${serverfiles}/bin/datacache.so"

16
lgsm/functions/info_config.sh

@ -5,7 +5,7 @@
# Website: https://linuxgsm.com # Website: https://linuxgsm.com
# Description: Gets specific details from config files. # Description: Gets specific details from config files.
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" 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
@ -413,9 +413,9 @@ fn_info_config_pstbs(){
maxplayers="${unavailable}" maxplayers="${unavailable}"
reservedslots="${unavailable}" reservedslots="${unavailable}"
else else
servername="$(grep "ServerName=" "${servercfgfullpath}" | sed -e 's/^[ \t]//g' -e '/^#/d' -e 's/ServerName//g' | tr -d '=";,:' | sed -e 's/^[ \t]//' -e 's/[ \t]*$//')" servername=$(grep "ServerName=" "${servercfgfullpath}" | sed -e 's/^[ \t]//g' -e '/^#/d' -e 's/ServerName//g' | tr -d '=";,:' | sed -e 's/^[ \t]//' -e 's/[ \t]*$//')
maxplayers="$(grep "MaxPlayers=" "${servercfgfullpath}" | tr -cd '[:digit:]')" maxplayers=$(grep "MaxPlayers=" "${servercfgfullpath}" | tr -cd '[:digit:]')
reservedslots="$(grep "NumReservedSlots=" "${servercfgfullpath}" | tr -cd '[:digit:]')" reservedslots=$(grep "NumReservedSlots=" "${servercfgfullpath}" | tr -cd '[:digit:]')
fi fi
if [ ! -f "${servercfgdir}/Rcon.cfg" ]; then if [ ! -f "${servercfgdir}/Rcon.cfg" ]; then
@ -684,8 +684,8 @@ fn_info_config_sbots(){
servername="${unavailable}" servername="${unavailable}"
maxplayers="${unavailable}" maxplayers="${unavailable}"
else else
servername="$(grep "ServerName=" "${servercfgfullpath}" | sed -e 's/^[ \t]//g' -e '/^#/d' -e 's/ServerName//g' | tr -d '=";,:' | sed -e 's/^[ \t]//' -e 's/[ \t]*$//')" servername=$(grep "ServerName=" "${servercfgfullpath}" | sed -e 's/^[ \t]//g' -e '/^#/d' -e 's/ServerName//g' | tr -d '=";,:' | sed -e 's/^[ \t]//' -e 's/[ \t]*$//')
maxplayers="$(grep "MaxPlayers=" "${servercfgfullpath}" | tr -cd '[:digit:]')" maxplayers=$(grep "MaxPlayers=" "${servercfgfullpath}" | tr -cd '[:digit:]')
fi fi
servername=${servername:-"NOT SET"} servername=${servername:-"NOT SET"}
@ -1225,8 +1225,8 @@ fn_info_config_squad(){
servername="${unavailable}" servername="${unavailable}"
maxplayers="${unavailable}" maxplayers="${unavailable}"
else else
servername="$(grep "ServerName=" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/ServerName//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')" servername=$(grep "ServerName=" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/ServerName//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
maxplayers="$(grep "MaxPlayers=" "${servercfgfullpath}" | tr -cd '[:digit:]')" maxplayers=$(grep "MaxPlayers=" "${servercfgfullpath}" | tr -cd '[:digit:]')
fi fi
if [ ! -f "${servercfgdir}/Rcon.cfg" ]; then if [ ! -f "${servercfgdir}/Rcon.cfg" ]; then

34
lgsm/functions/info_distro.sh

@ -5,7 +5,7 @@
# 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 alert.sh. # Used for command_details.sh, command_debug.sh and alert.sh.
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
### Game Server pid ### Game Server pid
if [ "${status}" == "1" ]; then if [ "${status}" == "1" ]; then
@ -34,9 +34,9 @@ do
distrocodename=$(grep VERSION_CODENAME /etc/os-release | sed 's/VERSION_CODENAME=//g' | sed 's/\"//g') distrocodename=$(grep VERSION_CODENAME /etc/os-release | sed 's/VERSION_CODENAME=//g' | sed 's/\"//g')
elif [ -n "$(command -v lsb_release 2>/dev/null)" ]&&[ "${distro_info}" == "lsb_release" ]; then elif [ -n "$(command -v lsb_release 2>/dev/null)" ]&&[ "${distro_info}" == "lsb_release" ]; then
if [ -z "${distroname}" ];then if [ -z "${distroname}" ];then
distroname="$(lsb_release -sd)" distroname=$(lsb_release -sd)
elif [ -z "${distroversion}" ];then elif [ -z "${distroversion}" ];then
distroversion="$(lsb_release -sr)" distroversion=$(lsb_release -sr)
elif [ -z "${distroid}" ];then elif [ -z "${distroid}" ];then
distroid=$(lsb_release -si) distroid=$(lsb_release -si)
elif [ -z "${distrocodename}" ];then elif [ -z "${distrocodename}" ];then
@ -44,13 +44,13 @@ do
fi fi
elif [ -n "$(command -v hostnamectl 2>/dev/null)" ]&&[ "${distro_info}" == "hostnamectl" ]; then elif [ -n "$(command -v hostnamectl 2>/dev/null)" ]&&[ "${distro_info}" == "hostnamectl" ]; then
if [ -z "${distroname}" ];then if [ -z "${distroname}" ];then
distroname="$(hostnamectl | grep "Operating System" | sed 's/Operating System: //g')" distroname=$(hostnamectl | grep "Operating System" | sed 's/Operating System: //g')
fi fi
elif [ -f "/etc/debian_version" ]&&[ "${distro_info}" == "debian_version" ]; then elif [ -f "/etc/debian_version" ]&&[ "${distro_info}" == "debian_version" ]; then
if [ -z "${distroname}" ];then if [ -z "${distroname}" ];then
distroname="Debian $(cat /etc/debian_version)" distroname="Debian $(cat /etc/debian_version)"
elif [ -z "${distroversion}" ];then elif [ -z "${distroversion}" ];then
distroversion="$(cat /etc/debian_version)" distroversion=$(cat /etc/debian_version)
elif [ -z "${distroid}" ];then elif [ -z "${distroid}" ];then
distroid="debian" distroid="debian"
fi fi
@ -60,21 +60,21 @@ do
elif [ -z "${distroversion}" ];then elif [ -z "${distroversion}" ];then
distroversion=$(rpm -qa \*-release | grep -Ei "oracle|redhat|centos|fedora" | cut -d"-" -f3) distroversion=$(rpm -qa \*-release | grep -Ei "oracle|redhat|centos|fedora" | cut -d"-" -f3)
elif [ -z "${distroid}" ];then elif [ -z "${distroid}" ];then
distroid="$(awk '{print $1}' /etc/redhat-release)" distroid=$(awk '{print $1}' /etc/redhat-release)
fi fi
fi fi
done done
## Glibc version ## 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 2>/dev/null)" ]; then if [ -z "$(command -V tmux 2>/dev/null)" ]; then
tmuxv="${red}NOT INSTALLED!${default}" tmuxv="${red}NOT INSTALLED!${default}"
else else
if [ "$(tmux -V|sed "s/tmux //" | sed -n '1 p' | tr -cd '[:digit:]')" -lt "16" ] 2>/dev/null; then if [ "$(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)
@ -107,7 +107,7 @@ fi
# Available RAM and swap. # Available RAM and swap.
# Newer distros can use numfmt to give more accurate results. # Newer distros can use numfmt to give more accurate results.
if [ "$(command -v numfmt 2>/dev/null)" ]; then if [ -n "$(command -v numfmt 2>/dev/null)" ]; then
# Issue #2005 - Kernel 3.14+ contains MemAvailable which should be used. All others will be calculated. # Issue #2005 - Kernel 3.14+ contains MemAvailable which should be used. All others will be calculated.
# get the raw KB values of these fields. # get the raw KB values of these fields.
@ -121,16 +121,16 @@ if [ "$(command -v numfmt 2>/dev/null)" ]; then
if grep -q ^MemAvailable /proc/meminfo; then if grep -q ^MemAvailable /proc/meminfo; then
physmemactualfreekb=$(grep ^MemAvailable /proc/meminfo | awk '{print $2}') physmemactualfreekb=$(grep ^MemAvailable /proc/meminfo | awk '{print $2}')
else else
physmemactualfreekb=$((${physmemfreekb}+${physmembufferskb}+${physmemcachedkb})) physmemactualfreekb=$((physmemfreekb+physmembufferskb+physmemcachedkb))
fi fi
# Available RAM and swap. # Available RAM and swap.
physmemtotalmb=$((${physmemtotalkb}/1024)) physmemtotalmb=$((physmemtotalkb/1024))
physmemtotal=$(numfmt --to=iec --from=iec --suffix=B "${physmemtotalkb}K") physmemtotal=$(numfmt --to=iec --from=iec --suffix=B "${physmemtotalkb}K")
physmemfree=$(numfmt --to=iec --from=iec --suffix=B "${physmemactualfreekb}K") physmemfree=$(numfmt --to=iec --from=iec --suffix=B "${physmemactualfreekb}K")
physmemused=$(numfmt --to=iec --from=iec --suffix=B "$((${physmemtotalkb}-${physmemfreekb}-${physmembufferskb}-${physmemcachedkb}-${physmemreclaimablekb}))K") physmemused=$(numfmt --to=iec --from=iec --suffix=B "$((physmemtotalkb-physmemfreekb-physmembufferskb-physmemcachedkb-physmemreclaimablekb))K")
physmemavailable=$(numfmt --to=iec --from=iec --suffix=B "${physmemactualfreekb}K") physmemavailable=$(numfmt --to=iec --from=iec --suffix=B "${physmemactualfreekb}K")
physmemcached=$(numfmt --to=iec --from=iec --suffix=B "$((${physmemcachedkb}+${physmemreclaimablekb}))K") physmemcached=$(numfmt --to=iec --from=iec --suffix=B "$((physmemcachedkb+physmemreclaimablekb))K")
swaptotal=$(numfmt --to=iec --from=iec --suffix=B "$(grep ^SwapTotal /proc/meminfo | awk '{print $2}')K") swaptotal=$(numfmt --to=iec --from=iec --suffix=B "$(grep ^SwapTotal /proc/meminfo | awk '{print $2}')K")
swapfree=$(numfmt --to=iec --from=iec --suffix=B "$(grep ^SwapFree /proc/meminfo | awk '{print $2}')K") swapfree=$(numfmt --to=iec --from=iec --suffix=B "$(grep ^SwapFree /proc/meminfo | awk '{print $2}')K")
@ -228,7 +228,7 @@ netlink=$(ethtool "${netint}" 2>/dev/null| grep Speed | awk '{print $2}')
# External IP address # External IP address
if [ -z "${extip}" ]; then if [ -z "${extip}" ]; then
extip=$(${curlpath} -4 -m 3 ifconfig.co 2>/dev/null) extip=$(curl -4 -m 3 ifconfig.co 2>/dev/null)
exitcode=$? exitcode=$?
# Should ifconfig.co return an error will use last known IP. # Should ifconfig.co return an error will use last known IP.
if [ ${exitcode} -eq 0 ]; then if [ ${exitcode} -eq 0 ]; then
@ -252,12 +252,12 @@ else
fi fi
# Steam Master Server - checks if detected by master server. # Steam Master Server - checks if detected by master server.
if [ "$(command -v jq 2>/dev/null)" ]; then if [ -n "$(command -v jq 2>/dev/null)" ]; then
if [ "${ip}" ]&&[ "${port}" ]; then if [ "${ip}" ]&&[ "${port}" ]; then
if [ "${steammaster}" == "true" ]; then if [ "${steammaster}" == "true" ]; then
masterserver="$(${curlpath} -m 3 -s 'https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr='${ip}':'${port}'&format=json' | jq '.response.servers[]|.addr' | wc -l)" masterserver=$(curl -m 3 -s 'https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr='${ip}':'${port}'&format=json' | jq '.response.servers[]|.addr' | wc -l)
if [ "${masterserver}" == "0" ]; then if [ "${masterserver}" == "0" ]; then
masterserver="$(${curlpath} -m 3 -s 'https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr='${extip}':'${port}'&format=json' | jq '.response.servers[]|.addr' | wc -l)" masterserver=$(curl -m 3 -s 'https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr='${extip}':'${port}'&format=json' | jq '.response.servers[]|.addr' | wc -l)
fi fi
if [ "${masterserver}" == "0" ]; then if [ "${masterserver}" == "0" ]; then
displaymasterserver="false" displaymasterserver="false"

2
lgsm/functions/info_parms.sh

@ -4,7 +4,7 @@
# Website: https://linuxgsm.com # Website: https://linuxgsm.com
# Description: If specific parms are not set then this will be displayed in details. # Description: If specific parms are not set then this will be displayed in details.
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" 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

8
lgsm/functions/info_stats.sh

@ -10,7 +10,7 @@ info_distro.sh
if [ ! -f "${datadir}/uuid.txt" ];then if [ ! -f "${datadir}/uuid.txt" ];then
mkdir -p "${datadir}" mkdir -p "${datadir}"
touch "${datadir}/uuid.txt" touch "${datadir}/uuid.txt"
if [ "$(command -v uuidgen 2>/dev/null)" ]; then if [ -n "$(command -v uuidgen 2>/dev/null)" ]; then
uuidgen > "${datadir}/uuid.txt" uuidgen > "${datadir}/uuid.txt"
else else
cat /proc/sys/kernel/random/uuid > "${datadir}/uuid.txt" cat /proc/sys/kernel/random/uuid > "${datadir}/uuid.txt"
@ -20,11 +20,11 @@ fi
uuid=$(cat "${datadir}/uuid.txt") uuid=$(cat "${datadir}/uuid.txt")
# results are rounded up to reduce number of different results in analytics # results are rounded up to reduce number of different results in analytics
# nearest 100Mhz # nearest 100Mhz
cpuusedmhzroundup=$(((${cpuusedmhz} + 99) / 100 * 100)) cpuusedmhzroundup=$(((cpuusedmhz + 99) / 100 * 100))
# nearest 100MB # nearest 100MB
memusedroundup=$(((${memused} + 99) / 100 * 100)) memusedroundup=$(((memused + 99) / 100 * 100))
# nearest 100MB # nearest 100MB
serverfilesduroundup=$(((${serverfilesdu} + 99) / 100 * 100)) serverfilesduroundup=$(((serverfilesdu + 99) / 100 * 100))
# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters # https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
# Level 1 Stats # Level 1 Stats

2
lgsm/functions/install_complete.sh

@ -6,7 +6,7 @@
local commandname="INSTALL" local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
echo -e "" echo -e ""
echo -e "=================================" echo -e "================================="

2
lgsm/functions/install_config.sh

@ -6,7 +6,7 @@
local commandname="INSTALL" local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
# Checks if server cfg dir exists, creates it if it doesn't. # Checks if server cfg dir exists, creates it if it doesn't.
fn_check_cfgdir(){ fn_check_cfgdir(){

2
lgsm/functions/install_dst_token.sh

@ -6,7 +6,7 @@
local commandname="INSTALL" local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
echo -e "" echo -e ""
echo -e "${lightyellow}Enter ${gamename} Cluster Token${default}" echo -e "${lightyellow}Enter ${gamename} Cluster Token${default}"

2
lgsm/functions/install_gslt.sh

@ -6,7 +6,7 @@
local commandname="INSTALL" local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
echo -e "" echo -e ""
echo -e "${lightyellow}Game Server Login Token${default}" echo -e "${lightyellow}Game Server Login Token${default}"

2
lgsm/functions/install_header.sh

@ -6,7 +6,7 @@
local commandname="INSTALL" local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
clear clear
fn_print_ascii_logo fn_print_ascii_logo

14
lgsm/functions/install_logs.sh

@ -6,7 +6,7 @@
local commandname="INSTALL" local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
if [ "${checklogs}" != "1" ]; then if [ "${checklogs}" != "1" ]; then
echo -e "" echo -e ""
@ -51,8 +51,7 @@ if [ -n "${consolelogdir}" ]; then
fn_print_ok_eol_nl fn_print_ok_eol_nl
fi fi
echo -en "creating console log: ${consolelog}..." echo -en "creating console log: ${consolelog}..."
touch "${consolelog}" if ! touch "${consolelog}"; then
if [ $? -ne 0 ]; then
fn_print_fail_eol_nl fn_print_fail_eol_nl
core_exit.sh core_exit.sh
else else
@ -63,8 +62,7 @@ fi
# Create Game logs. # Create Game logs.
if [ -n "${gamelogdir}" ]&&[ ! -d "${gamelogdir}" ]; then if [ -n "${gamelogdir}" ]&&[ ! -d "${gamelogdir}" ]; then
echo -en "installing game log dir: ${gamelogdir}..." echo -en "installing game log dir: ${gamelogdir}..."
mkdir -p "${gamelogdir}" if ! mkdir -p "${gamelogdir}"; then
if [ $? -ne 0 ]; then
fn_print_fail_eol_nl fn_print_fail_eol_nl
core_exit.sh core_exit.sh
else else
@ -79,8 +77,7 @@ fi
if [ -n "${gamelogdir}" ]; then if [ -n "${gamelogdir}" ]; then
if [ "${gamelogdir:0:${#logdir}}" != "${logdir}" ]; then if [ "${gamelogdir:0:${#logdir}}" != "${logdir}" ]; then
echo -en "creating symlink to game log dir: ${logdir}/server -> ${gamelogdir}..." echo -en "creating symlink to game log dir: ${logdir}/server -> ${gamelogdir}..."
ln -nfs "${gamelogdir}" "${logdir}/server" if ! ln -nfs "${gamelogdir}" "${logdir}/server"; then
if [ $? -ne 0 ]; then
fn_print_fail_eol_nl fn_print_fail_eol_nl
core_exit.sh core_exit.sh
else else
@ -93,8 +90,7 @@ fi
if [ -d "${rootdir}/Steam/logs" ]; then if [ -d "${rootdir}/Steam/logs" ]; then
if [ ! -L "${logdir}/steamcmd" ]; then if [ ! -L "${logdir}/steamcmd" ]; then
echo -en "creating symlink to steam log dir: ${logdir}/steamcmd -> ${rootdir}/Steam/logs..." echo -en "creating symlink to steam log dir: ${logdir}/steamcmd -> ${rootdir}/Steam/logs..."
ln -nfs "${rootdir}/Steam/logs" "${logdir}/steamcmd" if ! ln -nfs "${rootdir}/Steam/logs" "${logdir}/steamcmd"; then
if [ $? -ne 0 ]; then
fn_print_fail_eol_nl fn_print_fail_eol_nl
core_exit.sh core_exit.sh
else else

2
lgsm/functions/install_mta_resources.sh

@ -7,7 +7,7 @@
local commandname="INSTALL" local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_print_information_nl "${gamename} will not function without resources!" fn_print_information_nl "${gamename} will not function without resources!"
echo -e " * install default resources using ./${selfname} install-default-resources" echo -e " * install default resources using ./${selfname} install-default-resources"

2
lgsm/functions/install_retry.sh

@ -6,7 +6,7 @@
local commandname="INSTALL" local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
if fn_prompt_yn "Retry install?" Y; then if fn_prompt_yn "Retry install?" Y; then
command_install.sh; core_exit.sh command_install.sh; core_exit.sh

2
lgsm/functions/install_server_dir.sh

@ -6,7 +6,7 @@
local commandname="INSTALL" local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
echo -e "" echo -e ""
echo -e "${lightyellow}Server Directory${default}" echo -e "${lightyellow}Server Directory${default}"

4
lgsm/functions/install_server_files.sh

@ -6,7 +6,7 @@
local commandname="INSTALL" local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_install_server_files(){ fn_install_server_files(){
if [ "${shortname}" == "ahl" ]; then if [ "${shortname}" == "ahl" ]; then
@ -98,7 +98,7 @@ fn_install_server_files_steamcmd(){
# Detects if unbuffer command is available for 32 bit distributions only. # Detects if unbuffer command is available for 32 bit distributions only.
info_distro.sh info_distro.sh
if [ "$(command -v stdbuf 2>/dev/null)" ]&&[ "${arch}" != "x86_64" ]; then if [ -n "$(command -v stdbuf 2>/dev/null)" ]&&[ "${arch}" != "x86_64" ]; then
unbuffer="stdbuf -i0 -o0 -e0" unbuffer="stdbuf -i0 -o0 -e0"
fi fi

2
lgsm/functions/install_squad_license.sh

@ -6,7 +6,7 @@
local commandname="INSTALL" local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
echo -e "" echo -e ""
echo -e "${lightyellow}Squad Server License${default}" echo -e "${lightyellow}Squad Server License${default}"

2
lgsm/functions/install_stats.sh

@ -6,7 +6,7 @@
local commandname="INSTALL" local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
echo -e "" echo -e ""
echo -e "${lightyellow}LinuxGSM Stats${default}" echo -e "${lightyellow}LinuxGSM Stats${default}"

2
lgsm/functions/install_ts3db.sh

@ -7,7 +7,7 @@
local commandname="INSTALL" local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_install_ts3db_mariadb(){ fn_install_ts3db_mariadb(){
if [ ! -f "${serverfiles}/libts3db_mariadb.so" ]; then if [ ! -f "${serverfiles}/libts3db_mariadb.so" ]; then

2
lgsm/functions/install_ut2k4_key.sh

@ -6,7 +6,7 @@
local commandname="INSTALL" local commandname="INSTALL"
local commandaction="Install" local commandaction="Install"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
echo -e "" echo -e ""
echo -e "${lightyellow}Enter ${gamename} CD Key${default}" echo -e "${lightyellow}Enter ${gamename} CD Key${default}"

2
lgsm/functions/logs.sh

@ -98,7 +98,7 @@ if [ "$(find "${lgsmlogdir}"/ -type f -mtime +"${logdays}" | wc -l)" -ne "0" ];
fi fi
# Count total amount of files removed. # Count total amount of files removed.
countlogs=$((${scriptcount} + ${consolecount} + ${gamecount} + ${srcdscount} + ${smcount} + ${ulxcount} + ${darkrpcount})) countlogs=$((scriptcount + consolecount + gamecount + srcdscount + smcount + ulxcount + darkrpcount))
# Job done. # Job done.
fn_print_ok_nl "Removed ${countlogs} log files" fn_print_ok_nl "Removed ${countlogs} log files"
fn_script_log "Removed ${countlogs} log files" fn_script_log "Removed ${countlogs} log files"

26
lgsm/functions/mods_core.sh

@ -7,7 +7,7 @@
local commandname="MODS" local commandname="MODS"
local commandaction="Mods" local commandaction="Mods"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
# Files and Directories. # Files and Directories.
modsdir="${lgsmdir}/mods" modsdir="${lgsmdir}/mods"
@ -43,7 +43,7 @@ fn_mod_lowercase(){
fileswc=$(find "${extractdir}" -depth | wc -l) fileswc=$(find "${extractdir}" -depth | wc -l)
echo -en "\r" echo -en "\r"
while read -r src; do while read -r src; do
dst="$(dirname "${src}$(/)basename" "${src}" | tr 'A-Z' 'a-z')" dst=$(dirname "${src}$(/)basename" "${src}" | tr '[:upper:]' '[:lower:]')
if [ "${src}" != "${dst}" ] if [ "${src}" != "${dst}" ]
then then
[ ! -e "${dst}" ] && mv -T "${src}" "${dst}" || echo -e "${src} was not renamed" [ ! -e "${dst}" ] && mv -T "${src}" "${dst}" || echo -e "${src} was not renamed"
@ -122,11 +122,11 @@ fn_mod_tidy_files_list(){
removefromlist="cfg;addons;RustDedicated_Data;RustDedicated_Data\/Managed;RustDedicated_Data\/Managed\/x86;RustDedicated_Data\/Managed\/x64;" removefromlist="cfg;addons;RustDedicated_Data;RustDedicated_Data\/Managed;RustDedicated_Data\/Managed\/x86;RustDedicated_Data\/Managed\/x64;"
# Loop through files to remove from file list, # Loop through files to remove from file list,
# generate elements to remove from list. # generate elements to remove from list.
removefromlistamount="$(echo -e "${removefromlist}" | awk -F ';' '{ print NF }')" removefromlistamount=$(echo -e "${removefromlist}" | awk -F ';' '{ print NF }')
# Test all subvalue of "removefromlist" using the ";" separator. # Test all subvalue of "removefromlist" using the ";" separator.
for ((filesindex=1; filesindex < removefromlistamount; filesindex++)); do for ((filesindex=1; filesindex < removefromlistamount; filesindex++)); do
# Put current file into test variable. # Put current file into test variable.
removefilevar="$(echo -e "${removefromlist}" | awk -F ';' -v x=${filesindex} '{ print $x }')" removefilevar=$(echo -e "${removefromlist}" | awk -F ';' -v x=${filesindex} '{ print $x }')
# Delete line(s) matching exactly. # Delete line(s) matching exactly.
sed -i "/^${removefilevar}$/d" "${modsdir}/${modcommand}-files.txt" sed -i "/^${removefilevar}$/d" "${modsdir}/${modcommand}-files.txt"
# Exit on error. # Exit on error.
@ -259,7 +259,7 @@ fn_mods_installed_list(){
modcommandmaxlength="0" modcommandmaxlength="0"
# Loop through every line of the installed mods list ${modsinstalledlistfullpath}. # Loop through every line of the installed mods list ${modsinstalledlistfullpath}.
while [ "${installedmodsline}" -le "${installedmodscount}" ]; do while [ "${installedmodsline}" -le "${installedmodscount}" ]; do
currentmod="$(sed "${installedmodsline}q;d" "${modsinstalledlistfullpath}")" currentmod=$(sed "${installedmodsline}q;d" "${modsinstalledlistfullpath}")
# Get mod info to make sure mod exists. # Get mod info to make sure mod exists.
fn_mod_get_info fn_mod_get_info
# Add the mod to available commands. # Add the mod to available commands.
@ -306,11 +306,11 @@ fn_compatible_mod_games(){
# If value is set to GAMES (ignore). # If value is set to GAMES (ignore).
if [ "${modgames}" != "GAMES" ]; then if [ "${modgames}" != "GAMES" ]; then
# How many games we need to test. # How many games we need to test.
gamesamount="$(echo -e "${modgames}" | awk -F ';' '{ print NF }')" gamesamount=$(echo -e "${modgames}" | awk -F ';' '{ print NF }')
# Test all subvalue of "modgames" using the ";" separator. # Test all subvalue of "modgames" using the ";" separator.
for ((gamevarindex=1; gamevarindex < gamesamount; gamevarindex++)); do for ((gamevarindex=1; gamevarindex < gamesamount; gamevarindex++)); do
# Put current game name into modtest variable. # Put current game name into modtest variable.
gamemodtest="$( echo -e "${modgames}" | awk -F ';' -v x=${gamevarindex} '{ print $x }' )" gamemodtest=$( echo -e "${modgames}" | awk -F ';' -v x=${gamevarindex} '{ print $x }' )
# If game name matches. # If game name matches.
if [ "${gamemodtest}" == "${gamename}" ]; then if [ "${gamemodtest}" == "${gamename}" ]; then
# Mod is compatible. # Mod is compatible.
@ -327,11 +327,11 @@ fn_compatible_mod_engines(){
# If value is set to ENGINES (ignore). # If value is set to ENGINES (ignore).
if [ "${modengines}" != "ENGINES" ]; then if [ "${modengines}" != "ENGINES" ]; then
# How many engines we need to test. # How many engines we need to test.
enginesamount="$(echo -e "${modengines}" | awk -F ';' '{ print NF }')" enginesamount=$(echo -e "${modengines}" | awk -F ';' '{ print NF }')
# Test all subvalue of "modengines" using the ";" separator. # Test all subvalue of "modengines" using the ";" separator.
for ((gamevarindex=1; gamevarindex < ${enginesamount}; gamevarindex++)); do for ((gamevarindex=1; gamevarindex < ${enginesamount}; gamevarindex++)); do
# Put current engine name into modtest variable. # Put current engine name into modtest variable.
enginemodtest="$( echo -e "${modengines}" | awk -F ';' -v x=${gamevarindex} '{ print $x }' )" enginemodtest=$( echo -e "${modengines}" | awk -F ';' -v x=${gamevarindex} '{ print $x }' )
# If engine name matches. # If engine name matches.
if [ "${enginemodtest}" == "${engine}" ]; then if [ "${enginemodtest}" == "${engine}" ]; then
# Mod is compatible. # Mod is compatible.
@ -348,11 +348,11 @@ fn_not_compatible_mod_games(){
# If value is set to NOTGAMES (ignore). # If value is set to NOTGAMES (ignore).
if [ "${modexcludegames}" != "NOTGAMES" ]; then if [ "${modexcludegames}" != "NOTGAMES" ]; then
# How many engines we need to test. # How many engines we need to test.
excludegamesamount="$(echo -e "${modexcludegames}" | awk -F ';' '{ print NF }')" excludegamesamount=$(echo -e "${modexcludegames}" | awk -F ';' '{ print NF }')
# Test all subvalue of "modexcludegames" using the ";" separator. # Test all subvalue of "modexcludegames" using the ";" separator.
for ((gamevarindex=1; gamevarindex < excludegamesamount; gamevarindex++)); do for ((gamevarindex=1; gamevarindex < excludegamesamount; gamevarindex++)); do
# Put current engine name into modtest variable. # Put current engine name into modtest variable.
excludegamemodtest="$( echo -e "${modexcludegames}" | awk -F ';' -v x=${gamevarindex} '{ print $x }' )" excludegamemodtest=$( echo -e "${modexcludegames}" | awk -F ';' -v x=${gamevarindex} '{ print $x }' )
# If engine name matches. # If engine name matches.
if [ "${excludegamemodtest}" == "${gamename}" ]; then if [ "${excludegamemodtest}" == "${gamename}" ]; then
# Mod is compatible. # Mod is compatible.
@ -461,7 +461,7 @@ fn_mods_clear_tmp_dir(){
# Counts how many mods were installed. # Counts how many mods were installed.
fn_mods_count_installed(){ fn_mods_count_installed(){
if [ -f "${modsinstalledlistfullpath}" ]; then if [ -f "${modsinstalledlistfullpath}" ]; then
installedmodscount="$(wc -l < "${modsinstalledlistfullpath}")" installedmodscount=$(wc -l < "${modsinstalledlistfullpath}")
else else
installedmodscount=0 installedmodscount=0
fi fi
@ -486,7 +486,7 @@ fn_check_mod_files_list(){
# File list must exist and be valid before any operation on it. # File list must exist and be valid before any operation on it.
if [ -f "${modsdir}/${modcommand}-files.txt" ]; then if [ -f "${modsdir}/${modcommand}-files.txt" ]; then
# How many lines is the file list. # How many lines is the file list.
modsfilelistsize="$(wc -l < "${modsdir}/${modcommand}-files.txt")" modsfilelistsize=$(wc -l < "${modsdir}/${modcommand}-files.txt")
# If file list is empty. # If file list is empty.
if [ "${modsfilelistsize}" -eq 0 ]; then if [ "${modsfilelistsize}" -eq 0 ]; then
fn_print_failure "${modcommand}-files.txt is empty" fn_print_failure "${modcommand}-files.txt is empty"

16
lgsm/functions/mods_list.sh

@ -10,36 +10,36 @@
local commandname="MODS" local commandname="MODS"
local commandaction="List Mods" local commandaction="List Mods"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
# Get a proper URL for mods that don't provide a good one (optional) # Get a proper URL for mods that don't provide a good one (optional)
fn_script_log_info "Retrieving latest mods URLs" fn_script_log_info "Retrieving latest mods URLs"
# Metamod # Metamod
metamodmversion="1.10" metamodmversion="1.10"
metamodscrapeurl="https://mms.alliedmods.net/mmsdrop/${metamodmversion}/mmsource-latest-linux" metamodscrapeurl="https://mms.alliedmods.net/mmsdrop/${metamodmversion}/mmsource-latest-linux"
metamodlatestfile="$(wget "${metamodscrapeurl}" -q -O -)" metamodlatestfile=$(wget "${metamodscrapeurl}" -q -O -)
metamoddownloadurl="https://www.metamodsource.net/latest.php?os=linux&version=${metamodmversion}" metamoddownloadurl="https://www.metamodsource.net/latest.php?os=linux&version=${metamodmversion}"
metamodurl="${metamoddownloadurl}" metamodurl="${metamoddownloadurl}"
# Sourcemod # Sourcemod
sourcemodmversion="1.10" sourcemodmversion="1.10"
sourcemodscrapeurl="https://sm.alliedmods.net/smdrop/${sourcemodmversion}/sourcemod-latest-linux" sourcemodscrapeurl="https://sm.alliedmods.net/smdrop/${sourcemodmversion}/sourcemod-latest-linux"
sourcemodlatestfile="$(wget "${sourcemodscrapeurl}" -q -O -)" sourcemodlatestfile=$(wget "${sourcemodscrapeurl}" -q -O -)
sourcemoddownloadurl="https://www.sourcemod.net/latest.php?os=linux&version=${sourcemodmversion}" sourcemoddownloadurl="https://www.sourcemod.net/latest.php?os=linux&version=${sourcemodmversion}"
sourcemodurl="${sourcemoddownloadurl}" sourcemodurl="${sourcemoddownloadurl}"
# Steamworks # Steamworks
steamworksscrapeurl="https://users.alliedmods.net/~kyles/builds/SteamWorks" steamworksscrapeurl="https://users.alliedmods.net/~kyles/builds/SteamWorks"
steamworkslatestfile="$(curl -sL ${steamworksscrapeurl} | grep -m 1 linux | cut -d '"' -f 4)" steamworkslatestfile=$(curl -sL ${steamworksscrapeurl} | grep -m 1 linux | cut -d '"' -f 4)
steamworksdownloadurl="${steamworksscrapeurl}/${steamworkslatestfile}" steamworksdownloadurl="${steamworksscrapeurl}/${steamworkslatestfile}"
steamworksurl="${steamworksdownloadurl}" steamworksurl="${steamworksdownloadurl}"
# CS:GO Mods # CS:GO Mods
get5scrapepath="$(curl -sL https://ci.splewis.net/job/get5/lastSuccessfulBuild/api/xml | grep -oP "<relativePath>\K(.+)(?=</relativePath>)")" get5scrapepath=$(curl -sL https://ci.splewis.net/job/get5/lastSuccessfulBuild/api/xml | grep -oP "<relativePath>\K(.+)(?=</relativePath>)")
get5latestfile="$(echo -e "${get5scrapepath}" | xargs -n 1 -I @ sh -c "echo -e "basename "@""")" get5latestfile=$(echo -e "${get5scrapepath}" | xargs -n 1 -I @ sh -c "echo -e "basename "@""")
get5downloadurl="https://ci.splewis.net/job/get5/lastSuccessfulBuild/artifact/${get5scrapepath}" get5downloadurl="https://ci.splewis.net/job/get5/lastSuccessfulBuild/artifact/${get5scrapepath}"
get5url="${get5downloadurl}" get5url="${get5downloadurl}"
# Oxide # Oxide
oxiderustlatestlink="https://umod.org/games/rust/download/develop" # fix for linux build 06.09.2019 oxiderustlatestlink="https://umod.org/games/rust/download/develop" # fix for linux build 06.09.2019
oxidehurtworldlatestlink="$(curl -sL https://api.github.com/repos/OxideMod/Oxide.Hurtworld/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep "Oxide.Hurtworld.zip")" oxidehurtworldlatestlink=$(curl -sL https://api.github.com/repos/OxideMod/Oxide.Hurtworld/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep "Oxide.Hurtworld.zip")
oxidesdtdlatestlink="$(curl -sL https://api.github.com/repos/OxideMod/Oxide.SevenDaysToDie/releases/latest | grep browser_download_url | cut -d '"' -f 4)" oxidesdtdlatestlink=$(curl -sL https://api.github.com/repos/OxideMod/Oxide.SevenDaysToDie/releases/latest | grep browser_download_url | cut -d '"' -f 4)
# Define mods information (required) # Define mods information (required)

2
lgsm/functions/query_gamedig.sh

@ -6,7 +6,7 @@
# https://github.com/sonicsnes/node-gamedig # https://github.com/sonicsnes/node-gamedig
# Check if gamedig and jq are installed. # Check if gamedig and jq are installed.
if [ "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ]; then if [ -n "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ]; then
# will bypass query if server offline. # will bypass query if server offline.
check_status.sh check_status.sh

4
lgsm/functions/update_factorio.sh

@ -6,7 +6,7 @@
local commandname="UPDATE" local commandname="UPDATE"
local commandaction="Update" local commandaction="Update"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_update_factorio_dl(){ fn_update_factorio_dl(){
fn_fetch_file "https://factorio.com/get-download/${downloadbranch}/headless/${factorioarch}" "${tmpdir}" "factorio_headless_${factorioarch}-${remotebuild}.tar.xz" fn_fetch_file "https://factorio.com/get-download/${downloadbranch}/headless/${factorioarch}" "${tmpdir}" "factorio_headless_${factorioarch}-${remotebuild}.tar.xz"
@ -43,7 +43,7 @@ fn_update_factorio_localbuild(){
fn_update_factorio_remotebuild(){ fn_update_factorio_remotebuild(){
# Gets remote build info. # Gets remote build info.
remotebuild=$(${curlpath} -s "https://factorio.com/get-download/${downloadbranch}/headless/${factorioarch}" | grep -o '[0-9]\.[0-9]\{1,\}\.[0-9]\{1,\}' | head -1) remotebuild=$(curl -s "https://factorio.com/get-download/${downloadbranch}/headless/${factorioarch}" | grep -o '[0-9]\.[0-9]\{1,\}\.[0-9]\{1,\}' | head -1)
if [ "${installer}" != "1" ]; then if [ "${installer}" != "1" ]; then
fn_print_dots "Checking for update: ${remotelocation}: checking remote build" fn_print_dots "Checking for update: ${remotelocation}: checking remote build"
# Checks if remotebuild variable has been set. # Checks if remotebuild variable has been set.

8
lgsm/functions/update_minecraft.sh

@ -6,11 +6,11 @@
local commandname="UPDATE" local commandname="UPDATE"
local commandaction="Update" local commandaction="Update"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_update_minecraft_dl(){ fn_update_minecraft_dl(){
latestmcreleaselink=$(${curlpath} -s "https://launchermeta.mojang.com/mc/game/version_manifest.json" | jq -r '.latest.release as $latest | .versions[] | select(.id == $latest) | .url') latestmcreleaselink=$(curl -s "https://launchermeta.mojang.com/mc/game/version_manifest.json" | jq -r '.latest.release as $latest | .versions[] | select(.id == $latest) | .url')
latestmcbuildurl=$(${curlpath} -s "${latestmcreleaselink}" | jq -r '.downloads.server.url') latestmcbuildurl=$(curl -s "${latestmcreleaselink}" | jq -r '.downloads.server.url')
fn_fetch_file "${latestmcbuildurl}" "${tmpdir}" "minecraft_server.${remotebuild}.jar" fn_fetch_file "${latestmcbuildurl}" "${tmpdir}" "minecraft_server.${remotebuild}.jar"
echo -e "copying to ${serverfiles}...\c" echo -e "copying to ${serverfiles}...\c"
cp "${tmpdir}/minecraft_server.${remotebuild}.jar" "${serverfiles}/minecraft_server.jar" cp "${tmpdir}/minecraft_server.${remotebuild}.jar" "${serverfiles}/minecraft_server.jar"
@ -98,7 +98,7 @@ fn_update_minecraft_localbuild(){
fn_update_minecraft_remotebuild(){ fn_update_minecraft_remotebuild(){
# Gets remote build info. # Gets remote build info.
remotebuild=$(${curlpath} -s "https://launchermeta.${remotelocation}/mc/game/version_manifest.json" | jq -r '.latest.release') remotebuild=$(curl -s "https://launchermeta.${remotelocation}/mc/game/version_manifest.json" | jq -r '.latest.release')
if [ "${installer}" != "1" ]; then if [ "${installer}" != "1" ]; then
fn_print_dots "Checking for update: ${remotelocation}: checking remote build" fn_print_dots "Checking for update: ${remotelocation}: checking remote build"
# Checks if remotebuild variable has been set. # Checks if remotebuild variable has been set.

8
lgsm/functions/update_mta.sh

@ -6,7 +6,7 @@
local commandname="UPDATE" local commandname="UPDATE"
local commandaction="Update" local commandaction="Update"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_update_mta_dl(){ fn_update_mta_dl(){
fn_fetch_file "http://linux.mtasa.com/dl/multitheftauto_linux_x64.tar.gz" "${tmpdir}" "multitheftauto_linux_x64.tar.gz" fn_fetch_file "http://linux.mtasa.com/dl/multitheftauto_linux_x64.tar.gz" "${tmpdir}" "multitheftauto_linux_x64.tar.gz"
@ -99,9 +99,9 @@ fn_update_mta_localbuild(){
fn_update_mta_remotebuild(){ fn_update_mta_remotebuild(){
# Gets remote build info. # Gets remote build info.
majorversion="$(curl -s https://raw.githubusercontent.com/multitheftauto/mtasa-blue/master/Server/version.h | grep "#define MTASA_VERSION_MAJOR" | awk '{ print $3 }' | sed 's/\r//g')" majorversion=$(curl -s https://raw.githubusercontent.com/multitheftauto/mtasa-blue/master/Server/version.h | grep "#define MTASA_VERSION_MAJOR" | awk '{ print $3 }' | sed 's/\r//g')
minorversion="$(curl -s https://raw.githubusercontent.com/multitheftauto/mtasa-blue/master/Server/version.h | grep "#define MTASA_VERSION_MINOR" | awk '{ print $3 }' | sed 's/\r//g')" minorversion=$(curl -s https://raw.githubusercontent.com/multitheftauto/mtasa-blue/master/Server/version.h | grep "#define MTASA_VERSION_MINOR" | awk '{ print $3 }' | sed 's/\r//g')
maintenanceversion="$(curl -s https://raw.githubusercontent.com/multitheftauto/mtasa-blue/master/Server/version.h | grep "#define MTASA_VERSION_MAINTENANCE" | awk '{ print $3 }' | sed 's/\r//g')" maintenanceversion=$(curl -s https://raw.githubusercontent.com/multitheftauto/mtasa-blue/master/Server/version.h | grep "#define MTASA_VERSION_MAINTENANCE" | awk '{ print $3 }' | sed 's/\r//g')
remotebuild="${majorversion}.${minorversion}.${maintenanceversion}" remotebuild="${majorversion}.${minorversion}.${maintenanceversion}"
if [ "${installer}" != "1" ]; then if [ "${installer}" != "1" ]; then
fn_print_dots "Checking for update: ${remotelocation}: checking remote build" fn_print_dots "Checking for update: ${remotelocation}: checking remote build"

4
lgsm/functions/update_mumble.sh

@ -6,7 +6,7 @@
local commandname="UPDATE" local commandname="UPDATE"
local commandaction="Update" local commandaction="Update"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_update_mumble_dl(){ fn_update_mumble_dl(){
fn_fetch_file "https://github.com/mumble-voip/mumble/releases/download/${remotebuild}/murmur-static_${mumblearch}-${remotebuild}.tar.bz2" "${tmpdir}" "murmur-static_${mumblearch}-${remotebuild}.tar.bz2" fn_fetch_file "https://github.com/mumble-voip/mumble/releases/download/${remotebuild}/murmur-static_${mumblearch}-${remotebuild}.tar.bz2" "${tmpdir}" "murmur-static_${mumblearch}-${remotebuild}.tar.bz2"
@ -43,7 +43,7 @@ fn_update_mumble_localbuild(){
fn_update_mumble_remotebuild(){ fn_update_mumble_remotebuild(){
# Gets remote build info. # Gets remote build info.
remotebuild=$(${curlpath} -s "https://api.github.com/repos/mumble-voip/mumble/releases/latest" | grep 'murmur-static_x86.*\.bz2"' | tail -1 | awk -F"/" '{ print $8 }') remotebuild=$(curl -s "https://api.github.com/repos/mumble-voip/mumble/releases/latest" | grep 'murmur-static_x86.*\.bz2"' | tail -1 | awk -F"/" '{ print $8 }')
if [ "${installer}" != "1" ]; then if [ "${installer}" != "1" ]; then
fn_print_dots "Checking for update: ${remotelocation}: checking remote build" fn_print_dots "Checking for update: ${remotelocation}: checking remote build"
# Checks if remotebuild variable has been set. # Checks if remotebuild variable has been set.

4
lgsm/functions/update_steamcmd.sh

@ -6,14 +6,14 @@
local commandname="UPDATE" local commandname="UPDATE"
local commandaction="Update" local commandaction="Update"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_update_steamcmd_dl(){ fn_update_steamcmd_dl(){
info_config.sh info_config.sh
# Detects if unbuffer command is available for 32 bit distributions only. # Detects if unbuffer command is available for 32 bit distributions only.
info_distro.sh info_distro.sh
if [ "$(command -v stdbuf)" ]&&[ "${arch}" != "x86_64" ]; then if [ -n "$(command -v stdbuf)" ]&&[ "${arch}" != "x86_64" ]; then
unbuffer="stdbuf -i0 -o0 -e0" unbuffer="stdbuf -i0 -o0 -e0"
fi fi

14
lgsm/functions/update_ts3.sh

@ -6,13 +6,13 @@
local commandname="UPDATE" local commandname="UPDATE"
local commandaction="Update" local commandaction="Update"
local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" local function_selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")")
fn_update_ts3_dl(){ fn_update_ts3_dl(){
if [ "${ts3arch}" == "amd64" ]; then if [ "${ts3arch}" == "amd64" ]; then
remotebuildurl=$(${curlpath} -s 'https://www.teamspeak.com/versions/server.json' | jq -r '.linux.x86_64.mirrors."teamspeak.com"') remotebuildurl=$(curl -s 'https://www.teamspeak.com/versions/server.json' | jq -r '.linux.x86_64.mirrors."teamspeak.com"')
elif [ "${ts3arch}" == "x86" ]; then elif [ "${ts3arch}" == "x86" ]; then
remotebuildurl=$(${curlpath} -s 'https://www.teamspeak.com/versions/server.json' | jq -r '.linux.x86.mirrors."teamspeak.com"') remotebuildurl=$(curl -s 'https://www.teamspeak.com/versions/server.json' | jq -r '.linux.x86.mirrors."teamspeak.com"')
fi fi
fn_fetch_file "${remotebuildurl}" "${tmpdir}" "teamspeak3-server_linux_${ts3arch}-${remotebuild}.tar.bz2" fn_fetch_file "${remotebuildurl}" "${tmpdir}" "teamspeak3-server_linux_${ts3arch}-${remotebuild}.tar.bz2"
fn_dl_extract "${tmpdir}" "teamspeak3-server_linux_${ts3arch}-${remotebuild}.tar.bz2" "${tmpdir}" fn_dl_extract "${tmpdir}" "teamspeak3-server_linux_${ts3arch}-${remotebuild}.tar.bz2" "${tmpdir}"
@ -68,7 +68,7 @@ fn_update_ts3_localbuild(){
fi fi
if [ -z "${localbuild}" ]; then if [ -z "${localbuild}" ]; then
localbuild=$(cat $(find ./* -name "ts3server*_0.log" 2> /dev/null | sort | tail -1) | grep -Eo "TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | grep -Eo "((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | tail -1) localbuild=$(cat "$(find ./* -name "ts3server*_0.log" 2> /dev/null | sort | tail -1)" | grep -Eo "TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | grep -Eo "((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | tail -1)
fi fi
if [ -z "${localbuild}" ]; then if [ -z "${localbuild}" ]; then
@ -81,7 +81,7 @@ fn_update_ts3_localbuild(){
loopignore=1 loopignore=1
fn_script_log_info "Waiting for local build to generate" fn_script_log_info "Waiting for local build to generate"
fi fi
localbuild=$(cat $(find ./* -name "ts3server*_0.log" 2> /dev/null | sort | tail -1) | grep -Eo "TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | grep -Eo "((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | tail -1) localbuild=$(cat "$(find ./* -name "ts3server*_0.log" 2> /dev/null | sort | tail -1)" | grep -Eo "TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | grep -Eo "((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | tail -1)
if [ "${localbuild}" ]; then if [ "${localbuild}" ]; then
break break
fi fi
@ -104,9 +104,9 @@ fn_update_ts3_localbuild(){
fn_update_ts3_remotebuild(){ fn_update_ts3_remotebuild(){
# Gets remote build info. # Gets remote build info.
if [ "${arch}" == "x86_64" ]; then if [ "${arch}" == "x86_64" ]; then
remotebuild="$(${curlpath} -s "https://www.teamspeak.com/versions/server.json" | jq -r '.linux.x86_64.version')" remotebuild=$(curl -s "https://www.teamspeak.com/versions/server.json" | jq -r '.linux.x86_64.version')
elif [ "${arch}" == "x86" ]; then elif [ "${arch}" == "x86" ]; then
remotebuild="$(${curlpath} -s "https://www.teamspeak.com/versions/server.json" | jq -r '.linux.x86.version')" remotebuild=$(curl -s "https://www.teamspeak.com/versions/server.json" | jq -r '.linux.x86.version')
fi fi
if [ "${installer}" != "1" ]; then if [ "${installer}" != "1" ]; then
fn_print_dots "Checking for update: ${remotelocation}: checking remote build" fn_print_dots "Checking for update: ${remotelocation}: checking remote build"

19
linuxgsm.sh

@ -23,8 +23,8 @@ fi
version="v19.11.0" version="v19.11.0"
shortname="core" shortname="core"
gameservername="core" gameservername="core"
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=".${selfname}.lock" lockselfname=".${selfname}.lock"
lgsmdir="${rootdir}/lgsm" lgsmdir="${rootdir}/lgsm"
logdir="${rootdir}/log" logdir="${rootdir}/log"
@ -51,7 +51,7 @@ githubbranch="master"
# Core function that is required first. # Core function that is required first.
core_functions.sh(){ core_functions.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5" fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5"
} }
@ -70,14 +70,12 @@ fn_bootstrap_fetch_file(){
if [ ! -d "${local_filedir}" ]; then if [ ! -d "${local_filedir}" ]; then
mkdir -p "${local_filedir}" mkdir -p "${local_filedir}"
fi fi
# Defines curl path.
curlpath=$(command -v curl 2>/dev/null)
# If curl exists download file. # If curl exists download file.
if [ "$(basename "${curlpath}")" == "curl" ]; then if [ -n "$(command -v curl 2>/dev/null)" ]; then
# Trap to remove part downloaded files. # Trap to remove part downloaded files.
echo -en " fetching ${local_filename}...\c" echo -en " fetching ${local_filename}...\c"
curlcmd=$(${curlpath} -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1) curlcmd=$(curl -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1)
local exitcode=$? local exitcode=$?
if [ ${exitcode} -ne 0 ]; then if [ ${exitcode} -ne 0 ]; then
echo -e "FAIL" echo -e "FAIL"
@ -127,14 +125,13 @@ fn_bootstrap_fetch_file_github(){
# Installer menu. # Installer menu.
fn_print_center() { fn_print_center() {
columns="$(tput cols)" columns=$(tput cols)
line="$*" line="$*"
printf "%*s\n" $(( (${#line} + columns) / 2)) "${line}" printf "%*s\n" $(( (${#line} + columns) / 2)) "${line}"
} }
fn_print_horizontal(){ fn_print_horizontal(){
char="${1:-=}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "="
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "${char}"
} }
# Bash menu. # Bash menu.
@ -237,7 +234,7 @@ fn_install_file(){
if [ -e "${local_filename}" ]; then if [ -e "${local_filename}" ]; then
i=2 i=2
while [ -e "${local_filename}-${i}" ] ; do while [ -e "${local_filename}-${i}" ] ; do
let i++ (( i++ ))
done done
local_filename="${local_filename}-${i}" local_filename="${local_filename}-${i}"
fi fi

19
tests/tests_fctrserver.sh

@ -23,8 +23,8 @@ fi
version="v19.9.0" version="v19.9.0"
shortname="fctr" shortname="fctr"
gameservername="fctrserver" gameservername="fctrserver"
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=".${selfname}.lock" lockselfname=".${selfname}.lock"
lgsmdir="${rootdir}/lgsm" lgsmdir="${rootdir}/lgsm"
logdir="${rootdir}/log" logdir="${rootdir}/log"
@ -60,7 +60,7 @@ githubbranch="${TRAVIS_BRANCH}"
# Core function that is required first. # Core function that is required first.
core_functions.sh(){ core_functions.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5" fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5"
} }
@ -81,14 +81,12 @@ fn_bootstrap_fetch_file(){
if [ ! -d "${local_filedir}" ]; then if [ ! -d "${local_filedir}" ]; then
mkdir -p "${local_filedir}" mkdir -p "${local_filedir}"
fi fi
# Defines curl path.
curlpath=$(command -v curl 2>/dev/null)
# If curl exists download file. # If curl exists download file.
if [ "$(basename "${curlpath}")" == "curl" ]; then if [ -n "$(command -v curl 2>/dev/null)" ]; then
# Trap to remove part downloaded files. # Trap to remove part downloaded files.
echo -en " fetching ${local_filename}...\c" echo -en " fetching ${local_filename}...\c"
curlcmd=$(${curlpath} -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1) curlcmd=$(curl -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1)
local exitcode=$? local exitcode=$?
if [ ${exitcode} -ne 0 ]; then if [ ${exitcode} -ne 0 ]; then
echo -e "FAIL" echo -e "FAIL"
@ -138,14 +136,13 @@ fn_bootstrap_fetch_file_github(){
# Installer menu. # Installer menu.
fn_print_center() { fn_print_center() {
columns="$(tput cols)" columns=$(tput cols)
line="$*" line="$*"
printf "%*s\n" $(( (${#line} + columns) / 2)) "${line}" printf "%*s\n" $(( (${#line} + columns) / 2)) "${line}"
} }
fn_print_horizontal(){ fn_print_horizontal(){
char="${1:-=}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "="
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "${char}"
} }
# Bash menu. # Bash menu.
@ -248,7 +245,7 @@ fn_install_file(){
if [ -e "${local_filename}" ]; then if [ -e "${local_filename}" ]; then
i=2 i=2
while [ -e "${local_filename}-${i}" ] ; do while [ -e "${local_filename}-${i}" ] ; do
let i++ (( i++ ))
done done
local_filename="${local_filename}-${i}" local_filename="${local_filename}-${i}"
fi fi

18
tests/tests_jc2server.sh

@ -23,8 +23,8 @@ fi
version="v19.9.0" version="v19.9.0"
shortname="jc2" shortname="jc2"
gameservername="jc2server" gameservername="jc2server"
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=".${selfname}.lock" lockselfname=".${selfname}.lock"
lgsmdir="${rootdir}/lgsm" lgsmdir="${rootdir}/lgsm"
logdir="${rootdir}/log" logdir="${rootdir}/log"
@ -60,7 +60,7 @@ githubbranch="${TRAVIS_BRANCH}"
# Core function that is required first. # Core function that is required first.
core_functions.sh(){ core_functions.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5" fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5"
} }
@ -79,14 +79,12 @@ fn_bootstrap_fetch_file(){
if [ ! -d "${local_filedir}" ]; then if [ ! -d "${local_filedir}" ]; then
mkdir -p "${local_filedir}" mkdir -p "${local_filedir}"
fi fi
# Defines curl path.
curlpath=$(command -v curl 2>/dev/null)
# If curl exists download file. # If curl exists download file.
if [ "$(basename "${curlpath}")" == "curl" ]; then if [ "$(command -v curl 2>/dev/null)" ]; then
# Trap to remove part downloaded files. # Trap to remove part downloaded files.
echo -en " fetching ${local_filename}...\c" echo -en " fetching ${local_filename}...\c"
curlcmd=$(${curlpath} -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1) curlcmd=$(curl -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1)
local exitcode=$? local exitcode=$?
if [ ${exitcode} -ne 0 ]; then if [ ${exitcode} -ne 0 ]; then
echo -e "FAIL" echo -e "FAIL"
@ -111,6 +109,7 @@ fn_bootstrap_fetch_file(){
if [ -f "${local_filedir}/${local_filename}" ]; then if [ -f "${local_filedir}/${local_filename}" ]; then
# Run file if run is set. # Run file if run is set.
if [ "${run}" == "run" ]; then if [ "${run}" == "run" ]; then
# shellcheck source=/dev/null
source "${local_filedir}/${local_filename}" source "${local_filedir}/${local_filename}"
fi fi
fi fi
@ -135,14 +134,13 @@ fn_bootstrap_fetch_file_github(){
# Installer menu. # Installer menu.
fn_print_center() { fn_print_center() {
columns="$(tput cols)" columns=$(tput cols)
line="$*" line="$*"
printf "%*s\n" $(( (${#line} + columns) / 2)) "${line}" printf "%*s\n" $(( (${#line} + columns) / 2)) "${line}"
} }
fn_print_horizontal(){ fn_print_horizontal(){
char="${1:-=}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "="
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "${char}"
} }
# Bash menu. # Bash menu.

19
tests/tests_mcserver.sh

@ -23,8 +23,8 @@ fi
version="v19.9.0" version="v19.9.0"
shortname="mc" shortname="mc"
gameservername="mcserver" gameservername="mcserver"
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=".${selfname}.lock" lockselfname=".${selfname}.lock"
lgsmdir="${rootdir}/lgsm" lgsmdir="${rootdir}/lgsm"
logdir="${rootdir}/log" logdir="${rootdir}/log"
@ -60,7 +60,7 @@ githubbranch="${TRAVIS_BRANCH}"
# Core function that is required first. # Core function that is required first.
core_functions.sh(){ core_functions.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5" fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5"
} }
@ -79,14 +79,12 @@ fn_bootstrap_fetch_file(){
if [ ! -d "${local_filedir}" ]; then if [ ! -d "${local_filedir}" ]; then
mkdir -p "${local_filedir}" mkdir -p "${local_filedir}"
fi fi
# Defines curl path.
curlpath=$(command -v curl 2>/dev/null)
# If curl exists download file. # If curl exists download file.
if [ "$(basename "${curlpath}")" == "curl" ]; then if [ -n "$(command -v curl 2>/dev/null)" ]; then
# Trap to remove part downloaded files. # Trap to remove part downloaded files.
echo -en " fetching ${local_filename}...\c" echo -en " fetching ${local_filename}...\c"
curlcmd=$(${curlpath} -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1) curlcmd=$(curl -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1)
local exitcode=$? local exitcode=$?
if [ ${exitcode} -ne 0 ]; then if [ ${exitcode} -ne 0 ]; then
echo -e "FAIL" echo -e "FAIL"
@ -111,7 +109,7 @@ fn_bootstrap_fetch_file(){
if [ -f "${local_filedir}/${local_filename}" ]; then if [ -f "${local_filedir}/${local_filename}" ]; then
# Run file if run is set. # Run file if run is set.
if [ "${run}" == "run" ]; then if [ "${run}" == "run" ]; then
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "${local_filedir}/${local_filename}" source "${local_filedir}/${local_filename}"
fi fi
fi fi
@ -136,14 +134,13 @@ fn_bootstrap_fetch_file_github(){
# Installer menu. # Installer menu.
fn_print_center() { fn_print_center() {
columns="$(tput cols)" columns=$(tput cols)
line="$*" line="$*"
printf "%*s\n" $(( (${#line} + columns) / 2)) "${line}" printf "%*s\n" $(( (${#line} + columns) / 2)) "${line}"
} }
fn_print_horizontal(){ fn_print_horizontal(){
char="${1:-=}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "="
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "${char}"
} }
# Bash menu. # Bash menu.

21
tests/tests_ts3server.sh

@ -23,8 +23,8 @@ fi
version="v19.9.0" version="v19.9.0"
shortname="ts3" shortname="ts3"
gameservername="ts3server" gameservername="ts3server"
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=".${selfname}.lock" lockselfname=".${selfname}.lock"
lgsmdir="${rootdir}/lgsm" lgsmdir="${rootdir}/lgsm"
logdir="${rootdir}/log" logdir="${rootdir}/log"
@ -60,7 +60,7 @@ githubbranch="${TRAVIS_BRANCH}"
# Core function that is required first. # Core function that is required first.
core_functions.sh(){ core_functions.sh(){
functionfile="${FUNCNAME}" functionfile="${FUNCNAME[0]}"
fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5" fn_bootstrap_fetch_file_github "lgsm/functions" "core_functions.sh" "${functionsdir}" "chmodx" "run" "noforcedl" "nomd5"
} }
@ -79,14 +79,12 @@ fn_bootstrap_fetch_file(){
if [ ! -d "${local_filedir}" ]; then if [ ! -d "${local_filedir}" ]; then
mkdir -p "${local_filedir}" mkdir -p "${local_filedir}"
fi fi
# Defines curl path.
curlpath=$(command -v curl 2>/dev/null)
# If curl exists download file. # If curl exists download file.
if [ "$(basename "${curlpath}")" == "curl" ]; then if [ -n "$(command -v curl 2>/dev/null)" ]; then
# Trap to remove part downloaded files. # Trap to remove part downloaded files.
echo -en " fetching ${local_filename}...\c" echo -en " fetching ${local_filename}...\c"
curlcmd=$(${curlpath} -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1) curlcmd=$(curl -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1)
local exitcode=$? local exitcode=$?
if [ ${exitcode} -ne 0 ]; then if [ ${exitcode} -ne 0 ]; then
echo -e "FAIL" echo -e "FAIL"
@ -111,7 +109,7 @@ fn_bootstrap_fetch_file(){
if [ -f "${local_filedir}/${local_filename}" ]; then if [ -f "${local_filedir}/${local_filename}" ]; then
# Run file if run is set. # Run file if run is set.
if [ "${run}" == "run" ]; then if [ "${run}" == "run" ]; then
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "${local_filedir}/${local_filename}" source "${local_filedir}/${local_filename}"
fi fi
fi fi
@ -136,14 +134,13 @@ fn_bootstrap_fetch_file_github(){
# Installer menu. # Installer menu.
fn_print_center() { fn_print_center() {
columns="$(tput cols)" columns=$(tput cols)
line="$*" line="$*"
printf "%*s\n" $(( (${#line} + columns) / 2)) "${line}" printf "%*s\n" $(( (${#line} + columns) / 2)) "${line}"
} }
fn_print_horizontal(){ fn_print_horizontal(){
char="${1:-=}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "="
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "${char}"
} }
# Bash menu. # Bash menu.
@ -246,7 +243,7 @@ fn_install_file(){
if [ -e "${local_filename}" ]; then if [ -e "${local_filename}" ]; then
i=2 i=2
while [ -e "${local_filename}-${i}" ] ; do while [ -e "${local_filename}-${i}" ] ; do
let i++ (( i++ ))
done done
local_filename="${local_filename}-${i}" local_filename="${local_filename}-${i}"
fi fi

Loading…
Cancel
Save