hwserver 3.4 KB

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