ts3server 2.9 KB

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