l4d2server 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/bin/bash
  2. # Left 4 Dead 2
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: http://gameservermanagers.com
  6. version="040715"
  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="c5m1_waterfront"
  17. maxplayers="8"
  18. port="27015"
  19. clientport="27005"
  20. ip="0.0.0.0"
  21. updateonstart="off"
  22. # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
  23. fn_parms(){
  24. parms="-game left4dead2 -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
  25. }
  26. #### Advanced Variables ####
  27. # Steam
  28. appid="222860"
  29. # Server Details
  30. servicename="l4d2-server"
  31. gamename="Left 4 Dead 2"
  32. engine="source"
  33. # Directories
  34. rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  35. selfname="$(basename $0)"
  36. lockselfname=".${servicename}.lock"
  37. filesdir="${rootdir}/serverfiles"
  38. systemdir="${filesdir}/left4dead2"
  39. executabledir="${filesdir}"
  40. executable="./srcds_run"
  41. servercfg="${servicename}.cfg"
  42. servercfgdir="${systemdir}/cfg"
  43. servercfgfullpath="${servercfgdir}/${servercfg}"
  44. servercfgdefault="${servercfgdir}/server.cfg"
  45. backupdir="${rootdir}/backups"
  46. # Logging
  47. logdays="7"
  48. gamelogdir="${systemdir}/logs"
  49. scriptlogdir="${rootdir}/log/script"
  50. consolelogdir="${rootdir}/log/console"
  51. scriptlog="${scriptlogdir}/${servicename}-script.log"
  52. consolelog="${consolelogdir}/${servicename}-console.log"
  53. emaillog="${scriptlogdir}/${servicename}-email.log"
  54. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  55. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  56. ##### Script #####
  57. # Do not edit
  58. fn_runfunction(){
  59. # Functions are downloaded and run with this function
  60. if [ ! -f "${rootdir}/functions/${functionfile}" ]; then
  61. cd "${rootdir}"
  62. if [ ! -d "functions" ]; then
  63. mkdir functions
  64. fi
  65. cd functions
  66. echo -e " loading ${functionfile}...\c"
  67. wget -N /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/functions/${functionfile} 2>&1 | grep -F HTTP | cut -c45-
  68. chmod +x "${functionfile}"
  69. cd "${rootdir}"
  70. fi
  71. source "${rootdir}/functions/${functionfile}"
  72. }
  73. fn_functions(){
  74. # Functions are defined in fn_functions.
  75. functionfile="${FUNCNAME}"
  76. fn_runfunction
  77. }
  78. fn_functions
  79. getopt=$1
  80. fn_getopt