rustserver 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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="Hurtworld LGSM Server"
  23. ip="0.0.0.0"
  24. port="28015"
  25. queryport="28016"
  26. maxplayers="20"
  27. map="" #Optional rust_island_2013
  28. creativemode="0" #Free Build
  29. logfile="gamelog.txt"
  30. # Adding admins using STEAMID64
  31. # Example : addadmin 012345678901234567; addadmin 987654321098765432
  32. admins=""
  33. # Advanced
  34. # Rollback server state (remove after start command)
  35. loadsave=""
  36. # Use unstable 64 bit server executable (O/1)
  37. x64mode="0"
  38. # https://developer.valvesoftware.com/wiki/Rust_Dedicated_Server
  39. fn_parms(){
  40. parms="-batchmode -hostname ${servername} -map ${map} -queryport ${queryport} -maxplayers ${maxplayers} -datadir \"serverdata\""
  41. }
  42. #### Advanced Variables ####
  43. # Github Branch Select
  44. # Allows for the use of different function files
  45. # from a different repo and/or branch.
  46. githubuser="dgibbs64"
  47. githubrepo="linuxgsm"
  48. githubbranch="master"
  49. # Steam
  50. appid="258550"
  51. # Server Details
  52. servicename="rust-server"
  53. gamename="Rust"
  54. engine="unity3d"
  55. # Directories
  56. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  57. selfname=$(basename $(readlink -f "${BASH_SOURCE[0]}"))
  58. lockselfname=".${servicename}.lock"
  59. filesdir="${rootdir}/serverfiles"
  60. systemdir="${filesdir}"
  61. executabledir="${filesdir}"
  62. executable="./RustDedicated"
  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. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  74. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  75. ##### Script #####
  76. # Do not edit
  77. fn_getgithubfile(){
  78. filename=$1
  79. exec=$2
  80. fileurl=${3:-$filename}
  81. filepath="${rootdir}/${filename}"
  82. filedir=$(dirname "${filepath}")
  83. # If the function file is missing, then download
  84. if [ ! -f "${filepath}" ]; then
  85. if [ ! -d "${filedir}" ]; then
  86. mkdir "${filedir}"
  87. fi
  88. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  89. echo -e " fetching ${filename}...\c"
  90. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  91. :
  92. else
  93. echo -e "\e[0;31mFAIL\e[0m\n"
  94. echo "Curl is not installed!"
  95. echo -e ""
  96. exit
  97. fi
  98. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  99. if [ $? -ne 0 ]; then
  100. echo -e "\e[0;31mFAIL\e[0m\n"
  101. echo " ${curl}"|grep "curl:"
  102. echo -e "${githuburl}\n"
  103. exit
  104. else
  105. echo -e "\e[0;32mOK\e[0m"
  106. fi
  107. if [ "${exec}" ]; then
  108. chmod +x "${filepath}"
  109. fi
  110. fi
  111. if [ "${exec}" ]; then
  112. source "${filepath}"
  113. fi
  114. }
  115. fn_runfunction(){
  116. fn_getgithubfile "functions/${functionfile}" 1
  117. }
  118. core_functions.sh(){
  119. # Functions are defined in core_functions.sh.
  120. functionfile="${FUNCNAME}"
  121. fn_runfunction
  122. }
  123. core_functions.sh
  124. getopt=$1
  125. core_getopt.sh