bsserver 5.4 KB

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