ts3server 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #!/bin/bash
  2. # TeamSpeak 3
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: https://gameservermanagers.com
  6. if [ -f ".dev-debug" ]; then
  7. exec 5>dev-debug.log
  8. BASH_XTRACEFD="5"
  9. set -x
  10. fi
  11. version="290716"
  12. #### Variables ####
  13. # Notification Alerts
  14. # (on|off)
  15. # Email
  16. emailalert="off"
  17. email="email@example.com"
  18. # Pushbullet
  19. # https://www.pushbullet.com/#settings
  20. pushbulletalert="off"
  21. pushbullettoken="accesstoken"
  22. # Start Variables
  23. updateonstart="off"
  24. # Server Details
  25. gamename="TeamSpeak 3"
  26. servername="TeamSpeak 3 Server"
  27. servicename="ts3-server"
  28. # Directories
  29. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  30. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  31. lockselfname=".${servicename}.lock"
  32. lgsmdir="${rootdir}/lgsm"
  33. functionsdir="${lgsmdir}/functions"
  34. filesdir="${rootdir}/serverfiles"
  35. systemdir="${filesdir}"
  36. executabledir="${filesdir}"
  37. executable="./ts3server_startscript.sh"
  38. servercfg="${servicename}.ini"
  39. servercfgdir="${filesdir}"
  40. servercfgfullpath="${servercfgdir}/${servercfg}"
  41. servercfgdefault="${servercfgdir}/lgsm-default.ini"
  42. backupdir="${rootdir}/backups"
  43. # Logging
  44. logdays="7"
  45. gamelogdir="${filesdir}/logs"
  46. scriptlogdir="${rootdir}/log/script"
  47. scriptlog="${scriptlogdir}/${servicename}-script.log"
  48. emaillog="${scriptlogdir}/${servicename}-email.log"
  49. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  50. # Github Branch Select
  51. # Allows for the use of different function files
  52. # from a different repo and/or branch.
  53. githubuser="dgibbs64"
  54. githubrepo="linuxgsm"
  55. githubbranch="master"
  56. ##### Script #####
  57. # Do not edit
  58. # Fetches core_dl for file downloads
  59. fn_fetch_core_dl(){
  60. github_file_url_dir="lgsm/functions"
  61. github_file_url_name="${functionfile}"
  62. filedir="${functionsdir}"
  63. filename="${github_file_url_name}"
  64. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  65. # If the file is missing, then download
  66. if [ ! -f "${filedir}/${filename}" ]; then
  67. if [ ! -d "${filedir}" ]; then
  68. mkdir -p "${filedir}"
  69. fi
  70. echo -e " fetching ${filename}...\c"
  71. # Check curl exists and use available path
  72. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  73. for curlcmd in ${curlpaths}
  74. do
  75. if [ -x "${curlcmd}" ]; then
  76. break
  77. fi
  78. done
  79. # If curl exists download file
  80. if [ "$(basename ${curlcmd})" == "curl" ]; then
  81. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  82. if [ $? -ne 0 ]; then
  83. echo -e "\e[0;31mFAIL\e[0m\n"
  84. echo "${curlfetch}"
  85. echo -e "${githuburl}\n"
  86. exit 1
  87. else
  88. echo -e "\e[0;32mOK\e[0m"
  89. fi
  90. else
  91. echo -e "\e[0;31mFAIL\e[0m\n"
  92. echo "Curl is not installed!"
  93. echo -e ""
  94. exit 1
  95. fi
  96. chmod +x "${filedir}/${filename}"
  97. fi
  98. source "${filedir}/${filename}"
  99. }
  100. core_dl.sh(){
  101. # Functions are defined in core_functions.sh.
  102. functionfile="${FUNCNAME}"
  103. fn_fetch_core_dl
  104. }
  105. core_functions.sh(){
  106. # Functions are defined in core_functions.sh.
  107. functionfile="${FUNCNAME}"
  108. fn_fetch_core_dl
  109. }
  110. core_dl.sh
  111. core_functions.sh
  112. getopt=$1
  113. core_getopt.sh