Advertisement
Guest User

Untitled

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