Advertisement
Guest User

Untitled

a guest
Jan 7th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.74 KB | None | 0 0
  1. #!/bin/bash
  2. # Project: Game Server Managers - LinuxGSM
  3. # Author: Daniel Gibbs
  4. # License: MIT License, Copyright (c) 2016 Daniel Gibbs
  5. # Purpose: Rust | 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="161224"
  18.  
  19. ##########################
  20. ######## Settings ########
  21. ##########################
  22.  
  23. #### Server Settings ####
  24.  
  25. ## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters
  26. # More settings available after install in serverfiles/server/rust-server/server.cfg
  27. servername="Barren Rustland"
  28. ip=""
  29. port="28015"
  30. rconport="28016"
  31. rconpassword="changewhenworking"
  32. maxplayers="30"
  33. # Advanced Start Settings
  34. seed="1586214" # default random; range : 1 to 2147483647 ; used to change or reproduce a procedural map
  35. worldsize="3000" # default 3000; range : 1000 to 6000 ; map size in meters
  36. saveinterval="300" # Auto-save in seconds
  37. tickrate="30" # default 30; range : 15 to 100
  38.  
  39. ## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters
  40. # Edit with care | https://developer.valvesoftware.com/wiki/Rust_Dedicated_Server
  41. fn_parms(){
  42. parms="-batchmode +server.ip ${ip} +server.port ${port} +server.tickrate ${tickrate} +server.hostname \"${servername}\" +server.identity \"${servicename}\" ${conditionalseed} +server.maxplayers ${maxplayers} +server.worldsize ${worldsiz$
  43. }
  44.  
  45. # Specific to Rust
  46. if [ -n "${seed}" ]; then
  47. # If set, then add to start parms
  48. conditionalseed="+server.seed ${seed}"
  49. else
  50. # Keep randomness of the number if not set
  51. conditionalseed=""
  52. fi
  53.  
  54. #### LinuxGSM Settings ####
  55.  
  56. ## Notification Alerts
  57. # (on|off)
  58. # Email Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Email
  59. emailalert="off"
  60. email="email@example.com"
  61. emailfrom=""
  62.  
  63. # Pushbullet Alerts | https://github.com/GameServerManagers/LinuxGSM/wiki/Pushbullet
  64. pushbulletalert="off"
  65. pushbullettoken="accesstoken"
  66. channeltag=""
  67.  
  68. ## Updating | https://github.com/GameServerManagers/LinuxGSM/wiki/Update
  69. updateonstart="off"
  70.  
  71. ## Backup | https://github.com/GameServerManagers/LinuxGSM/wiki/Backup
  72. maxbackups="4"
  73. maxbackupdays="30"
  74. stoponbackup="on"
  75.  
  76. ## Logging | https://github.com/GameServerManagers/LinuxGSM/wiki/Logging
  77. consolelogging="on"
  78. logdays="7"
  79.  
  80. #### LinuxGSM Advanced Settings ####
  81.  
  82. ## SteamCMD Settings
  83. # Server appid
  84. appid="258550"
  85. # Steam App Branch Select
  86. # Allows to opt into the various Steam app branches. Default branch is "".
  87. # Example: "-beta latest_experimental"
  88. branch=""
  89.  
  90. ## Github Branch Select
  91. # Allows for the use of different function files
  92. # from a different repo and/or branch.
  93. githubuser="GameServerManagers"
  94. githubrepo="LinuxGSM"
  95. githubbranch="master"
  96.  
  97. ## LinuxGSM Server Details
  98. # Do not edit
  99. gamename="Rust"
  100. engine="unity3d"
  101.  
  102. ## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers
  103. servicename="rust-server"
  104.  
  105. #### Directories ####
  106. # Edit with care
  107.  
  108. ## Work Directories
  109. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  110. selfname=$(basename $(readlink -f "${BASH_SOURCE[0]}"))
  111. lockselfname=".${servicename}.lock"
  112. lgsmdir="${rootdir}/lgsm"
  113. functionsdir="${lgsmdir}/functions"
  114. libdir="${lgsmdir}/lib"
  115. tmpdir="${lgsmdir}/tmp"
  116. filesdir="${rootdir}/serverfiles"
  117.  
  118. ## Server Specific Directories
  119. systemdir="${filesdir}"
  120. executabledir="${filesdir}"
  121. executable="./RustDedicated"
  122. serveridentitydir="${systemdir}/server/${servicename}"
  123. servercfg="server.cfg"
  124. servercfgdefault="server.cfg"
  125. servercfgdir="${serveridentitydir}/cfg"
  126. servercfgfullpath="${servercfgdir}/${servercfg}"
  127.  
  128. ## Backup Directory
  129. backupdir="${rootdir}/backups"
  130.  
  131. ## Logging Directories
  132. gamelogdir="${rootdir}/log/server"
  133. scriptlogdir="${rootdir}/log/script"
  134. consolelogdir="${rootdir}/log/console"
  135. gamelog="${gamelogdir}/${servicename}-game.log"
  136. scriptlog="${scriptlogdir}/${servicename}-script.log"
  137. consolelog="${consolelogdir}/${servicename}-console.log"
  138. emaillog="${scriptlogdir}/${servicename}-email.log"
  139.  
  140. ## Logs Naming
  141. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
  142. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"
  143. gamelogfile="\"gamelog-$(date '+%Y-%m-%d-%H-%M-%S').log\""
  144.  
  145. ########################
  146. ######## Script ########
  147. ###### Do not edit #####
  148. ########################
  149. # Fetches core_dl for file downloads
  150. fn_fetch_core_dl(){
  151. github_file_url_dir="lgsm/functions"
  152. github_file_url_name="${functionfile}"
  153. filedir="${functionsdir}"
  154. filename="${github_file_url_name}"
  155. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}"
  156. # If the file is missing, then download
  157. if [ ! -f "${filedir}/${filename}" ]; then
  158. if [ ! -d "${filedir}" ]; then
  159. mkdir -p "${filedir}"
  160. fi
  161. echo -e " fetching ${filename}...\c"
  162. # Check curl exists and use available path
  163. curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)"
  164. for curlcmd in ${curlpaths}
  165. do
  166. if [ -x "${curlcmd}" ]; then
  167. break
  168. fi
  169. done
  170. # If curl exists download file
  171. if [ "$(basename ${curlcmd})" == "curl" ]; then
  172. curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1)
  173. if [ $? -ne 0 ]; then
  174. echo -e "\e[0;31mFAIL\e[0m\n"
  175. echo "${curlfetch}"
  176. echo -e "${githuburl}\n"
  177. exit 1
  178. fi
  179. chmod +x "${filedir}/${filename}"
  180. fi
  181. source "${filedir}/${filename}"
  182. }
  183.  
  184. core_dl.sh(){
  185. # Functions are defined in core_functions.sh.
  186. functionfile="${FUNCNAME}"
  187. fn_fetch_core_dl
  188. }
  189.  
  190. core_functions.sh(){
  191. # Functions are defined in core_functions.sh.
  192. functionfile="${FUNCNAME}"
  193. fn_fetch_core_dl
  194. }
  195.  
  196. # Prevent from running this script as root.
  197. if [ "$(whoami)" = "root" ]; then
  198. if [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]||[ ! -f "${functionsdir}/core_exit.sh" ]; then
  199. echo "[ FAIL ] Do NOT run this script as root!"
  200. exit 1
  201. else
  202. core_functions.sh
  203. check_root.sh
  204. fi
  205. fi
  206.  
  207. core_dl.sh
  208. core_functions.sh
  209. getopt=$1
  210. core_getopt.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement