sdtdserver 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #!/bin/bash
  2. # 7 Days To Die
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: http://danielgibbs.co.uk
  6. # Version: 010115
  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. # http://7daystodie.gamepedia.com/Server
  18. fn_parms(){
  19. parms="-configfile=\"${servercfgfullpath}\" -dedicated"
  20. }
  21. #### Advanced Variables ####
  22. # Steam
  23. appid="294420"
  24. # Server Details
  25. servicename="sdtd-server"
  26. gamename="7 Days To Die"
  27. engine="unity3d"
  28. # Directories
  29. rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  30. selfname="$0"
  31. lockselfname=$(echo ".${servicename}.lock")
  32. filesdir="${rootdir}/serverfiles"
  33. systemdir="${filesdir}"
  34. executabledir="${filesdir}"
  35. executable="./7DaysToDie.sh"
  36. servercfgdir="${filesdir}"
  37. servercfg="${servicename}.xml"
  38. servercfgfullpath="${servercfgdir}/${servercfg}"
  39. defaultcfg="${filesdir}/serverconfig.xml"
  40. backupdir="backups"
  41. # Server Details
  42. servername=$(grep ServerName "${servercfgfullpath}"|sed 's/^.*value="//'|cut -f1 -d"\"")
  43. # Logging
  44. logdays="7"
  45. gamelogdir="${rootdir}/log/server"
  46. scriptlogdir="${rootdir}/log/script"
  47. consolelogdir="${rootdir}/log/console"
  48. gamelog="${gamelogdir}/${servicename}-game.log"
  49. scriptlog="${scriptlogdir}/${servicename}-script.log"
  50. consolelog="${consolelogdir}/${servicename}-console.log"
  51. emaillog="${scriptlogdir}/${servicename}-email.log"
  52. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  53. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  54. ##### Script #####
  55. # Do not edit
  56. fn_install(){
  57. fn_rootcheck
  58. fn_header
  59. if [ -z "${autoinstall}" ]; then
  60. fn_serverdirectory
  61. fn_header
  62. fi
  63. fn_steamdl
  64. fn_steaminstall
  65. fn_loginstall
  66. fn_getquery
  67. fn_serverconfig
  68. fn_header
  69. fn_details
  70. fn_installcomplete
  71. }
  72. fn_functions(){
  73. # Functions are defines in fn_functions.
  74. functionfile="${FUNCNAME}"
  75. fn_runfunction
  76. }
  77. fn_runfunction(){
  78. # Functions are downloaded and run with this function
  79. if [ ! -f "${rootdir}/functions/${functionfile}" ]; then
  80. cd "${rootdir}"
  81. if [ ! -d "functions" ]; then
  82. mkdir functions
  83. fi
  84. cd functions
  85. echo -e "loading ${functionfile}...\c"
  86. wget -N --no-check-certificate /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/${functionfile} 2>&1 | grep -F HTTP | cut -c45-
  87. chmod +x "${functionfile}"
  88. cd "${rootdir}"
  89. sleep 1
  90. fi
  91. source "${rootdir}/functions/${functionfile}"
  92. }
  93. fn_functions
  94. case "$1" in
  95. start)
  96. fn_startserver;;
  97. stop)
  98. fn_stopserver;;
  99. restart)
  100. fn_restartserver;;
  101. update)
  102. norestart=1;;
  103. fn_versioncheck;;
  104. update-restart)
  105. fn_versioncheck;;
  106. validate)
  107. fn_validateserver;;
  108. validate-restart)
  109. fn_stopserver
  110. fn_validateserver
  111. fn_startserver;;
  112. monitor)
  113. fn_monitorserver;;
  114. email-test)
  115. fn_emailtest;;
  116. details)
  117. fn_details;;
  118. backup)
  119. fn_backupserver;;
  120. console)
  121. fn_console;;
  122. debug)
  123. fn_debugserver;;
  124. install)
  125. fn_install;;
  126. auto-install)
  127. fn_autoinstall;;
  128. *)
  129. echo "Usage: $0 {start|stop|restart|update|update-restart|validate|validate-restart|monitor|email-test|details|backup|console|debug|install|auto-install}"
  130. exit 1;;
  131. esac
  132. exit