4
0

sbserver 2.7 KB

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