4
0

tf2server 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #!/bin/bash
  2. # Team Fortress 2
  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. # Steam login
  13. steamuser="anonymous"
  14. steampass=""
  15. # Start Variables
  16. defaultmap="cp_badlands"
  17. maxplayers="16"
  18. port="27015"
  19. sourcetvport="27020"
  20. clientport="27005"
  21. ip="0.0.0.0"
  22. updateonstart="off"
  23. # Optional: Game Server Login Token
  24. # GSLT can be used for running a public server.
  25. # More info: http://gameservermanagers.com/gslt
  26. gslt=""
  27. # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
  28. fn_parms(){
  29. parms="-game tf -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +map ${defaultmap} +sv_setsteamaccount ${gslt} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
  30. }
  31. #### Advanced Variables ####
  32. # Github Branch Select
  33. # Allows for the use of different function files
  34. # from a different repo and/or branch.
  35. githubuser="dgibbs64"
  36. githubrepo="linuxgsm"
  37. githubbranch="master"
  38. # Steam
  39. appid="232250"
  40. # Server Details
  41. servicename="tf2-server"
  42. gamename="Team Fortress 2"
  43. engine="source"
  44. # Directories
  45. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  46. selfname=$(basename $(readlink -f "${BASH_SOURCE[0]}"))
  47. lockselfname=".${servicename}.lock"
  48. filesdir="${rootdir}/serverfiles"
  49. systemdir="${filesdir}/tf"
  50. executabledir="${filesdir}"
  51. executable="./srcds_run"
  52. servercfg="${servicename}.cfg"
  53. servercfgdir="${systemdir}/cfg"
  54. servercfgfullpath="${servercfgdir}/${servercfg}"
  55. servercfgdefault="${servercfgdir}/lgsm-default.cfg"
  56. backupdir="${rootdir}/backups"
  57. # Logging
  58. logdays="7"
  59. gamelogdir="${systemdir}/logs"
  60. scriptlogdir="${rootdir}/log/script"
  61. consolelogdir="${rootdir}/log/console"
  62. scriptlog="${scriptlogdir}/${servicename}-script.log"
  63. consolelog="${consolelogdir}/${servicename}-console.log"
  64. emaillog="${scriptlogdir}/${servicename}-email.log"
  65. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  66. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  67. ##### Script #####
  68. # Do not edit
  69. fn_getgithubfile(){
  70. filename=$1
  71. exec=$2
  72. fileurl=${3:-$filename}
  73. filepath="${rootdir}/${filename}"
  74. filedir=$(dirname "${filepath}")
  75. # If the function file is missing, then download
  76. if [ ! -f "${filepath}" ]; then
  77. if [ ! -d "${filedir}" ]; then
  78. mkdir "${filedir}"
  79. fi
  80. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  81. echo -e " fetching ${filename}...\c"
  82. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  83. :
  84. else
  85. echo -e "\e[0;31mFAIL\e[0m\n"
  86. echo "Curl is not installed!"
  87. echo -e ""
  88. exit
  89. fi
  90. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  91. if [ $? -ne 0 ]; then
  92. echo -e "\e[0;31mFAIL\e[0m\n"
  93. echo " ${curl}"|grep "curl:"
  94. echo -e "${githuburl}\n"
  95. exit
  96. else
  97. echo -e "\e[0;32mOK\e[0m"
  98. fi
  99. if [ "${exec}" ]; then
  100. chmod +x "${filepath}"
  101. fi
  102. fi
  103. if [ "${exec}" ]; then
  104. source "${filepath}"
  105. fi
  106. }
  107. fn_runfunction(){
  108. fn_getgithubfile "functions/${functionfile}" 1
  109. }
  110. fn_functions(){
  111. # Functions are defined in fn_functions.
  112. functionfile="${FUNCNAME}"
  113. fn_runfunction
  114. }
  115. fn_functions
  116. getopt=$1
  117. fn_getopt