ut99server 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. #!/bin/bash
  2. # Unreal Tournament 99
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: http://danielgibbs.co.uk
  6. # Version: 011214
  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}/Default.ini"
  22. backupdir="backups"
  23. # Server Details
  24. servicename="ut99-server"
  25. gamename="Unreal Tournament 99"
  26. engine="unreal"
  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. scriptlogdir="${rootdir}/log/script"
  33. consolelogdir="${rootdir}/log/console"
  34. scriptlog="${scriptlogdir}/${servicename}-script.log"
  35. consolelog="${consolelogdir}/${servicename}-console.log"
  36. emaillog="${scriptlogdir}/${servicename}-email.log"
  37. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  38. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  39. # Start Variables
  40. fn_parms(){
  41. defaultmap="DM-Deck16]["
  42. parms="server ${defaultmap}.unr ini=${systemdir}/${ini}"
  43. }
  44. ##### Script #####
  45. # Do not edit
  46. # unless you know
  47. # what you are doing
  48. fn_scriptlog(){
  49. echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${1}" >> "${scriptlog}"
  50. }
  51. # [ FAIL ]
  52. fn_printfail(){
  53. echo -en "\r\033[K[\e[0;31m FAIL \e[0;39m] $@"
  54. }
  55. fn_printfailnl(){
  56. echo -e "\r\033[K[\e[0;31m FAIL \e[0;39m] $@"
  57. }
  58. # [ OK ]
  59. fn_printok(){
  60. echo -en "\r\033[K[\e[0;32m OK \e[0;39m] $@"
  61. }
  62. fn_printoknl(){
  63. echo -e "\r\033[K[\e[0;32m OK \e[0;39m] $@"
  64. }
  65. # [ INFO ]
  66. fn_printinfo(){
  67. echo -en "\r\033[K[\e[0;36m INFO \e[0;39m] $@"
  68. }
  69. fn_printinfonl(){
  70. echo -e "\r\033[K[\e[0;36m INFO \e[0;39m] $@"
  71. }
  72. # [ WARN ]
  73. fn_printwarn(){
  74. echo -en "\r\033[K[\e[1;33m WARN \e[0;39m] $@"
  75. }
  76. fn_printwarnnl(){
  77. echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@"
  78. }
  79. # [ .... ]
  80. fn_printdots(){
  81. echo -en "\r\033[K[ .... ] $@"
  82. }
  83. fn_rootcheck(){
  84. functionfile="${FUNCNAME}"
  85. fn_runfunction
  86. }
  87. fn_syscheck(){
  88. if [ ! -e "${systemdir}" ]; then
  89. fn_printfailnl "Cannot access ${systemdir}: No such directory"
  90. exit
  91. fi
  92. }
  93. fn_autoip(){
  94. functionfile="${FUNCNAME}"
  95. fn_runfunction
  96. }
  97. fn_logmanager(){
  98. functionfile="${FUNCNAME}"
  99. fn_runfunction
  100. }
  101. fn_debugserver(){
  102. functionfile="${FUNCNAME}"
  103. fn_runfunction
  104. }
  105. fn_console(){
  106. functionfile="${FUNCNAME}"
  107. fn_runfunction
  108. }
  109. fn_backupserver(){
  110. functionfile="${FUNCNAME}"
  111. fn_runfunction
  112. }
  113. fn_distro(){
  114. functionfile="${FUNCNAME}"
  115. fn_runfunction
  116. }
  117. fn_uptime(){
  118. functionfile="${FUNCNAME}"
  119. fn_runfunction
  120. }
  121. fn_load(){
  122. functionfile="${FUNCNAME}"
  123. fn_runfunction
  124. }
  125. fn_emailnotification(){
  126. functionfile="${FUNCNAME}"
  127. fn_runfunction
  128. }
  129. fn_emailtest(){
  130. functionfile="${FUNCNAME}"
  131. fn_runfunction
  132. }
  133. fn_serverquery(){
  134. functionfile="${FUNCNAME}"
  135. fn_runfunction
  136. }
  137. fn_monitorserver(){
  138. functionfile="${FUNCNAME}"
  139. fn_runfunction
  140. }
  141. fn_restartserver(){
  142. fn_scriptlog "Restarting ${servername}"
  143. fn_stopserver
  144. fn_startserver
  145. }
  146. fn_stopserver(){
  147. functionfile="${FUNCNAME}"
  148. fn_runfunction
  149. }
  150. fn_startserver(){
  151. functionfile="${FUNCNAME}"
  152. fn_runfunction
  153. }
  154. fn_details(){
  155. functionfile="${FUNCNAME}"
  156. fn_runfunction
  157. }
  158. fn_runfunction(){
  159. # Download function if missing
  160. if [ ! -f "${rootdir}/functions/${functionfile}" ]; then
  161. cd "${rootdir}"
  162. if [ ! -d "functions" ]; then
  163. mkdir functions
  164. fi
  165. echo "loading ${functionfile}..."
  166. cd functions
  167. wget --no-check-certificate -nv -N https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/${functionfile}
  168. chmod +x "${functionfile}"
  169. cd "${rootdir}"
  170. sleep 1
  171. echo ""
  172. fi
  173. # Run function
  174. source "${rootdir}/functions/${functionfile}"
  175. }
  176. fn_ut99compressmaps(){
  177. functionfile="${FUNCNAME}"
  178. fn_runfunction
  179. }
  180. #
  181. ## Installer
  182. #
  183. fn_ut99fix(){
  184. functionfile="${FUNCNAME}"
  185. fn_runfunction
  186. }
  187. fn_header(){
  188. functionfile="${FUNCNAME}"
  189. fn_runfunction
  190. }
  191. fn_ut99filesdl(){
  192. functionfile="${FUNCNAME}"
  193. fn_runfunction
  194. }
  195. fn_ut99install(){
  196. functionfile="${FUNCNAME}"
  197. fn_runfunction
  198. }
  199. fn_loginstall(){
  200. functionfile="${FUNCNAME}"
  201. fn_runfunction
  202. }
  203. fn_getquery(){
  204. functionfile="${FUNCNAME}"
  205. fn_runfunction
  206. }
  207. fn_retryinstall(){
  208. functionfile="${FUNCNAME}"
  209. fn_runfunction
  210. }
  211. fn_serverdirectory(){
  212. functionfile="${FUNCNAME}"
  213. fn_runfunction
  214. }
  215. fn_serverconfig(){
  216. functionfile="${FUNCNAME}"
  217. fn_runfunction
  218. }
  219. fn_install(){
  220. fn_rootcheck
  221. fn_header
  222. if [ -z "${autoinstall}" ]; then
  223. fn_serverdirectory
  224. fn_header
  225. fi
  226. fn_ut99filesdl
  227. fn_ut99install
  228. fn_loginstall
  229. fn_getquery
  230. fn_serverconfig
  231. fn_ut99fix
  232. fn_header
  233. fn_details
  234. echo "================================="
  235. echo "Install Complete!"
  236. echo ""
  237. echo "To start server type:"
  238. echo "${selfname} start"
  239. echo ""
  240. }
  241. case "$1" in
  242. start)
  243. fn_startserver;;
  244. stop)
  245. fn_stopserver;;
  246. restart)
  247. fn_restartserver;;
  248. monitor)
  249. fn_monitorserver;;
  250. email-test)
  251. fn_emailtest;;
  252. details)
  253. fn_details;;
  254. backup)
  255. fn_backupserver;;
  256. console)
  257. fn_console;;
  258. debug)
  259. fn_debugserver;;
  260. install)
  261. fn_install;;
  262. map-compressor)
  263. fn_ut99compressmaps;;
  264. *)
  265. echo "Usage: $0 {start|stop|restart|monitor|email-test|details|backup|console|debug|install|map-compressor}"
  266. exit 1;;
  267. esac
  268. exit