4
0

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