sbserver 2.8 KB

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