csgoserver 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. version="210516"
  12. #### Variables ####
  13. # Notification Alerts
  14. # (on|off)
  15. # Email
  16. emailalert="off"
  17. email="email@example.com"
  18. #emailfrom="email@example.com"
  19. # Pushbullet
  20. # https://www.pushbullet.com/#settings
  21. pushbulletalert="off"
  22. pushbullettoken="accesstoken"
  23. # Steam login
  24. steamuser="anonymous"
  25. steampass=""
  26. # Start Variables
  27. # https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server
  28. # [Game Modes] gametype gamemode
  29. # Arms Race 1 0
  30. # Classic Casual 0 0
  31. # Classic Competitive 0 1
  32. # Demolition 1 1
  33. # Deathmatch 1 2
  34. gametype="0"
  35. gamemode="0"
  36. defaultmap="de_dust2"
  37. mapgroup="random_classic"
  38. maxplayers="16"
  39. tickrate="64"
  40. port="27015"
  41. sourcetvport="27020"
  42. clientport="27005"
  43. ip="0.0.0.0"
  44. updateonstart="off"
  45. # Required: Game Server Login Token
  46. # GSLT is required for running a public server.
  47. # More info: https://gameservermanagers.com/gslt
  48. gslt=""
  49. # Optional: Workshop Parameters
  50. # https://developer.valvesoftware.com/wiki/CSGO_Workshop_For_Server_Operators
  51. # To get an authkey visit - http://steamcommunity.com/dev/apikey
  52. # authkey=""
  53. # ws_collection_id=""
  54. # ws_start_map=""
  55. # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
  56. fn_parms(){
  57. 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}"
  58. }
  59. #### Advanced Variables ####
  60. # Github Branch Select
  61. # Allows for the use of different function files
  62. # from a different repo and/or branch.
  63. githubuser="GameServerManagers"
  64. githubrepo="LinuxGSM"
  65. githubbranch="master"
  66. # Steam
  67. appid="740"
  68. # Steam App Branch Select
  69. # Allows to opt into the various Steam app branches. Default branch is "".
  70. # Example: "-beta 1.35.4.4"
  71. branch=""
  72. # Server Details
  73. servicename="csgo-server"
  74. gamename="Counter-Strike: Global Offensive"
  75. engine="source"
  76. # Directories
  77. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  78. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  79. lockselfname=".${servicename}.lock"
  80. lgsmdir="${rootdir}/lgsm"
  81. functionsdir="${lgsmdir}/functions"
  82. libdir="${lgsmdir}/lib"
  83. tmpdir="${lgsmdir}/tmp"
  84. filesdir="${rootdir}/serverfiles"
  85. systemdir="${filesdir}/csgo"
  86. executabledir="${filesdir}"
  87. executable="./srcds_run"
  88. servercfg="${servicename}.cfg"
  89. servercfgdefault="server.cfg"
  90. servercfgdir="${systemdir}/cfg"
  91. servercfgfullpath="${servercfgdir}/${servercfg}"
  92. # Backup
  93. backupdays="30"
  94. backupdir="${rootdir}/backups"
  95. # Logging
  96. logdays="7"
  97. gamelogdir="${systemdir}/logs"
  98. scriptlogdir="${rootdir}/log/script"
  99. consolelogdir="${rootdir}/log/console"
  100. consolelogging="on"
  101. scriptlog="${scriptlogdir}/${servicename}-script.log"
  102. consolelog="${consolelogdir}/${servicename}-console.log"
  103. emaillog="${scriptlogdir}/${servicename}-email.log"
  104. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  105. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  106. ##### Script #####
  107. # Do not edit
  108. # Fetches core_dl for file downloads
  109. fn_fetch_core_dl(){
  110. github_file_url_dir="lgsm/functions"
  111. github_file_url_name="${functionfile}"
  112. filedir="${functionsdir}"
  113. filename="${github_file_url_name}"
  114. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  115. # If the file is missing, then download
  116. if [ ! -f "${filedir}/${filename}" ]; then
  117. if [ ! -d "${filedir}" ]; then
  118. mkdir -p "${filedir}"
  119. fi
  120. echo -e " fetching ${filename}...\c"
  121. # Check curl exists and use available path
  122. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  123. for curlcmd in ${curlpaths}
  124. do
  125. if [ -x "${curlcmd}" ]; then
  126. break
  127. fi
  128. done
  129. # If curl exists download file
  130. if [ "$(basename ${curlcmd})" == "curl" ]; then
  131. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  132. if [ $? -ne 0 ]; then
  133. echo -e "\e[0;31mFAIL\e[0m\n"
  134. echo "${curlfetch}"
  135. echo -e "${githuburl}\n"
  136. exit 1
  137. else
  138. echo -e "\e[0;32mOK\e[0m"
  139. fi
  140. else
  141. echo -e "\e[0;31mFAIL\e[0m\n"
  142. echo "Curl is not installed!"
  143. echo -e ""
  144. exit 1
  145. fi
  146. chmod +x "${filedir}/${filename}"
  147. fi
  148. source "${filedir}/${filename}"
  149. }
  150. core_dl.sh(){
  151. # Functions are defined in core_functions.sh.
  152. functionfile="${FUNCNAME}"
  153. fn_fetch_core_dl
  154. }
  155. core_functions.sh(){
  156. # Functions are defined in core_functions.sh.
  157. functionfile="${FUNCNAME}"
  158. fn_fetch_core_dl
  159. }
  160. core_dl.sh
  161. core_functions.sh
  162. getopt=$1
  163. core_getopt.sh