Advertisement
Guest User

Gmod server

a guest
Sep 18th, 2016
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.77 KB | None | 0 0
  1. #!/bin/bash
  2. # Garry's Mod
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: https://gameservermanagers.com
  6. if [ -f ".dev-debug" ]; then
  7.     exec 5>dev-debug.log
  8.     BASH_XTRACEFD="5"
  9.     set -x
  10. fi
  11.  
  12. version="210516"
  13.  
  14. #### Variables ####
  15.  
  16. # Notification Alerts
  17. # (on|off)
  18.  
  19. # Email
  20. emailalert="off"
  21. email="email@example.com"
  22.  
  23. # Pushbullet
  24. # https://www.pushbullet.com/#settings
  25. pushbulletalert="off"
  26. pushbullettoken="accesstoken"
  27.  
  28. # Steam login
  29. steamuser="anonymous"
  30. steampass=""
  31.  
  32. # Steam App Branch Select
  33. # Allows to opt into the various Steam app branches. Default branch is "".
  34. # Example: "-beta prerelease "
  35. branch=""
  36.  
  37. # Workshop Variables
  38. # http://wiki.garrysmod.com/page/Workshop_for_Dedicated_Servers
  39. workshopauth="9946949063BB6DC5590057CEFB8C1CFD"
  40. workshopcollectionid="145048780"
  41.  
  42. # Start Variables
  43. defaultmap="rp_rockford_french_v3b"
  44. gamemode="darkrp"
  45. maxplayers="120"
  46. port="27015"
  47. sourcetvport="27020"
  48. clientport="27005"
  49. tickrate="66"
  50. ip="0.0.0.0"
  51. updateonstart="off"
  52.  
  53. # Custom Start Parameters
  54. # Default +r_hunkalloclightmaps 0, fixes a start issue on maps with many lights
  55. customparms="+r_hunkalloclightmaps 0"
  56.  
  57. # Optional: Game Server Login Token
  58. # GSLT can be used for running a public server.
  59. # More info: https://gameservermanagers.com/gslt
  60. gslt=""
  61.  
  62. # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
  63. fn_parms(){
  64. parms="-game garrysmod -strictportbind -ip ${ip} -port ${port} -tickrate ${tickrate} +host_workshop_collection ${workshopcollectionid} -authkey ${workshopauth} +clientport ${clientport} +tv_port ${sourcetvport} +gamemode ${gamemode} +map ${defaultmap} +sv_setsteamaccount ${gslt} +servercfgfile ${servercfg} -maxplayers ${maxplayers} ${customparms}"
  65. }
  66.  
  67. #### Advanced Variables ####
  68.  
  69. # Github Branch Select
  70. # Allows for the use of different function files
  71. # from a different repo and/or branch.
  72. githubuser="GameServerManagers"
  73. githubrepo="LinuxGSM"
  74. githubbranch="master"
  75.  
  76. # Steam
  77. appid="4020"
  78.  
  79. # Server Details
  80. servicename="gmod-server"
  81. gamename="Garry's Mod"
  82. engine="source"
  83.  
  84. # Directories
  85. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  86. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  87. lockselfname=".${servicename}.lock"
  88. lgsmdir="${rootdir}/lgsm"
  89. functionsdir="${lgsmdir}/functions"
  90. libdir="${lgsmdir}/lib"
  91. filesdir="${rootdir}/serverfiles"
  92. systemdir="${filesdir}/garrysmod"
  93. addonsdir="${systemdir}/addons"
  94. executabledir="${filesdir}"
  95. executable="./srcds_run"
  96. servercfg="${servicename}.cfg"
  97. servercfgdir="${systemdir}/cfg"
  98. servercfgfullpath="${servercfgdir}/${servercfg}"
  99. servercfgdefault="${servercfgdir}/lgsm-default.cfg"
  100. backupdir="${rootdir}/backups"
  101.  
  102. # Logging
  103. logdays="7"
  104. gamelogdir="${systemdir}/logs"
  105. scriptlogdir="${rootdir}/log/script"
  106. consolelogdir="${rootdir}/log/console"
  107. consolelogging="on"
  108.  
  109. scriptlog="${scriptlogdir}/${servicename}-script.log"
  110. consolelog="${consolelogdir}/${servicename}-console.log"
  111. emaillog="${scriptlogdir}/${servicename}-email.log"
  112.  
  113. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  114. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  115.  
  116. ##### Script #####
  117. # Do not edit
  118.  
  119. # Fetches core_dl for file downloads
  120. fn_fetch_core_dl(){
  121. github_file_url_dir="lgsm/functions"
  122. github_file_url_name="${functionfile}"
  123. filedir="${functionsdir}"
  124. filename="${github_file_url_name}"
  125. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  126. # If the file is missing, then download
  127. if [ ! -f "${filedir}/${filename}" ]; then
  128.     if [ ! -d "${filedir}" ]; then
  129.         mkdir -p "${filedir}"
  130.     fi
  131.     echo -e "    fetching ${filename}...\c"
  132.     # Check curl exists and use available path
  133.     curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  134.     for curlcmd in ${curlpaths}
  135.     do
  136.         if [ -x "${curlcmd}" ]; then
  137.             break
  138.         fi
  139.     done
  140.     # If curl exists download file
  141.     if [ "$(basename ${curlcmd})" == "curl" ]; then
  142.         curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  143.         if [ $? -ne 0 ]; then
  144.             echo -e "\e[0;31mFAIL\e[0m\n"
  145.             echo "${curlfetch}"
  146.             echo -e "${githuburl}\n"
  147.             exit 1
  148.         else
  149.             echo -e "\e[0;32mOK\e[0m"
  150.         fi
  151.     else
  152.         echo -e "\e[0;31mFAIL\e[0m\n"
  153.         echo "Curl is not installed!"
  154.         echo -e ""
  155.         exit 1
  156.     fi
  157.     chmod +x "${filedir}/${filename}"
  158. fi
  159. source "${filedir}/${filename}"
  160. }
  161.  
  162. core_dl.sh(){
  163. # Functions are defined in core_functions.sh.
  164. functionfile="${FUNCNAME}"
  165. fn_fetch_core_dl
  166. }
  167.  
  168. core_functions.sh(){
  169. # Functions are defined in core_functions.sh.
  170. functionfile="${FUNCNAME}"
  171. fn_fetch_core_dl
  172. }
  173.  
  174. core_dl.sh
  175. core_functions.sh
  176.  
  177. getopt=$1
  178. core_getopt.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement