rustserver 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #!/bin/bash
  2. # Rust
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Contributor: UltimateByte (LGSM adaptation), Wulf (Information)
  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="230215"
  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. # More settings available after install in serverfiles/server/rust-server/server.cfg
  23. servername="Rust LGSM Server"
  24. ip="0.0.0.0"
  25. port="28015"
  26. rconport="28016"
  27. rconpassword="CHANGE_ME" # Don't let it blank but change it
  28. maxplayers="50"
  29. # Advanced
  30. worldsize="4000" # default 4000; min : 2000 max : 8000
  31. saveinterval="300" # Auto-save in seconds
  32. tickrate="30" # default 30; min acceptable 15 , max 100 or 128
  33. # https://developer.valvesoftware.com/wiki/Rust_Dedicated_Server
  34. fn_parms(){
  35. parms="-batchmode +server.ip ${ip} +server.port ${port} +server.tickrate ${tickrate} +server.hostname \"${servername}\" +server.identity \"${servicename}\" +server.maxplayers ${maxplayers} +server.worldsize ${worldsize} +server.saveinterval ${saveinterval} +rcon.ip ${ip} +rcon.port ${rconport} +rcon.password \"${rconpassword}\" -logfile ${gamelogfile}"
  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. serveridentitydir="${systemdir}/server/${servicename}"
  59. servercfg="server.cfg"
  60. servercfgdir="${serveridentitydir}/cfg"
  61. servercfgfullpath="${servercfgdir}/${servercfg}"
  62. servercfgdefault="${servercfgdir}/lgsm-default.cfg"
  63. backupdir="${rootdir}/backups"
  64. # Logging
  65. logdays="7"
  66. gamelogdir="${rootdir}/log/server"
  67. scriptlogdir="${rootdir}/log/script"
  68. consolelogdir="${rootdir}/log/console"
  69. gamelog="${gamelogdir}/${servicename}-game.log"
  70. scriptlog="${scriptlogdir}/${servicename}-script.log"
  71. consolelog="${consolelogdir}/${servicename}-console.log"
  72. emaillog="${scriptlogdir}/${servicename}-email.log"
  73. gamelogfile="\"gamelog-$(date '+%Y-%m-%d-%H-%M-%S').log\""
  74. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  75. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  76. ##### Script #####
  77. # Do not edit
  78. fn_getgithubfile(){
  79. filename=$1
  80. exec=$2
  81. fileurl=${3:-$filename}
  82. filepath="${rootdir}/${filename}"
  83. filedir=$(dirname "${filepath}")
  84. # If the function file is missing, then download
  85. if [ ! -f "${filepath}" ]; then
  86. if [ ! -d "${filedir}" ]; then
  87. mkdir "${filedir}"
  88. fi
  89. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  90. echo -e " fetching ${filename}...\c"
  91. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  92. :
  93. else
  94. echo -e "\e[0;31mFAIL\e[0m\n"
  95. echo "Curl is not installed!"
  96. echo -e ""
  97. exit
  98. fi
  99. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  100. if [ $? -ne 0 ]; then
  101. echo -e "\e[0;31mFAIL\e[0m\n"
  102. echo " ${curl}"|grep "curl:"
  103. echo -e "${githuburl}\n"
  104. exit
  105. else
  106. echo -e "\e[0;32mOK\e[0m"
  107. fi
  108. if [ "${exec}" ]; then
  109. chmod +x "${filepath}"
  110. fi
  111. fi
  112. if [ "${exec}" ]; then
  113. source "${filepath}"
  114. fi
  115. }
  116. fn_runfunction(){
  117. fn_getgithubfile "functions/${functionfile}" 1
  118. }
  119. core_functions.sh(){
  120. # Functions are defined in core_functions.sh.
  121. functionfile="${FUNCNAME}"
  122. fn_runfunction
  123. }
  124. core_functions.sh
  125. getopt=$1
  126. core_getopt.sh