rustserver 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #!/bin/bash
  2. # Rust
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Contributor: UltimateByte
  6. # Website: http://gameservermanagers.com
  7. if [ -f ".dev-debug" ]; then
  8. exec 5>dev-debug.log
  9. BASH_XTRACEFD="5"
  10. set -x
  11. fi
  12. version="210215"
  13. #### Variables ####
  14. # Notification Email
  15. # (on|off)
  16. emailnotification="off"
  17. email="email@example.com"
  18. # Steam login (not required)
  19. steamuser="anonymous"
  20. steampass=""
  21. # Server settings
  22. servername="Rust LGSM Server"
  23. ip="0.0.0.0"
  24. port="28015" #+server.port
  25. rconport="28016" #+rcon.port
  26. rconpassword="" #+rcon.password
  27. maxplayers="40" #+max.players
  28. map="" #Optional +server.map "Procedural Map" or TestLevel
  29. # Advanced
  30. worldsize="4000" #+server.worldsize default 4000
  31. saveinterval="300" #+server.saveinterval in seconds
  32. logfile="\"gamelog.txt\""
  33. # https://developer.valvesoftware.com/wiki/Rust_Dedicated_Server
  34. fn_parms(){
  35. parms="-batchmode +server.hostname \"${servername}\" +server.identity \"${servicename}\" +server.maxplayers ${maxplayers} +server.worldsize ${worldsize} +server.saveinterval ${saveinterval} +rcon.port ${rconport} +rcon.password \"${rconpassword}\" -datadir \"serverdata/\" -logfile ${logfile}"
  36. }
  37. #### Advanced Variables ####
  38. # Github Branch Select
  39. # Allows for the use of different function files
  40. # from a different repo and/or branch.
  41. githubuser="dgibbs64"
  42. githubrepo="linuxgsm"
  43. githubbranch="rust"
  44. # Steam
  45. appid="258550"
  46. # Server Details
  47. servicename="rust-server"
  48. gamename="Rust"
  49. engine="unity3d"
  50. # Directories
  51. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  52. selfname=$(basename $(readlink -f "${BASH_SOURCE[0]}"))
  53. lockselfname=".${servicename}.lock"
  54. filesdir="${rootdir}/serverfiles"
  55. systemdir="${filesdir}"
  56. executabledir="${filesdir}"
  57. executable="./RustDedicated"
  58. backupdir="${rootdir}/backups"
  59. # Logging
  60. logdays="7"
  61. gamelogdir="${rootdir}/log/server"
  62. scriptlogdir="${rootdir}/log/script"
  63. consolelogdir="${rootdir}/log/console"
  64. gamelog="${gamelogdir}/${servicename}-game.log"
  65. scriptlog="${scriptlogdir}/${servicename}-script.log"
  66. consolelog="${consolelogdir}/${servicename}-console.log"
  67. emaillog="${scriptlogdir}/${servicename}-email.log"
  68. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  69. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  70. ##### Script #####
  71. # Do not edit
  72. fn_getgithubfile(){
  73. filename=$1
  74. exec=$2
  75. fileurl=${3:-$filename}
  76. filepath="${rootdir}/${filename}"
  77. filedir=$(dirname "${filepath}")
  78. # If the function file is missing, then download
  79. if [ ! -f "${filepath}" ]; then
  80. if [ ! -d "${filedir}" ]; then
  81. mkdir "${filedir}"
  82. fi
  83. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  84. echo -e " fetching ${filename}...\c"
  85. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  86. :
  87. else
  88. echo -e "\e[0;31mFAIL\e[0m\n"
  89. echo "Curl is not installed!"
  90. echo -e ""
  91. exit
  92. fi
  93. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  94. if [ $? -ne 0 ]; then
  95. echo -e "\e[0;31mFAIL\e[0m\n"
  96. echo " ${curl}"|grep "curl:"
  97. echo -e "${githuburl}\n"
  98. exit
  99. else
  100. echo -e "\e[0;32mOK\e[0m"
  101. fi
  102. if [ "${exec}" ]; then
  103. chmod +x "${filepath}"
  104. fi
  105. fi
  106. if [ "${exec}" ]; then
  107. source "${filepath}"
  108. fi
  109. }
  110. fn_runfunction(){
  111. fn_getgithubfile "functions/${functionfile}" 1
  112. }
  113. core_functions.sh(){
  114. # Functions are defined in core_functions.sh.
  115. functionfile="${FUNCNAME}"
  116. fn_runfunction
  117. }
  118. core_functions.sh
  119. getopt=$1
  120. core_getopt.sh