terrariaserver 2.8 KB

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