hwserver 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. # Server settings
  22. servername="Hurtworld LGSM Server"
  23. ip="0.0.0.0"
  24. port="12871"
  25. queryport="12881"
  26. maxplayers="20"
  27. map="" #Optional
  28. creativemode="0" #Free Build
  29. # Adding first admins
  30. # Syntax : addadmin STEAMID64; addadmin STEAMID64-bis
  31. # Example : addadmin="addadmin 012345678901234567; addadmin 987654321098765432"
  32. addadmin=""
  33. # Maintenance settings
  34. logfile="gamelog.txt"
  35. loadsave=""
  36. # EXPERIMENTAL ! Use at your own risk
  37. # Setting this to 1 runs the server with the x64 bits exectutable
  38. x64mode="0"
  39. # http://hurtworld.wikia.com/wiki/Hosting_A_Server
  40. fn_parms(){
  41. parms="-batchmode -nographics -exec \"host ${port} ${map} ${save};queryport ${queryport};maxplayers ${maxplayers};servername ${servername};creativemode ${creativemode};${addadmin}\" -logfile \"${logfile}\" "
  42. }
  43. #### Advanced Variables ####
  44. # Github Branch Select
  45. # Allows for the use of different function files
  46. # from a different repo and/or branch.
  47. githubuser="dgibbs64"
  48. githubrepo="linuxgsm"
  49. githubbranch="hurt-world"
  50. # Steam
  51. appid="405100"
  52. # Server Details
  53. servicename="hurtworld-server"
  54. gamename="Hurtworld"
  55. engine="unity3d"
  56. # Directories
  57. rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
  58. selfname=$(basename $(readlink -f "${BASH_SOURCE[0]}"))
  59. lockselfname=".${servicename}.lock"
  60. filesdir="${rootdir}/serverfiles"
  61. systemdir="${filesdir}"
  62. executabledir="${filesdir}"
  63. if [ "${x64mode}" == "1" ]; then
  64. executable="./Hurtworld.x86_64"
  65. else
  66. executable="./Hurtworld.x86"
  67. fi
  68. backupdir="${rootdir}/backups"
  69. # Logging
  70. logdays="7"
  71. gamelogdir="${rootdir}/log/server"
  72. scriptlogdir="${rootdir}/log/script"
  73. consolelogdir="${rootdir}/log/console"
  74. gamelog="${gamelogdir}/${servicename}-game.log"
  75. scriptlog="${scriptlogdir}/${servicename}-script.log"
  76. consolelog="${consolelogdir}/${servicename}-console.log"
  77. emaillog="${scriptlogdir}/${servicename}-email.log"
  78. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  79. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  80. ##### Script #####
  81. # Do not edit
  82. fn_getgithubfile(){
  83. filename=$1
  84. exec=$2
  85. fileurl=${3:-$filename}
  86. filepath="${rootdir}/${filename}"
  87. filedir=$(dirname "${filepath}")
  88. # If the function file is missing, then download
  89. if [ ! -f "${filepath}" ]; then
  90. if [ ! -d "${filedir}" ]; then
  91. mkdir "${filedir}"
  92. fi
  93. githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}"
  94. echo -e " fetching ${filename}...\c"
  95. if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then
  96. :
  97. else
  98. echo -e "\e[0;31mFAIL\e[0m\n"
  99. echo "Curl is not installed!"
  100. echo -e ""
  101. exit
  102. fi
  103. curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1)
  104. if [ $? -ne 0 ]; then
  105. echo -e "\e[0;31mFAIL\e[0m\n"
  106. echo " ${curl}"|grep "curl:"
  107. echo -e "${githuburl}\n"
  108. exit
  109. else
  110. echo -e "\e[0;32mOK\e[0m"
  111. fi
  112. if [ "${exec}" ]; then
  113. chmod +x "${filepath}"
  114. fi
  115. fi
  116. if [ "${exec}" ]; then
  117. source "${filepath}"
  118. fi
  119. }
  120. fn_runfunction(){
  121. fn_getgithubfile "functions/${functionfile}" 1
  122. }
  123. fn_functions(){
  124. # Functions are defined in fn_functions.
  125. functionfile="${FUNCNAME}"
  126. fn_runfunction
  127. }
  128. fn_functions
  129. getopt=$1
  130. fn_getopt