coserver 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. #!/bin/bash
  2. # Project: Game Server Managers - LinuxGSM
  3. # Author: Daniel Gibbs
  4. # License: MIT License, Copyright (c) 2017 Daniel Gibbs
  5. # Purpose: Classic Offensive | Server Management Script
  6. # Contributors: https://github.com/GameServerManagers/LinuxGSM/graphs/contributors
  7. # Documentation: https://github.com/GameServerManagers/LinuxGSM/wiki
  8. # Website: https://gameservermanagers.com
  9. # Debugging
  10. if [ -f ".dev-debug" ]; then
  11. exec 5>dev-debug.log
  12. BASH_XTRACEFD="5"
  13. set -x
  14. fi
  15. version="170501"
  16. ##########################
  17. ######## Settings ########
  18. ##########################
  19. #### Server Settings ####
  20. ## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters
  21. # https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server
  22. # [Game Modes] gametype gamemode
  23. # Arms Race 1 0
  24. # Classic Casual 0 0
  25. # Classic Competitive 0 1
  26. # Demolition 1 1
  27. # Deathmatch 1 2
  28. gametype="0"
  29. gamemode="0"
  30. defaultmap="de_mirage"
  31. mapgroup="mg_active"
  32. maxplayers="16"
  33. tickrate="64"
  34. port="27015"
  35. sourcetvport="27020"
  36. clientport="27005"
  37. ip="0.0.0.0"
  38. ## Required: Game Server Login Token
  39. # GSLT is required for running a public server.
  40. # More info: https://gameservermanagers.com/gslt
  41. gslt=""
  42. ## Optional: Workshop Parameters
  43. # https://developer.valvesoftware.com/wiki/CSGO_Workshop_For_Server_Operators
  44. # To get an authkey visit - http://steamcommunity.com/dev/apikey
  45. # authkey=""
  46. # ws_collection_id=""
  47. # ws_start_map=""
  48. ## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters
  49. fn_parms(){
  50. parms="-game csco -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}"
  51. }
  52. #### LinuxGSM Settings ####
  53. ## Notification Alerts
  54. # (on|off)
  55. # Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Email
  56. emailalert="off"
  57. email="email@example.com"
  58. emailfrom=""
  59. # Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet
  60. pushbulletalert="off"
  61. pushbullettoken="accesstoken"
  62. channeltag=""
  63. ## Updating | https://github.com/GameServerManagers/LinuxGSM/wiki/Update
  64. updateonstart="off"
  65. ## Backup | https://github.com/GameServerManagers/LinuxGSM/wiki/Backup
  66. maxbackups="4"
  67. maxbackupdays="30"
  68. stoponbackup="on"
  69. ## Logging | https://github.com/GameServerManagers/LinuxGSM/wiki/Logging
  70. consolelogging="on"
  71. logdays="7"
  72. #### LinuxGSM Advanced Settings ####
  73. ## SteamCMD Settings
  74. # Server appid
  75. appid="740"
  76. appid_co="600380"
  77. # Steam App Branch Select
  78. # Allows to opt into the various Steam app branches. Default branch is "".
  79. # Example: "-beta latest_experimental"
  80. branch=""
  81. ## SteamCMD Login | https://github.com/GameServerManagers/LinuxGSM/wiki/SteamCMD#steamcmd-login
  82. steamuser="username"
  83. steampass='password'
  84. ## Github Branch Select
  85. # Allows for the use of different function files
  86. # from a different repo and/or branch.
  87. githubuser="GameServerManagers"
  88. githubrepo="LinuxGSM"
  89. githubbranch="master"
  90. ## LinuxGSM Server Details
  91. # Do not edit
  92. gamename="Classic Offensive"
  93. engine="source"
  94. ## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers
  95. servicename="co-server"
  96. #### Directories ####
  97. # Edit with care
  98. ## Work Directories
  99. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  100. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  101. lockselfname=".${servicename}.lock"
  102. lgsmdir="${rootdir}/lgsm"
  103. functionsdir="${lgsmdir}/functions"
  104. libdir="${lgsmdir}/lib"
  105. tmpdir="${lgsmdir}/tmp"
  106. filesdir="${rootdir}/serverfiles"
  107. ## Server Specific Directories
  108. systemdir="${filesdir}/csco"
  109. executabledir="${filesdir}"
  110. executable="./srcds_run"
  111. servercfg="${servicename}.cfg"
  112. servercfgdefault="server.cfg"
  113. servercfgdir="${systemdir}/cfg"
  114. servercfgfullpath="${servercfgdir}/${servercfg}"
  115. ## Backup Directory
  116. backupdir="${rootdir}/backups"
  117. ## Logging Directories
  118. gamelogdir="${systemdir}/logs"
  119. scriptlogdir="${rootdir}/log/script"
  120. consolelogdir="${rootdir}/log/console"
  121. scriptlog="${scriptlogdir}/${servicename}-script.log"
  122. consolelog="${consolelogdir}/${servicename}-console.log"
  123. emaillog="${scriptlogdir}/${servicename}-email.log"
  124. ## Logs Naming
  125. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
  126. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"
  127. ########################
  128. ######## Script ########
  129. ###### Do not edit #####
  130. ########################
  131. # Fetches core_dl for file downloads
  132. fn_fetch_core_dl(){
  133. github_file_url_dir="lgsm/functions"
  134. github_file_url_name="${functionfile}"
  135. filedir="${functionsdir}"
  136. filename="${github_file_url_name}"
  137. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  138. # If the file is missing, then download
  139. if [ ! -f "${filedir}/${filename}" ]; then
  140. if [ ! -d "${filedir}" ]; then
  141. mkdir -p "${filedir}"
  142. fi
  143. echo -e " fetching ${filename}...\c"
  144. # Check curl exists and use available path
  145. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  146. for curlcmd in ${curlpaths}
  147. do
  148. if [ -x "${curlcmd}" ]; then
  149. break
  150. fi
  151. done
  152. # If curl exists download file
  153. if [ "$(basename ${curlcmd})" == "curl" ]; then
  154. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  155. if [ $? -ne 0 ]; then
  156. echo -e "\e[0;31mFAIL\e[0m\n"
  157. echo "${curlfetch}"
  158. echo -e "${githuburl}\n"
  159. exit 1
  160. else
  161. echo -e "\e[0;32mOK\e[0m"
  162. fi
  163. else
  164. echo -e "\e[0;31mFAIL\e[0m\n"
  165. echo "Curl is not installed!"
  166. echo -e ""
  167. exit 1
  168. fi
  169. chmod +x "${filedir}/${filename}"
  170. fi
  171. source "${filedir}/${filename}"
  172. }
  173. core_dl.sh(){
  174. # Functions are defined in core_functions.sh.
  175. functionfile="${FUNCNAME}"
  176. fn_fetch_core_dl
  177. }
  178. core_functions.sh(){
  179. # Functions are defined in core_functions.sh.
  180. functionfile="${FUNCNAME}"
  181. fn_fetch_core_dl
  182. }
  183. # Prevent from running this script as root.
  184. if [ "$(whoami)" = "root" ]; then
  185. if [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]||[ ! -f "${functionsdir}/core_exit.sh" ]; then
  186. echo "[ FAIL ] Do NOT run this script as root!"
  187. exit 1
  188. else
  189. core_functions.sh
  190. check_root.sh
  191. fi
  192. fi
  193. core_dl.sh
  194. core_functions.sh
  195. getopt=$1
  196. core_getopt.sh