hwserver 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #!/bin/bash
  2. # Hurtworld
  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="191215"
  13. #### Variables ####
  14. # Notification Email
  15. # (on|off)
  16. emailnotification="off"
  17. email="email@example.com"
  18. # Steam login
  19. steamuser="anonymous"
  20. steampass=""
  21. # Start Variables
  22. servername="Hurtworld LGSM Server"
  23. port="12871"
  24. queryport="12881"
  25. ip="0.0.0.0" #For server monitoring
  26. maxplayers="20"
  27. map=""
  28. creativemode="0" #Free Build (0 is off)
  29. updateonstart="off"
  30. loadsave="" #For maintenance only
  31. logfile="gamelog.txt"
  32. # http://hurtworld.wikia.com/wiki/Hosting_A_Server
  33. fn_parms(){
  34. parms="-batchmode -nographics -exec \"host ${port} ${map} ${save};queryport ${queryport};maxplayers ${maxplayers};servername ${servername};creativemode ${creativemode}\" -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="hurt-world"
  43. # Steam
  44. appid="405100"
  45. # Server Details
  46. servicename="hurtworld-server"
  47. gamename="Hurtworld"
  48. engine="hwunity3d"
  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="./Hurtworld.x86"
  57. servercfg="${servicename}.xml"
  58. servercfgdir="${filesdir}"
  59. servercfgfullpath="${servercfgdir}/${servercfg}"
  60. servercfgdefault="${servercfgdir}/serverconfig.xml"
  61. backupdir="${rootdir}/backups"
  62. # Logging
  63. logdays="7"
  64. gamelogdir="${rootdir}/log/server"
  65. scriptlogdir="${rootdir}/log/script"
  66. consolelogdir="${rootdir}/log/console"
  67. gamelog="${gamelogdir}/${servicename}-game.log"
  68. scriptlog="${scriptlogdir}/${servicename}-script.log"
  69. consolelog="${consolelogdir}/${servicename}-console.log"
  70. emaillog="${scriptlogdir}/${servicename}-email.log"
  71. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  72. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  73. ##### Script #####
  74. # Do not edit
  75. fn_getgithubfile(){
  76. filename=$1
  77. exec=$2
  78. fileurl=${3:-$filename}
  79. filepath="${rootdir}/${filename}"
  80. filedir=$(dirname "${filepath}")
  81. # If the function file is missing, then download
  82. if [ ! -f "${filepath}" ]; then
  83. if [ ! -d "${filedir}" ]; then
  84. mkdir "${filedir}"
  85. fi
  86. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  87. echo -e " fetching ${filename}...\c"
  88. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  89. :
  90. else
  91. echo -e "\e[0;31mFAIL\e[0m\n"
  92. echo "Curl is not installed!"
  93. echo -e ""
  94. exit
  95. fi
  96. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  97. if [ $? -ne 0 ]; then
  98. echo -e "\e[0;31mFAIL\e[0m\n"
  99. echo " ${curl}"|grep "curl:"
  100. echo -e "${githuburl}\n"
  101. exit
  102. else
  103. echo -e "\e[0;32mOK\e[0m"
  104. fi
  105. if [ "${exec}" ]; then
  106. chmod +x "${filepath}"
  107. fi
  108. fi
  109. if [ "${exec}" ]; then
  110. source "${filepath}"
  111. fi
  112. }
  113. fn_runfunction(){
  114. fn_getgithubfile "functions/${functionfile}" 1
  115. }
  116. fn_functions(){
  117. # Functions are defined in fn_functions.
  118. functionfile="${FUNCNAME}"
  119. fn_runfunction
  120. }
  121. fn_functions
  122. getopt=$1
  123. fn_getopt