4
0

csgoserver 5.0 KB

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