csgoserver 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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="211016"
  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. backupdir="${rootdir}/backups"
  93. # Logging
  94. logdays="7"
  95. gamelogdir="${systemdir}/logs"
  96. scriptlogdir="${rootdir}/log/script"
  97. consolelogdir="${rootdir}/log/console"
  98. consolelogging="on"
  99. scriptlog="${scriptlogdir}/${servicename}-script.log"
  100. consolelog="${consolelogdir}/${servicename}-console.log"
  101. emaillog="${scriptlogdir}/${servicename}-email.log"
  102. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  103. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  104. ##### Script #####
  105. # Do not edit
  106. # Fetches core_dl for file downloads
  107. fn_fetch_core_dl(){
  108. github_file_url_dir="lgsm/functions"
  109. github_file_url_name="${functionfile}"
  110. filedir="${functionsdir}"
  111. filename="${github_file_url_name}"
  112. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  113. # If the file is missing, then download
  114. if [ ! -f "${filedir}/${filename}" ]; then
  115. if [ ! -d "${filedir}" ]; then
  116. mkdir -p "${filedir}"
  117. fi
  118. echo -e " fetching ${filename}...\c"
  119. # Check curl exists and use available path
  120. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  121. for curlcmd in ${curlpaths}
  122. do
  123. if [ -x "${curlcmd}" ]; then
  124. break
  125. fi
  126. done
  127. # If curl exists download file
  128. if [ "$(basename ${curlcmd})" == "curl" ]; then
  129. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  130. if [ $? -ne 0 ]; then
  131. echo -e "\e[0;31mFAIL\e[0m\n"
  132. echo "${curlfetch}"
  133. echo -e "${githuburl}\n"
  134. exit 1
  135. else
  136. echo -e "\e[0;32mOK\e[0m"
  137. fi
  138. else
  139. echo -e "\e[0;31mFAIL\e[0m\n"
  140. echo "Curl is not installed!"
  141. echo -e ""
  142. exit 1
  143. fi
  144. chmod +x "${filedir}/${filename}"
  145. fi
  146. source "${filedir}/${filename}"
  147. }
  148. core_dl.sh(){
  149. # Functions are defined in core_functions.sh.
  150. functionfile="${FUNCNAME}"
  151. fn_fetch_core_dl
  152. }
  153. core_functions.sh(){
  154. # Functions are defined in core_functions.sh.
  155. functionfile="${FUNCNAME}"
  156. fn_fetch_core_dl
  157. }
  158. core_dl.sh
  159. core_functions.sh
  160. getopt=$1
  161. core_getopt.sh