4
0

ricochetserver 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. #!/bin/bash
  2. # Project: Game Server Managers - LinuxGSM
  3. # Author: Daniel Gibbs
  4. # License: MIT License, Copyright (c) 2016 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="161030"
  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. ## SteamCMD Login | https://github.com/GameServerManagers/LinuxGSM/wiki/SteamCMD#steamcmd-login
  36. steamuser="username"
  37. steampass="password"
  38. ## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters
  39. ip="0.0.0.0"
  40. ## Optional: Game Server Login Token
  41. # GSLT can be used for running a public server.
  42. # More info: https://gameservermanagers.com/gslt
  43. gslt=""
  44. ## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters
  45. # Edit with care | https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
  46. fn_parms(){
  47. parms=""
  48. }
  49. #### LinuxGSM Settings ####
  50. ## Notification Alerts
  51. # (on|off)
  52. # Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Email
  53. emailalert="off"
  54. email="email@example.com"
  55. emailfrom=""
  56. # Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet
  57. pushbulletalert="off"
  58. pushbullettoken="accesstoken"
  59. # Pushbullet Channel | Do not set unless the channel exists on the
  60. # account associated with the access token. Set without using the '#'
  61. # E.g: "thisisachanneltag" would push to #thisisachanneltag
  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="90"
  76. appidmod="ricochet"
  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. ## Github Branch Select
  82. # Allows for the use of different function files
  83. # from a different repo and/or branch.
  84. githubuser="GameServerManagers"
  85. githubrepo="LinuxGSM"
  86. githubbranch="master"
  87. ## LinuxGSM Server Details
  88. # Do not edit
  89. gamename="Ricochet"
  90. engine="goldsource"
  91. ## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers
  92. servicename="ricochet-server"
  93. #### Directories ####
  94. # Edit with care
  95. ## Work Directories
  96. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  97. selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  98. lockselfname=".${servicename}.lock"
  99. lgsmdir="${rootdir}/lgsm"
  100. functionsdir="${lgsmdir}/functions"
  101. libdir="${lgsmdir}/lib"
  102. tmpdir="${lgsmdir}/tmp"
  103. filesdir="${rootdir}/serverfiles"
  104. ## Server Specific Directories
  105. systemdir="${filesdir}/ricochet"
  106. executabledir="${filesdir}"
  107. executable="./hlds_run"
  108. servercfg="${servicename}.cfg"
  109. servercfgdefault="server.cfg"
  110. servercfgdir="${systemdir}"
  111. servercfgfullpath="${servercfgdir}/${servercfg}"
  112. ## Backup Directory
  113. backupdir="${rootdir}/backups"
  114. ## Logging Directories
  115. gamelogdir="${systemdir}/logs"
  116. scriptlogdir="${rootdir}/log/script"
  117. consolelogdir="${rootdir}/log/console"
  118. scriptlog="${scriptlogdir}/${servicename}-script.log"
  119. consolelog="${consolelogdir}/${servicename}-console.log"
  120. emaillog="${scriptlogdir}/${servicename}-email.log"
  121. ## Logs Naming
  122. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
  123. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"
  124. ########################
  125. ######## Script ########
  126. ###### Do not edit #####
  127. ########################
  128. # Fetches core_dl for file downloads
  129. fn_fetch_core_dl(){
  130. github_file_url_dir="lgsm/functions"
  131. github_file_url_name="${functionfile}"
  132. filedir="${functionsdir}"
  133. filename="${github_file_url_name}"
  134. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  135. # If the file is missing, then download
  136. if [ ! -f "${filedir}/${filename}" ]; then
  137. if [ ! -d "${filedir}" ]; then
  138. mkdir -p "${filedir}"
  139. fi
  140. echo -e " fetching ${filename}...\c"
  141. # Check curl exists and use available path
  142. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  143. for curlcmd in ${curlpaths}
  144. do
  145. if [ -x "${curlcmd}" ]; then
  146. break
  147. fi
  148. done
  149. # If curl exists download file
  150. if [ "$(basename ${curlcmd})" == "curl" ]; then
  151. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  152. if [ $? -ne 0 ]; then
  153. echo -e "\e[0;31mFAIL\e[0m\n"
  154. echo "${curlfetch}"
  155. echo -e "${githuburl}\n"
  156. exit 1
  157. else
  158. echo -e "\e[0;32mOK\e[0m"
  159. fi
  160. else
  161. echo -e "\e[0;31mFAIL\e[0m\n"
  162. echo "Curl is not installed!"
  163. echo -e ""
  164. exit 1
  165. fi
  166. chmod +x "${filedir}/${filename}"
  167. fi
  168. source "${filedir}/${filename}"
  169. }
  170. core_dl.sh(){
  171. # Functions are defined in core_functions.sh.
  172. functionfile="${FUNCNAME}"
  173. fn_fetch_core_dl
  174. }
  175. core_functions.sh(){
  176. # Functions are defined in core_functions.sh.
  177. functionfile="${FUNCNAME}"
  178. fn_fetch_core_dl
  179. }
  180. # Prevent from running this script as root.
  181. if [ "$(whoami)" = "root" ]; then
  182. if [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]||[ ! -f "${functionsdir}/core_exit.sh" ]; then
  183. echo "[ FAIL ] Do NOT run this script as root!"
  184. exit 1
  185. else
  186. core_functions.sh
  187. check_root.sh
  188. fi
  189. fi
  190. core_dl.sh
  191. core_functions.sh
  192. getopt=$1
  193. core_getopt.sh