ut2k4server 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. #!/bin/bash
  2. # Unreal Tournament 2004
  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. # Directories
  13. rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  14. selfname="$0"
  15. lockselfname=$(echo ".${servicename}.lock")
  16. filesdir="${rootdir}/serverfiles"
  17. systemdir="${filesdir}/System"
  18. executabledir="${systemdir}"
  19. executable="./ucc-bin"
  20. compressedmapsdir="${rootdir}/Maps-Compressed"
  21. defaultcfg="${systemdir}/UT2004.ini"
  22. backupdir="backups"
  23. # Server Details
  24. servicename="ut2k4-server"
  25. gamename="Unreal Tournament 2004"
  26. engine="unreal2"
  27. ini="${servicename}.ini"
  28. servername=$(grep -s ServerName= ${systemdir}/${ini}|sed 's/ServerName=//g')
  29. ip="0.0.0.0"
  30. # Logging
  31. logdays="7"
  32. gamelogdir="${rootdir}/log/server"
  33. scriptlogdir="${rootdir}/log/script"
  34. consolelogdir="${rootdir}/log/console"
  35. gamelog="${gamelogdir}/${servicename}-game.log"
  36. scriptlog="${scriptlogdir}/${servicename}-script.log"
  37. consolelog="${consolelogdir}/${servicename}-console.log"
  38. emaillog="${scriptlogdir}/${servicename}-email.log"
  39. gamelogdate="${gamelogdir}/${servicename}-game-$(date '+%d-%m-%Y-%H-%M-%S').log"
  40. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  41. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  42. # Start Variables
  43. fn_parms(){
  44. defaultmap="DM-Rankin"
  45. parms="server ${defaultmap}?game=XGame.xDeathMatch -nohomedir ini=${ini} log=${gamelog}"
  46. }
  47. ##### Script #####
  48. # Do not edit
  49. fn_install(){
  50. fn_rootcheck
  51. fn_header
  52. if [ -z "${autoinstall}" ]; then
  53. fn_serverdirectory
  54. fn_header
  55. fi
  56. fn_ut2k4filesdl
  57. fn_ut2k4install
  58. fn_ut2k4key
  59. fn_loginstall
  60. fn_getquery
  61. fn_serverconfig
  62. fn_ut2k4fix
  63. fn_header
  64. fn_details
  65. fn_installcomplete
  66. }
  67. fn_functions(){
  68. # Functions are defines in fn_functions.
  69. functionfile="${FUNCNAME}"
  70. fn_runfunction
  71. }
  72. fn_runfunction(){
  73. # Functions are downloaded and run with this function
  74. if [ ! -f "${rootdir}/functions/${functionfile}" ]; then
  75. cd "${rootdir}"
  76. if [ ! -d "functions" ]; then
  77. mkdir functions
  78. fi
  79. cd functions
  80. echo -e "loading ${functionfile}...\c"
  81. wget -N --no-check-certificate /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/${functionfile} 2>&1 | grep -F HTTP | cut -c45-
  82. chmod +x "${functionfile}"
  83. cd "${rootdir}"
  84. sleep 1
  85. fi
  86. source "${rootdir}/functions/${functionfile}"
  87. }
  88. fn_unreal2compressmaps(){
  89. functionfile="${FUNCNAME}"
  90. fn_runfunction
  91. }
  92. #
  93. ## Installer
  94. #
  95. fn_ut2k4fix(){
  96. functionfile="${FUNCNAME}"
  97. fn_runfunction
  98. }
  99. fn_header(){
  100. functionfile="${FUNCNAME}"
  101. fn_runfunction
  102. }
  103. fn_ut2k4filesdl(){
  104. functionfile="${FUNCNAME}"
  105. fn_runfunction
  106. }
  107. fn_ut2k4key(){
  108. functionfile="${FUNCNAME}"
  109. fn_runfunction
  110. }
  111. fn_ut2k4install(){
  112. functionfile="${FUNCNAME}"
  113. fn_runfunction
  114. }
  115. fn_loginstall(){
  116. functionfile="${FUNCNAME}"
  117. fn_runfunction
  118. }
  119. fn_getquery(){
  120. functionfile="${FUNCNAME}"
  121. fn_runfunction
  122. }
  123. fn_retryinstall(){
  124. functionfile="${FUNCNAME}"
  125. fn_runfunction
  126. }
  127. fn_serverdirectory(){
  128. functionfile="${FUNCNAME}"
  129. fn_runfunction
  130. }
  131. fn_serverconfig(){
  132. functionfile="${FUNCNAME}"
  133. fn_runfunction
  134. }
  135. fn_install(){
  136. fn_rootcheck
  137. fn_header
  138. if [ -z "${autoinstall}" ]; then
  139. fn_serverdirectory
  140. fn_header
  141. fi
  142. fn_ut2k4filesdl
  143. fn_ut2k4install
  144. fn_ut2k4key
  145. fn_loginstall
  146. fn_getquery
  147. fn_serverconfig
  148. fn_ut2k4fix
  149. fn_header
  150. fn_details
  151. echo "================================="
  152. echo "Install Complete!"
  153. echo ""
  154. echo "To start server type:"
  155. echo "${selfname} start"
  156. echo ""
  157. }
  158. case "$1" in
  159. start)
  160. fn_startserver;;
  161. stop)
  162. fn_stopserver;;
  163. restart)
  164. fn_restartserver;;
  165. monitor)
  166. fn_monitorserver;;
  167. email-test)
  168. fn_emailtest;;
  169. details)
  170. fn_details;;
  171. backup)
  172. fn_backupserver;;
  173. console)
  174. fn_console;;
  175. debug)
  176. fn_debugserver;;
  177. install)
  178. fn_install;;
  179. map-compressor)
  180. fn_unreal2compressmaps;;
  181. *)
  182. echo "Usage: $0 {start|stop|restart|monitor|email-test|details|backup|console|debug|install|map-compressor}"
  183. exit 1;;
  184. esac
  185. exit