roserver 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. #!/bin/bash
  2. # Red Orchestra: Ostfront 41-45
  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. # Steam login
  13. steamuser="username"
  14. steampass="password"
  15. # Steam
  16. appid="223250"
  17. # Directories
  18. rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )"
  19. selfname="$0"
  20. lockselfname=$(echo ".${servicename}.lock")
  21. filesdir="${rootdir}/serverfiles"
  22. systemdir="${filesdir}/system"
  23. executabledir="${systemdir}"
  24. executable="./ucc-bin"
  25. compressedmapsdir="${rootdir}/Maps-Compressed"
  26. defaultcfg="${systemdir}/default.ini"
  27. backupdir="backups"
  28. # Server Details
  29. servicename="ro-server"
  30. gamename="Red Orchestra: Ostfront 41-45"
  31. engine="unreal2"
  32. ini="${servicename}.ini"
  33. servername=$(grep -s ServerName= ${systemdir}/${ini}|sed 's/ServerName=//g')
  34. ip="0.0.0.0"
  35. # Logging
  36. logdays="7"
  37. gamelogdir="${rootdir}/log/server"
  38. scriptlogdir="${rootdir}/log/script"
  39. consolelogdir="${rootdir}/log/console"
  40. gamelog="${gamelogdir}/${servicename}-game.log"
  41. scriptlog="${scriptlogdir}/${servicename}-script.log"
  42. consolelog="${consolelogdir}/${servicename}-console.log"
  43. emaillog="${scriptlogdir}/${servicename}-email.log"
  44. gamelogdate="${gamelogdir}/${servicename}-game-$(date '+%d-%m-%Y-%H-%M-%S').log"
  45. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  46. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  47. # Start Variables
  48. fn_parms(){
  49. defaultmap="RO-Arad.rom"
  50. parms="server ${defaultmap}?game=ROGame.ROTeamGame?VACSecured=true -nohomedir ini=${ini} log=${gamelog}"
  51. }
  52. ##### Script #####
  53. # Do not edit
  54. # unless you know
  55. # what you are doing
  56. fn_scriptlog(){
  57. echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${1}" >> "${scriptlog}"
  58. }
  59. # [ FAIL ]
  60. fn_printfail(){
  61. echo -en "\r\033[K[\e[0;31m FAIL \e[0;39m] $@"
  62. }
  63. fn_printfailnl(){
  64. echo -e "\r\033[K[\e[0;31m FAIL \e[0;39m] $@"
  65. }
  66. # [ OK ]
  67. fn_printok(){
  68. echo -en "\r\033[K[\e[0;32m OK \e[0;39m] $@"
  69. }
  70. fn_printoknl(){
  71. echo -e "\r\033[K[\e[0;32m OK \e[0;39m] $@"
  72. }
  73. # [ INFO ]
  74. fn_printinfo(){
  75. echo -en "\r\033[K[\e[0;36m INFO \e[0;39m] $@"
  76. }
  77. fn_printinfonl(){
  78. echo -e "\r\033[K[\e[0;36m INFO \e[0;39m] $@"
  79. }
  80. # [ WARN ]
  81. fn_printwarn(){
  82. echo -en "\r\033[K[\e[1;33m WARN \e[0;39m] $@"
  83. }
  84. fn_printwarnnl(){
  85. echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@"
  86. }
  87. # [ .... ]
  88. fn_printdots(){
  89. echo -en "\r\033[K[ .... ] $@"
  90. }
  91. fn_rootcheck(){
  92. functionfile="${FUNCNAME}"
  93. fn_runfunction
  94. }
  95. fn_syscheck(){
  96. if [ ! -e "${systemdir}" ]; then
  97. fn_printfailnl "Cannot access ${systemdir}: No such directory"
  98. exit
  99. fi
  100. }
  101. fn_autoip(){
  102. functionfile="${FUNCNAME}"
  103. fn_runfunction
  104. }
  105. fn_logmanager(){
  106. functionfile="${FUNCNAME}"
  107. fn_runfunction
  108. }
  109. fn_debugserver(){
  110. functionfile="${FUNCNAME}"
  111. fn_runfunction
  112. }
  113. fn_console(){
  114. functionfile="${FUNCNAME}"
  115. fn_runfunction
  116. }
  117. fn_backupserver(){
  118. functionfile="${FUNCNAME}"
  119. fn_runfunction
  120. }
  121. fn_distro(){
  122. functionfile="${FUNCNAME}"
  123. fn_runfunction
  124. }
  125. fn_uptime(){
  126. functionfile="${FUNCNAME}"
  127. fn_runfunction
  128. }
  129. fn_load(){
  130. functionfile="${FUNCNAME}"
  131. fn_runfunction
  132. }
  133. fn_emailnotification(){
  134. functionfile="${FUNCNAME}"
  135. fn_runfunction
  136. }
  137. fn_emailtest(){
  138. functionfile="${FUNCNAME}"
  139. fn_runfunction
  140. }
  141. fn_serverquery(){
  142. functionfile="${FUNCNAME}"
  143. fn_runfunction
  144. }
  145. fn_monitorserver(){
  146. functionfile="${FUNCNAME}"
  147. fn_runfunction
  148. }
  149. fn_updateserver(){
  150. functionfile="${FUNCNAME}"
  151. fn_runfunction
  152. }
  153. fn_validateserver(){
  154. functionfile="${FUNCNAME}"
  155. fn_runfunction
  156. }
  157. fn_restartserver(){
  158. fn_scriptlog "Restarting ${servername}"
  159. fn_stopserver
  160. fn_startserver
  161. }
  162. fn_stopserver(){
  163. functionfile="${FUNCNAME}"
  164. fn_runfunction
  165. }
  166. fn_startserver(){
  167. functionfile="${FUNCNAME}"
  168. fn_runfunction
  169. }
  170. fn_details(){
  171. functionfile="${FUNCNAME}"
  172. fn_runfunction
  173. }
  174. fn_runfunction(){
  175. # Download function if missing
  176. if [ ! -f "${rootdir}/functions/${functionfile}" ]; then
  177. cd "${rootdir}"
  178. if [ ! -d "functions" ]; then
  179. mkdir functions
  180. fi
  181. echo "loading ${functionfile}..."
  182. cd functions
  183. wget --no-check-certificate -nv -N https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/${functionfile}
  184. chmod +x "${functionfile}"
  185. cd "${rootdir}"
  186. sleep 1
  187. echo ""
  188. fi
  189. # Run function
  190. source "${rootdir}/functions/${functionfile}"
  191. }
  192. fn_unreal2compressmaps(){
  193. functionfile="${FUNCNAME}"
  194. fn_runfunction
  195. }
  196. #
  197. ## Installer
  198. #
  199. fn_rofix(){
  200. functionfile="${FUNCNAME}"
  201. fn_runfunction
  202. }
  203. fn_header(){
  204. functionfile="${FUNCNAME}"
  205. fn_runfunction
  206. }
  207. fn_steamdl(){
  208. functionfile="${FUNCNAME}"
  209. fn_runfunction
  210. }
  211. fn_steaminstall(){
  212. functionfile="${FUNCNAME}"
  213. fn_runfunction
  214. }
  215. fn_steamfix(){
  216. functionfile="${FUNCNAME}"
  217. fn_runfunction
  218. }
  219. fn_loginstall(){
  220. functionfile="${FUNCNAME}"
  221. fn_runfunction
  222. }
  223. fn_getquery(){
  224. functionfile="${FUNCNAME}"
  225. fn_runfunction
  226. }
  227. fn_retryinstall(){
  228. functionfile="${FUNCNAME}"
  229. fn_runfunction
  230. }
  231. fn_serverdirectory(){
  232. functionfile="${FUNCNAME}"
  233. fn_runfunction
  234. }
  235. fn_serverconfig(){
  236. functionfile="${FUNCNAME}"
  237. fn_runfunction
  238. }
  239. fn_install(){
  240. fn_rootcheck
  241. fn_header
  242. if [ -z "${autoinstall}" ]; then
  243. fn_serverdirectory
  244. fn_header
  245. fi
  246. fn_steamdl
  247. fn_steaminstall
  248. fn_steamfix
  249. fn_loginstall
  250. fn_getquery
  251. fn_serverconfig
  252. fn_rofix
  253. fn_header
  254. fn_details
  255. echo "================================="
  256. echo "Install Complete!"
  257. echo ""
  258. echo "To start server type:"
  259. echo "${selfname} start"
  260. echo ""
  261. }
  262. fn_autoinstall(){
  263. autoinstall=1
  264. fn_install
  265. }
  266. case "$1" in
  267. start)
  268. fn_startserver;;
  269. stop)
  270. fn_stopserver;;
  271. restart)
  272. fn_restartserver;;
  273. update)
  274. fn_updateserver;;
  275. update-restart)
  276. fn_stopserver
  277. fn_updateserver
  278. fn_startserver;;
  279. validate)
  280. fn_validateserver;;
  281. validate-restart)
  282. fn_stopserver
  283. fn_validateserver
  284. fn_startserver;;
  285. monitor)
  286. fn_monitorserver;;
  287. email-test)
  288. fn_emailtest;;
  289. details)
  290. fn_details;;
  291. backup)
  292. fn_backupserver;;
  293. console)
  294. fn_console;;
  295. debug)
  296. fn_debugserver;;
  297. install)
  298. fn_install;;
  299. auto-install)
  300. fn_autoinstall;;
  301. map-compressor)
  302. fn_unreal2compressmaps;;
  303. *)
  304. echo "Usage: $0 {start|stop|restart|update|update-restart|validate|validate-restart|monitor|email-test|details|backup|console|debug|install|auto-install|map-compressor}"
  305. exit 1;;
  306. esac
  307. exit