ts3server 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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="251215"
  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. fn_getgithubfile(){
  52. filename=$1
  53. exec=$2
  54. fileurl=${3:-$filename}
  55. filepath="${rootdir}/${filename}"
  56. filedir=$(dirname "${filepath}")
  57. # If the function file is missing, then download
  58. if [ ! -f "${filepath}" ]; then
  59. if [ ! -d "${filedir}" ]; then
  60. mkdir "${filedir}"
  61. fi
  62. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  63. echo -e " fetching ${filename}...\c"
  64. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  65. :
  66. else
  67. echo -e "\e[0;31mFAIL\e[0m\n"
  68. echo "Curl is not installed!"
  69. echo -e ""
  70. exit
  71. fi
  72. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  73. if [ $? -ne 0 ]; then
  74. echo -e "\e[0;31mFAIL\e[0m\n"
  75. echo "${curl}"
  76. echo -e "${githuburl}\n"
  77. exit
  78. else
  79. echo -e "\e[0;32mOK\e[0m"
  80. fi
  81. if [ "${exec}" ]; then
  82. chmod +x "${filepath}"
  83. fi
  84. fi
  85. if [ "${exec}" ]; then
  86. source "${filepath}"
  87. fi
  88. }
  89. fn_runfunction(){
  90. fn_getgithubfile "functions/${functionfile}" 1
  91. }
  92. core_functions.sh(){
  93. # Functions are defined in core_functions.sh.
  94. functionfile="${FUNCNAME}"
  95. fn_runfunction
  96. }
  97. core_functions.sh
  98. getopt=$1
  99. core_getopt.sh