Advertisement
Guest User

cancer

a guest
Feb 23rd, 2018
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.13 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: 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="170501"
  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="Retarded server"
  28. ip="192.168.1.158"
  29. port="28015"
  30. rconport="28016"
  31. rconpassword="citadel"
  32. rconweb="1" # Value is: 1 for Facepunch's web panel; 0 for RCON tools like Rusty or Rustadmin
  33. maxplayers="50"
  34. # Advanced Start Settings
  35. seed="999888777" #  default random; range : 1 to 2147483647 ; used to change or reproduce a procedural map
  36. worldsize="3300" # default 3000; range : 1000 to 6000 ; map size in meters
  37. saveinterval="300" # Auto-save in seconds
  38. tickrate="30" # default 30; range : 15 to 100
  39.  
  40. ## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters
  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 ${worldsize} +server.saveinterval ${saveinterval} +rcon.web ${rconweb} +rcon.ip ${ip} +rcon.port ${rconport} +rcon.password \"${rconpassword}\" -logfile \"${gamelogdate}\""
  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. scriptlog="${scriptlogdir}/${servicename}-script.log"
  136. consolelog="${consolelogdir}/${servicename}-console.log"
  137. emaillog="${scriptlogdir}/${servicename}-email.log"
  138.  
  139. ## Logs Naming
  140. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
  141. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"
  142. gamelogdate="${gamelogdir}/${servicename}-game-$(date '+%Y-%m-%d-%H:%M:%S').log"
  143.  
  144. ########################
  145. ######## Script ########
  146. ###### Do not edit #####
  147. ########################
  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.                 else
  179.                         echo -e "\e[0;32mOK\e[0m"
  180.                 fi
  181.         else
  182.                 echo -e "\e[0;31mFAIL\e[0m\n"
  183.                 echo "Curl is not installed!"
  184.                 echo -e ""
  185.                 exit 1
  186.         fi
  187.         chmod +x "${filedir}/${filename}"
  188. fi
  189. source "${filedir}/${filename}"
  190. }
  191.  
  192. core_dl.sh(){
  193. # Functions are defined in core_functions.sh.
  194. functionfile="${FUNCNAME}"
  195. fn_fetch_core_dl
  196. }
  197.  
  198. core_functions.sh(){
  199. # Functions are defined in core_functions.sh.
  200. functionfile="${FUNCNAME}"
  201. fn_fetch_core_dl
  202. }
  203.  
  204. # Prevent from running this script as root.
  205. if [ "$(whoami)" = "root" ]; then
  206.         if [ ! -f "${functionsdir}/core_functions.sh" ]||[ ! -f "${functionsdir}/check_root.sh" ]||[ ! -f "${functionsdir}/core_messages.sh" ]||[ ! -f "${functionsdir}/core_exit.sh" ]; then
  207.                 echo "[ FAIL ] Do NOT run this script as root!"
  208.                 exit 1
  209.         else
  210.                 core_functions.sh
  211.                 check_root.sh
  212.         fi
  213. fi
  214.  
  215. core_dl.sh
  216. core_functions.sh
  217. getopt=$1
  218. core_getopt.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement