ts3server 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/bash
  2. # Teamspeak 3
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: http://gameservermanagers.com
  6. version="121215"
  7. #### Variables ####
  8. # Notification Email
  9. # (on|off)
  10. emailnotification="off"
  11. email="email@example.com"
  12. # Start Variables
  13. updateonstart="off"
  14. # Server Details
  15. gamename="Teamspeak 3"
  16. servername="Teamspeak 3 Server"
  17. servicename="ts3-server"
  18. # Directories
  19. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  20. selfname=$(basename $(readlink -f "${BASH_SOURCE[0]}"))
  21. lockselfname=".${servicename}.lock"
  22. filesdir="${rootdir}/serverfiles"
  23. systemdir="${filesdir}"
  24. executabledir="${filesdir}"
  25. executable="./ts3server_startscript.sh"
  26. servercfg="${servicename}.ini"
  27. servercfgdir="${filesdir}"
  28. servercfgfullpath="${servercfgdir}/${servercfg}"
  29. backupdir="${rootdir}/backups"
  30. # Logging
  31. logdays="7"
  32. gamelogdir="${filesdir}/logs"
  33. scriptlogdir="${rootdir}/log/script"
  34. scriptlog="${scriptlogdir}/${servicename}-script.log"
  35. emaillog="${scriptlogdir}/${servicename}-email.log"
  36. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  37. # Github Branch Select
  38. # Allows for the use of different function files
  39. # from a different repo and/or branch.
  40. githubuser="dgibbs64"
  41. githubrepo="linuxgsm"
  42. githubbranch="master"
  43. ##### Script #####
  44. # Do not edit
  45. fn_getgithubfile(){
  46. filename=$1
  47. exec=$2
  48. fileurl=${3:-$filename}
  49. filepath="${rootdir}/${filename}"
  50. filedir=$(dirname "${filepath}")
  51. # If the function file is missing, then download
  52. if [ ! -f "${filepath}" ]; then
  53. if [ ! -d "${filedir}" ]; then
  54. mkdir "${filedir}"
  55. fi
  56. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  57. echo -e " fetching ${filename}...\c"
  58. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  59. echo -e "\e[0;31mFAIL\e[0m\n"
  60. echo "Curl is not installed!"
  61. echo -e ""
  62. exit
  63. fi
  64. CURL=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  65. if [ $? -ne 0 ]; then
  66. echo -e "\e[0;31mFAIL\e[0m\n"
  67. echo " $CURL"|grep "curl:"
  68. echo -e "${githuburl}\n"
  69. exit
  70. else
  71. echo -e "\e[0;32mOK\e[0m"
  72. fi
  73. if [ "${exec}" ]; then
  74. chmod +x "${filepath}"
  75. fi
  76. fi
  77. if [ "${exec}" ]; then
  78. source "${filepath}"
  79. fi
  80. }
  81. fn_runfunction(){
  82. fn_getgithubfile "functions/${functionfile}" 1
  83. }
  84. fn_functions(){
  85. # Functions are defined in fn_functions.
  86. functionfile="${FUNCNAME}"
  87. fn_runfunction
  88. }
  89. fn_functions
  90. getopt=$1
  91. fn_getopt