tf2server 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/bash
  2. # Team Fortress 2
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: http://gameservermanagers.com
  6. version="091215"
  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. # Steam
  33. appid="232250"
  34. # Server Details
  35. servicename="tf2-server"
  36. gamename="Team Fortress 2"
  37. engine="source"
  38. # Directories
  39. rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  40. selfname="$(basename $0)"
  41. lockselfname=".${servicename}.lock"
  42. filesdir="${rootdir}/serverfiles"
  43. systemdir="${filesdir}/tf"
  44. executabledir="${filesdir}"
  45. executable="./srcds_run"
  46. servercfg="${servicename}.cfg"
  47. servercfgdir="${systemdir}/cfg"
  48. servercfgfullpath="${servercfgdir}/${servercfg}"
  49. servercfgdefault="${servercfgdir}/lgsm-default.cfg"
  50. backupdir="${rootdir}/backups"
  51. # Logging
  52. logdays="7"
  53. gamelogdir="${systemdir}/logs"
  54. scriptlogdir="${rootdir}/log/script"
  55. consolelogdir="${rootdir}/log/console"
  56. scriptlog="${scriptlogdir}/${servicename}-script.log"
  57. consolelog="${consolelogdir}/${servicename}-console.log"
  58. emaillog="${scriptlogdir}/${servicename}-email.log"
  59. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  60. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  61. ##### Script #####
  62. # Do not edit
  63. fn_runfunction(){
  64. # Functions are downloaded and run with this function
  65. if [ ! -f "${rootdir}/functions/${functionfile}" ]; then
  66. cd "${rootdir}"
  67. if [ ! -d "functions" ]; then
  68. mkdir functions
  69. fi
  70. cd functions
  71. echo -e " loading ${functionfile}...\c"
  72. wget -N /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/functions/${functionfile} 2>&1 | grep -F HTTP | cut -c45-
  73. chmod +x "${functionfile}"
  74. cd "${rootdir}"
  75. fi
  76. source "${rootdir}/functions/${functionfile}"
  77. }
  78. fn_functions(){
  79. # Functions are defined in fn_functions.
  80. functionfile="${FUNCNAME}"
  81. fn_runfunction
  82. }
  83. fn_functions
  84. getopt=$1
  85. fn_getopt