gmodserver 2.6 KB

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