csgoserver 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #!/bin/bash
  2. # Counter Strike: Global Offensive
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: http://danielgibbs.co.uk
  6. # Version: 010115
  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. # Optional: Workshop Parameters
  34. # https://developer.valvesoftware.com/wiki/CSGO_Workshop_For_Server_Operators
  35. # To get an authkey visit - http://steamcommunity.com/dev/apikey
  36. # authkey=""
  37. # ws_collection_id=""
  38. # ws_start_map=""
  39. # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
  40. fn_parms(){
  41. parms="-game csgo -usercon -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} -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}"
  42. }
  43. #### Advanced Variables ####
  44. # Steam
  45. appid="740"
  46. # Server Details
  47. servicename="csgo-server"
  48. gamename="Counter Strike: Global Offensive"
  49. engine="source"
  50. # Directories
  51. rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )"
  52. selfname="$0"
  53. lockselfname=$(echo ".${servicename}.lock")
  54. filesdir="${rootdir}/serverfiles"
  55. systemdir="${filesdir}/csgo"
  56. executabledir="${filesdir}"
  57. executable="./srcds_run"
  58. servercfgdir="${systemdir}/cfg"
  59. servercfg="${servicename}.cfg"
  60. servercfgfullpath="${servercfgdir}/${servercfg}"
  61. defaultcfg="${servercfgdir}/server.cfg"
  62. backupdir="backups"
  63. # Server Details
  64. servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g')
  65. rcon=$(grep -s rcon_password "${servercfgfullpath}"|sed 's/rcon_password //g'|sed 's/"//g')
  66. # Logging
  67. logdays="7"
  68. gamelogdir="${systemdir}/logs"
  69. scriptlogdir="${rootdir}/log/script"
  70. consolelogdir="${rootdir}/log/console"
  71. scriptlog="${scriptlogdir}/${servicename}-script.log"
  72. consolelog="${consolelogdir}/${servicename}-console.log"
  73. emaillog="${scriptlogdir}/${servicename}-email.log"
  74. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  75. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  76. ##### Script #####
  77. # Do not edit
  78. fn_install(){
  79. fn_rootcheck
  80. fn_header
  81. if [ -z "${autoinstall}" ]; then
  82. fn_serverdirectory
  83. fn_header
  84. fi
  85. fn_steamdl
  86. fn_steaminstall
  87. fn_steamfix
  88. fn_loginstall
  89. fn_getquery
  90. fn_serverconfig
  91. fn_csgofix
  92. fn_header
  93. fn_details
  94. fn_installcomplete
  95. }
  96. fn_functions(){
  97. # Functions are defines in fn_functions.
  98. functionfile="${FUNCNAME}"
  99. fn_runfunction
  100. }
  101. fn_runfunction(){
  102. # Functions are downloaded and run with this function
  103. if [ ! -f "${rootdir}/functions/${functionfile}" ]; then
  104. cd "${rootdir}"
  105. if [ ! -d "functions" ]; then
  106. mkdir functions
  107. fi
  108. cd functions
  109. echo -e "loading ${functionfile}...\c"
  110. wget -N --no-check-certificate /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/${functionfile} 2>&1 | grep -F HTTP | cut -c45-
  111. chmod +x "${functionfile}"
  112. cd "${rootdir}"
  113. sleep 1
  114. fi
  115. source "${rootdir}/functions/${functionfile}"
  116. }
  117. fn_functions
  118. case "$1" in
  119. start)
  120. fn_startserver;;
  121. stop)
  122. fn_stopserver;;
  123. restart)
  124. fn_restartserver;;
  125. update)
  126. norestart=1;
  127. fn_versioncheck;;
  128. update-restart)
  129. fn_versioncheck;;
  130. validate)
  131. fn_validateserver;;
  132. validate-restart)
  133. fn_stopserver
  134. fn_validateserver
  135. fn_startserver;;
  136. monitor)
  137. fn_monitorserver;;
  138. email-test)
  139. fn_emailtest;;
  140. details)
  141. fn_details;;
  142. backup)
  143. fn_backupserver;;
  144. console)
  145. fn_console;;
  146. debug)
  147. fn_debugserver;;
  148. install)
  149. fn_install;;
  150. auto-install)
  151. fn_autoinstall;;
  152. *)
  153. echo "Usage: $0 {start|stop|restart|update|update-restart|validate|validate-restart|monitor|email-test|details|backup|console|debug|install|auto-install}"
  154. exit 1;;
  155. esac
  156. exit