ts3server 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. libdir="${lgsmdir}/lib"
  35. tmpdir="${lgsmdir}/tmp"
  36. filesdir="${rootdir}/serverfiles"
  37. systemdir="${filesdir}"
  38. executabledir="${filesdir}"
  39. executable="./ts3server_startscript.sh"
  40. servercfg="${servicename}.ini"
  41. servercfgdir="${filesdir}"
  42. servercfgfullpath="${servercfgdir}/${servercfg}"
  43. servercfgdefault="${servercfgdir}/lgsm-default.ini"
  44. backupdir="${rootdir}/backups"
  45. # Logging
  46. logdays="7"
  47. gamelogdir="${filesdir}/logs"
  48. scriptlogdir="${rootdir}/log/script"
  49. scriptlog="${scriptlogdir}/${servicename}-script.log"
  50. emaillog="${scriptlogdir}/${servicename}-email.log"
  51. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  52. # Github Branch Select
  53. # Allows for the use of different function files
  54. # from a different repo and/or branch.
  55. githubuser="GameServerManagers"
  56. githubrepo="LinuxGSM"
  57. githubbranch="master"
  58. ##### Script #####
  59. # Do not edit
  60. # Fetches core_dl for file downloads
  61. fn_fetch_core_dl(){
  62. github_file_url_dir="lgsm/functions"
  63. github_file_url_name="${functionfile}"
  64. filedir="${functionsdir}"
  65. filename="${github_file_url_name}"
  66. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  67. # If the file is missing, then download
  68. if [ ! -f "${filedir}/${filename}" ]; then
  69. if [ ! -d "${filedir}" ]; then
  70. mkdir -p "${filedir}"
  71. fi
  72. echo -e " fetching ${filename}...\c"
  73. # Check curl exists and use available path
  74. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  75. for curlcmd in ${curlpaths}
  76. do
  77. if [ -x "${curlcmd}" ]; then
  78. break
  79. fi
  80. done
  81. # If curl exists download file
  82. if [ "$(basename ${curlcmd})" == "curl" ]; then
  83. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  84. if [ $? -ne 0 ]; then
  85. echo -e "\e[0;31mFAIL\e[0m\n"
  86. echo "${curlfetch}"
  87. echo -e "${githuburl}\n"
  88. exit 1
  89. else
  90. echo -e "\e[0;32mOK\e[0m"
  91. fi
  92. else
  93. echo -e "\e[0;31mFAIL\e[0m\n"
  94. echo "Curl is not installed!"
  95. echo -e ""
  96. exit 1
  97. fi
  98. chmod +x "${filedir}/${filename}"
  99. fi
  100. source "${filedir}/${filename}"
  101. }
  102. core_dl.sh(){
  103. # Functions are defined in core_functions.sh.
  104. functionfile="${FUNCNAME}"
  105. fn_fetch_core_dl
  106. }
  107. core_functions.sh(){
  108. # Functions are defined in core_functions.sh.
  109. functionfile="${FUNCNAME}"
  110. fn_fetch_core_dl
  111. }
  112. core_dl.sh
  113. core_functions.sh
  114. getopt=$1
  115. core_getopt.sh