ts3server 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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="201215"
  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. backupdir="${rootdir}/backups"
  35. # Logging
  36. logdays="7"
  37. gamelogdir="${filesdir}/logs"
  38. scriptlogdir="${rootdir}/log/script"
  39. scriptlog="${scriptlogdir}/${servicename}-script.log"
  40. emaillog="${scriptlogdir}/${servicename}-email.log"
  41. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  42. # Github Branch Select
  43. # Allows for the use of different function files
  44. # from a different repo and/or branch.
  45. githubuser="dgibbs64"
  46. githubrepo="linuxgsm"
  47. githubbranch="master"
  48. ##### Script #####
  49. # Do not edit
  50. fn_getgithubfile(){
  51. filename=$1
  52. exec=$2
  53. fileurl=${3:-$filename}
  54. filepath="${rootdir}/${filename}"
  55. filedir=$(dirname "${filepath}")
  56. # If the function file is missing, then download
  57. if [ ! -f "${filepath}" ]; then
  58. if [ ! -d "${filedir}" ]; then
  59. mkdir "${filedir}"
  60. fi
  61. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  62. echo -e " fetching ${filename}...\c"
  63. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  64. :
  65. else
  66. echo -e "\e[0;31mFAIL\e[0m\n"
  67. echo "Curl is not installed!"
  68. echo -e ""
  69. exit
  70. fi
  71. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  72. if [ $? -ne 0 ]; then
  73. echo -e "\e[0;31mFAIL\e[0m\n"
  74. echo "${curl}"
  75. echo -e "${githuburl}\n"
  76. exit
  77. else
  78. echo -e "\e[0;32mOK\e[0m"
  79. fi
  80. if [ "${exec}" ]; then
  81. chmod +x "${filepath}"
  82. fi
  83. fi
  84. if [ "${exec}" ]; then
  85. source "${filepath}"
  86. fi
  87. }
  88. fn_runfunction(){
  89. fn_getgithubfile "functions/${functionfile}" 1
  90. }
  91. fn_functions(){
  92. # Functions are defined in fn_functions.
  93. functionfile="${FUNCNAME}"
  94. fn_runfunction
  95. }
  96. fn_functions
  97. getopt=$1
  98. fn_getopt