Guest User

Untitled

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