ts3server 3.1 KB

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