twserver 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #!/bin/bash
  2. # Teeworlds
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Contributor: Bryce Van Dyk (SingingTree)
  6. # Website: http://gameservermanagers.com
  7. version="121215"
  8. #### Variables ####
  9. # Notification Email
  10. # (on|off)
  11. emailnotification="off"
  12. email="email@example.com"
  13. # Steam login
  14. steamuser="username"
  15. steampass="password"
  16. # Start Variables
  17. ip="0.0.0.0"
  18. updateonstart="off"
  19. fn_parms(){
  20. parms="-f ${servercfgfullpath}"
  21. }
  22. #### Advanced Variables ####
  23. # Github Branch Select
  24. # Allows for the use of different function files
  25. # from a different repo and/or branch.
  26. githubuser="dgibbs64"
  27. githubrepo="linuxgsm"
  28. githubbranch="master"
  29. # Steam
  30. appid="380840"
  31. # Server Details
  32. servicename="tw-server"
  33. gamename="Teeworlds"
  34. engine="teeworlds"
  35. # Directories
  36. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  37. selfname=$(basename $(readlink -f "${BASH_SOURCE[0]}"))
  38. lockselfname=".${servicename}.lock"
  39. filesdir="${rootdir}/serverfiles"
  40. systemdir="${filesdir}"
  41. executabledir="${filesdir}"
  42. executable="./teeworlds_srv"
  43. servercfg="${servicename}.cfg" # Teeworlds can also auto load any config if an autoexec.cfg file is present in the server dir
  44. servercfgdir="${filesdir}"
  45. servercfgfullpath="${servercfgdir}/${servercfg}"
  46. servercfgdefault="${servercfgdir}/lgsm-default.cfg"
  47. backupdir="${rootdir}/backups"
  48. # Logging
  49. logdays="7"
  50. gamelogdir="${rootdir}/log/server"
  51. scriptlogdir="${rootdir}/log/script"
  52. consolelogdir="${rootdir}/log/console"
  53. gamelog="${gamelogdir}/${servicename}-game.log"
  54. scriptlog="${scriptlogdir}/${servicename}-script.log"
  55. consolelog="${consolelogdir}/${servicename}-console.log"
  56. emaillog="${scriptlogdir}/${servicename}-email.log"
  57. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  58. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  59. ##### Script #####
  60. # Do not edit
  61. fn_getgithubfile(){
  62. filename=$1
  63. exec=$2
  64. fileurl=${3:-$filename}
  65. filepath="${rootdir}/${filename}"
  66. filedir=$(dirname "${filepath}")
  67. # If the function file is missing, then download
  68. if [ ! -f "${filepath}" ]; then
  69. if [ ! -d "${filedir}" ]; then
  70. mkdir "${filedir}"
  71. fi
  72. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  73. echo -e " fetching ${filename}...\c"
  74. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  75. :
  76. else
  77. echo -e "\e[0;31mFAIL\e[0m\n"
  78. echo "Curl is not installed!"
  79. echo -e ""
  80. exit
  81. fi
  82. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  83. if [ $? -ne 0 ]; then
  84. echo -e "\e[0;31mFAIL\e[0m\n"
  85. echo " ${curl}"|grep "curl:"
  86. echo -e "${githuburl}\n"
  87. exit
  88. else
  89. echo -e "\e[0;32mOK\e[0m"
  90. fi
  91. if [ "${exec}" ]; then
  92. chmod +x "${filepath}"
  93. fi
  94. fi
  95. if [ "${exec}" ]; then
  96. source "${filepath}"
  97. fi
  98. }
  99. fn_runfunction(){
  100. fn_getgithubfile "functions/${functionfile}" 1
  101. }
  102. fn_functions(){
  103. # Functions are defined in fn_functions.
  104. functionfile="${FUNCNAME}"
  105. fn_runfunction
  106. }
  107. fn_functions
  108. getopt=$1
  109. fn_getopt