csgoserver 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #!/bin/bash
  2. # Counter Strike: Global Offensive
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: http://gameservermanagers.com
  6. version="121215"
  7. #### Variables ####
  8. # Notification Email
  9. # (on|off)
  10. emailnotification="off"
  11. email="email@example.com"
  12. # Steam login
  13. steamuser="anonymous"
  14. steampass=""
  15. # Start Variables
  16. # https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server
  17. # [Game Modes] gametype gamemode
  18. # Arms Race 1 0
  19. # Classic Casual 0 0
  20. # Classic Competitive 0 1
  21. # Demolition 1 1
  22. # Deathmatch 1 2
  23. gamemode="0"
  24. gametype="0"
  25. defaultmap="de_dust2"
  26. mapgroup="random_classic"
  27. maxplayers="16"
  28. tickrate="64"
  29. port="27015"
  30. sourcetvport="27020"
  31. clientport="27005"
  32. ip="0.0.0.0"
  33. updateonstart="off"
  34. # Required: Game Server Login Token
  35. # GSLT is required for running a public server.
  36. # More info: http://gameservermanagers.com/gslt
  37. gslt=""
  38. # Optional: Workshop Parameters
  39. # https://developer.valvesoftware.com/wiki/CSGO_Workshop_For_Server_Operators
  40. # To get an authkey visit - http://steamcommunity.com/dev/apikey
  41. # authkey=""
  42. # ws_collection_id=""
  43. # ws_start_map=""
  44. # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
  45. fn_parms(){
  46. 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}"
  47. }
  48. #### Advanced Variables ####
  49. # Github Branch Select
  50. # Allows for the use of different function files
  51. # from a different repo and/or branch.
  52. githubuser="dgibbs64"
  53. githubrepo="linuxgsm"
  54. githubbranch="master"
  55. # Steam
  56. appid="740"
  57. # Server Details
  58. servicename="csgo-server"
  59. gamename="Counter Strike: Global Offensive"
  60. engine="source"
  61. # Directories
  62. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  63. selfname=$(basename $(readlink -f "${BASH_SOURCE[0]}"))
  64. lockselfname=".${servicename}.lock"
  65. filesdir="${rootdir}/serverfiles"
  66. systemdir="${filesdir}/csgo"
  67. executabledir="${filesdir}"
  68. executable="./srcds_run"
  69. servercfg="${servicename}.cfg"
  70. servercfgdir="${systemdir}/cfg"
  71. servercfgfullpath="${servercfgdir}/${servercfg}"
  72. servercfgdefault="${servercfgdir}/lgsm-default.cfg"
  73. backupdir="${rootdir}/backups"
  74. # Logging
  75. logdays="7"
  76. gamelogdir="${systemdir}/logs"
  77. scriptlogdir="${rootdir}/log/script"
  78. consolelogdir="${rootdir}/log/console"
  79. scriptlog="${scriptlogdir}/${servicename}-script.log"
  80. consolelog="${consolelogdir}/${servicename}-console.log"
  81. emaillog="${scriptlogdir}/${servicename}-email.log"
  82. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  83. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  84. ##### Script #####
  85. # Do not edit
  86. fn_getgithubfile(){
  87. filename=$1
  88. exec=$2
  89. fileurl=${3:-$filename}
  90. filepath="${rootdir}/${filename}"
  91. filedir=$(dirname "${filepath}")
  92. # If the function file is missing, then download
  93. if [ ! -f "${filepath}" ]; then
  94. if [ ! -d "${filedir}" ]; then
  95. mkdir "${filedir}"
  96. fi
  97. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  98. echo -e " fetching ${filename}...\c"
  99. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  100. :
  101. else
  102. echo -e "\e[0;31mFAIL\e[0m\n"
  103. echo "Curl is not installed!"
  104. echo -e ""
  105. exit
  106. fi
  107. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  108. if [ $? -ne 0 ]; then
  109. echo -e "\e[0;31mFAIL\e[0m\n"
  110. echo " ${curl}"|grep "curl:"
  111. echo -e "${githuburl}\n"
  112. exit
  113. else
  114. echo -e "\e[0;32mOK\e[0m"
  115. fi
  116. if [ "${exec}" ]; then
  117. chmod +x "${filepath}"
  118. fi
  119. fi
  120. if [ "${exec}" ]; then
  121. source "${filepath}"
  122. fi
  123. }
  124. fn_runfunction(){
  125. fn_getgithubfile "functions/${functionfile}" 1
  126. }
  127. fn_functions(){
  128. # Functions are defined in fn_functions.
  129. functionfile="${FUNCNAME}"
  130. fn_runfunction
  131. }
  132. fn_functions
  133. getopt=$1
  134. fn_getopt