Advertisement
Guchay

Untitled

Sep 11th, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 KB | None | 0 0
  1. #!/bin/bash
  2. # Counter-Strike: Global Offensive
  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. # Start Variables
  33. # https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server
  34. # [Game Modes] gametype gamemode
  35. # Arms Race 1 0
  36. # Classic Casual 0 0
  37. # Classic Competitive 0 1
  38. # Demolition 1 1
  39. # Deathmatch 1 2
  40. gametype="0"
  41. gamemode="0"
  42. defaultmap=""
  43. mapgroup="random_classic"
  44. maxplayers="16"
  45. tickrate="102.4"
  46. port="27015"
  47. sourcetvport="27020"
  48. clientport="27005"
  49. ip=""
  50. updateonstart="off"
  51.  
  52. # Required: Game Server Login Token
  53. # GSLT is required for running a public server.
  54. # More info: https://gameservermanagers.com/gslt
  55. gslt=""
  56.  
  57. # Optional: Workshop Parameters
  58. # https://developer.valvesoftware.com/wiki/CSGO_Workshop_For_Server_Operators
  59. # To get an authkey visit - http://steamcommunity.com/dev/apikey
  60. # authkey=""
  61. # ws_collection_id=""
  62. # ws_start_map=""
  63.  
  64. # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
  65. fn_parms(){
  66. parms="-game csgo -usercon -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +sv_setsteamaccount ${gslt} -tickrate ${tickrate} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers_override ${maxplayers} +mapgroup ${mapgroup} +game_mode ${gamemode} +game_type ${gametype} +host_workshop_collection ${ws_collection_id} +workshop_start_map ${ws_start_map} -authkey ${authkey}"
  67. }
  68.  
  69. #### Advanced Variables ####
  70.  
  71. # Github Branch Select
  72. # Allows for the use of different function files
  73. # from a different repo and/or branch.
  74. githubuser="GameServerManagers"
  75. githubrepo="LinuxGSM"
  76. githubbranch="master"
  77.  
  78. # Steam
  79. appid="740"
  80.  
  81. # Steam App Branch Select
  82. # Allows to opt into the various Steam app branches. Default branch is "".
  83. # Example: "-beta 1.35.4.4"
  84. branch=""
  85.  
  86. # Server Details
  87. servicename="csgo-server"
  88. gamename="Counter-Strike: Global Offensive"
  89. engine="source"
  90.  
  91. # Directories
  92. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  93. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  94. lockselfname=".${servicename}.lock"
  95. lgsmdir="${rootdir}/lgsm"
  96. functionsdir="${lgsmdir}/functions"
  97. libdir="${lgsmdir}/lib"
  98. filesdir="${rootdir}/serverfiles"
  99. systemdir="${filesdir}/csgo"
  100. executabledir="${filesdir}"
  101. executable="./srcds_run"
  102. servercfg="${servicename}.cfg"
  103. servercfgdir="${systemdir}/cfg"
  104. servercfgfullpath="${servercfgdir}/${servercfg}"
  105. servercfgdefault="${servercfgdir}/lgsm-default.cfg"
  106. backupdir="${rootdir}/backups"
  107.  
  108. # Logging
  109. logdays="7"
  110. gamelogdir="${systemdir}/logs"
  111. scriptlogdir="${rootdir}/log/script"
  112. consolelogdir="${rootdir}/log/console"
  113. consolelogging="on"
  114.  
  115. scriptlog="${scriptlogdir}/${servicename}-script.log"
  116. consolelog="${consolelogdir}/${servicename}-console.log"
  117. emaillog="${scriptlogdir}/${servicename}-email.log"
  118.  
  119. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  120. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  121.  
  122. ##### Script #####
  123. # Do not edit
  124.  
  125. # Fetches core_dl for file downloads
  126. fn_fetch_core_dl(){
  127. github_file_url_dir="lgsm/functions"
  128. github_file_url_name="${functionfile}"
  129. filedir="${functionsdir}"
  130. filename="${github_file_url_name}"
  131. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  132. # If the file is missing, then download
  133. if [ ! -f "${filedir}/${filename}" ]; then
  134. if [ ! -d "${filedir}" ]; then
  135. mkdir -p "${filedir}"
  136. fi
  137. echo -e " fetching ${filename}...\c"
  138. # Check curl exists and use available path
  139. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  140. for curlcmd in ${curlpaths}
  141. do
  142. if [ -x "${curlcmd}" ]; then
  143. break
  144. fi
  145. done
  146. # If curl exists download file
  147. if [ "$(basename ${curlcmd})" == "curl" ]; then
  148. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  149. if [ $? -ne 0 ]; then
  150. echo -e "\e[0;31mFAIL\e[0m\n"
  151. echo "${curlfetch}"
  152. echo -e "${githuburl}\n"
  153. exit 1
  154. else
  155. echo -e "\e[0;32mOK\e[0m"
  156. fi
  157. else
  158. echo -e "\e[0;31mFAIL\e[0m\n"
  159. echo "Curl is not installed!"
  160. echo -e ""
  161. exit 1
  162. fi
  163. chmod +x "${filedir}/${filename}"
  164. fi
  165. source "${filedir}/${filename}"
  166. }
  167.  
  168. core_dl.sh(){
  169. # Functions are defined in core_functions.sh.
  170. functionfile="${FUNCNAME}"
  171. fn_fetch_core_dl
  172. }
  173.  
  174. core_functions.sh(){
  175. # Functions are defined in core_functions.sh.
  176. functionfile="${FUNCNAME}"
  177. fn_fetch_core_dl
  178. }
  179.  
  180. core_dl.sh
  181. core_functions.sh
  182.  
  183. getopt=$1
  184. core_getopt.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement