ricochetserver 6.0 KB

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