hwserver 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #!/bin/bash
  2. # Hurtworld
  3. # Server Management Script
  4. # Author: Daniel Gibbs, UltimateByte Fork
  5. # Website: http://gameservermanagers.com
  6. version="191215"
  7. #### Variables ####
  8. # Notification Email
  9. # (on|off)
  10. emailnotification="off"
  11. email="email@example.com"
  12. # Steam login
  13. steamuser="anonymous"
  14. steampass=""
  15. # Start Variables
  16. servername="Hurtworld LGSM Server"
  17. logfile="gamelog.txt"
  18. ip="0.0.0.0"
  19. hostport="12871"
  20. queryport="12881"
  21. maxplayers="20"
  22. map=""
  23. creativemode="0" #Free Build (0 is off)
  24. updateonstart="off"
  25. loadsave="" #For maintenance only
  26. logfile="gamelog.txt"
  27. # http://hurtworld.wikia.com/wiki/Hosting_A_Server
  28. fn_parms(){
  29. parms="-batchmode -nographics -exec \"host ${hostport} ${map} ${save};queryport ${queryport};maxplayers ${maxplayers};servername ${servername};creativemode ${creativemode}\" -logfile \"${logfile}\" "
  30. }
  31. #### Advanced Variables ####
  32. # Github Branch Select
  33. # Allows for the use of different function files
  34. # from a different repo and/or branch.
  35. githubuser="dgibbs64"
  36. githubrepo="linuxgsm"
  37. githubbranch="master"
  38. # Steam
  39. appid="405100"
  40. # Server Details
  41. servicename="hurtworld-server"
  42. gamename="hurtworld"
  43. engine="unity3d"
  44. # Directories
  45. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  46. selfname=$(basename $(readlink -f "${BASH_SOURCE[0]}"))
  47. lockselfname=".${servicename}.lock"
  48. filesdir="${rootdir}/serverfiles"
  49. systemdir="${filesdir}"
  50. executabledir="${filesdir}"
  51. executable="./Hurtworld.x86"
  52. servercfg="${servicename}.xml"
  53. servercfgdir="${filesdir}"
  54. servercfgfullpath="${servercfgdir}/${servercfg}"
  55. servercfgdefault="${servercfgdir}/serverconfig.xml"
  56. backupdir="${rootdir}/backups"
  57. # Logging
  58. logdays="7"
  59. gamelogdir="${rootdir}/log/server"
  60. scriptlogdir="${rootdir}/log/script"
  61. consolelogdir="${rootdir}/log/console"
  62. gamelog="${gamelogdir}/${servicename}-game.log"
  63. scriptlog="${scriptlogdir}/${servicename}-script.log"
  64. consolelog="${consolelogdir}/${servicename}-console.log"
  65. emaillog="${scriptlogdir}/${servicename}-email.log"
  66. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  67. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  68. ##### Script #####
  69. # Do not edit
  70. fn_getgithubfile(){
  71. filename=$1
  72. exec=$2
  73. fileurl=${3:-$filename}
  74. filepath="${rootdir}/${filename}"
  75. filedir=$(dirname "${filepath}")
  76. # If the function file is missing, then download
  77. if [ ! -f "${filepath}" ]; then
  78. if [ ! -d "${filedir}" ]; then
  79. mkdir "${filedir}"
  80. fi
  81. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  82. echo -e " fetching ${filename}...\c"
  83. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  84. :
  85. else
  86. echo -e "\e[0;31mFAIL\e[0m\n"
  87. echo "Curl is not installed!"
  88. echo -e ""
  89. exit
  90. fi
  91. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  92. if [ $? -ne 0 ]; then
  93. echo -e "\e[0;31mFAIL\e[0m\n"
  94. echo " ${curl}"|grep "curl:"
  95. echo -e "${githuburl}\n"
  96. exit
  97. else
  98. echo -e "\e[0;32mOK\e[0m"
  99. fi
  100. if [ "${exec}" ]; then
  101. chmod +x "${filepath}"
  102. fi
  103. fi
  104. if [ "${exec}" ]; then
  105. source "${filepath}"
  106. fi
  107. }
  108. fn_runfunction(){
  109. fn_getgithubfile "functions/${functionfile}" 1
  110. }
  111. fn_functions(){
  112. # Functions are defined in fn_functions.
  113. functionfile="${FUNCNAME}"
  114. fn_runfunction
  115. }
  116. fn_functions
  117. getopt=$1
  118. fn_getopt