ss3sserver 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. #!/bin/bash
  2. # Serious Sam 3: BFE
  3. # Server Management Script
  4. # Author: Daniel Gibbs
  5. # Website: http://danielgibbs.co.uk
  6. # Version: 161214
  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. # https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/SeriousSam3BFE/help/DedicatedServer_Readme.txt
  18. fn_parms(){
  19. parms="+ip ${ip} +logfile ${gamelog} +exec ${servercfgfullpath}"
  20. }
  21. #### Advanced Variables ####
  22. # Steam
  23. appid="41080"
  24. # Server Details
  25. servicename="ss3-server"
  26. gamename="Serious Sam 3: BFE"
  27. engine="seriousengine35"
  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}/Bin"
  34. executabledir="${systemdir}"
  35. executable="./runSam3_DedicatedServer.sh"
  36. servercfgdir="${filesdir}/Content/SeriousSam3/Config"
  37. servercfg="${servicename}.ini"
  38. servercfgfullpath="${servercfgdir}/${servercfg}"
  39. backupdir="backups"
  40. # Logging
  41. logdays="7"
  42. gamelogdir="${rootdir}/log/server"
  43. scriptlogdir="${rootdir}/log/script"
  44. consolelogdir="${rootdir}/log/console"
  45. gamelog="${gamelogdir}/${servicename}-game.log"
  46. scriptlog="${scriptlogdir}/${servicename}-script.log"
  47. consolelog="${consolelogdir}/${servicename}-console.log"
  48. emaillog="${scriptlogdir}/${servicename}-email.log"
  49. gamelogdate="${gamelogdir}/${servicename}-game-$(date '+%d-%m-%Y-%H-%M-%S').log"
  50. scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log"
  51. consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log"
  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. #
  193. ## Installer
  194. #
  195. fn_glibcfix(){
  196. functionfile="${FUNCNAME}"
  197. fn_runfunction
  198. }
  199. fn_header(){
  200. functionfile="${FUNCNAME}"
  201. fn_runfunction
  202. }
  203. fn_steamdl(){
  204. functionfile="${FUNCNAME}"
  205. fn_runfunction
  206. }
  207. fn_steaminstall(){
  208. functionfile="${FUNCNAME}"
  209. fn_runfunction
  210. }
  211. fn_steamfix(){
  212. functionfile="${FUNCNAME}"
  213. fn_runfunction
  214. }
  215. fn_loginstall(){
  216. functionfile="${FUNCNAME}"
  217. fn_runfunction
  218. }
  219. fn_getquery(){
  220. functionfile="${FUNCNAME}"
  221. fn_runfunction
  222. }
  223. fn_retryinstall(){
  224. functionfile="${FUNCNAME}"
  225. fn_runfunction
  226. }
  227. fn_serverdirectory(){
  228. functionfile="${FUNCNAME}"
  229. fn_runfunction
  230. }
  231. fn_serverconfig(){
  232. functionfile="${FUNCNAME}"
  233. fn_runfunction
  234. }
  235. fn_install(){
  236. fn_rootcheck
  237. fn_header
  238. if [ -z "${autoinstall}" ]; then
  239. fn_serverdirectory
  240. fn_header
  241. fi
  242. fn_steamdl
  243. fn_steaminstall
  244. fn_steamfix
  245. fn_glibcfix
  246. fn_loginstall
  247. fn_serverconfig
  248. fn_header
  249. fn_details
  250. echo "================================="
  251. echo "Install Complete!"
  252. echo ""
  253. echo "To start server type:"
  254. echo "${selfname} start"
  255. echo ""
  256. }
  257. fn_autoinstall(){
  258. autoinstall=1
  259. fn_install
  260. }
  261. case "$1" in
  262. start)
  263. fn_startserver;;
  264. stop)
  265. fn_stopserver;;
  266. restart)
  267. fn_restartserver;;
  268. update)
  269. fn_updateserver;;
  270. update-restart)
  271. fn_stopserver
  272. fn_updateserver
  273. fn_startserver;;
  274. validate)
  275. fn_validateserver;;
  276. validate-restart)
  277. fn_stopserver
  278. fn_validateserver
  279. fn_startserver;;
  280. monitor)
  281. fn_monitorserver;;
  282. email-test)
  283. fn_emailtest;;
  284. details)
  285. fn_details;;
  286. backup)
  287. fn_backupserver;;
  288. console)
  289. fn_console;;
  290. debug)
  291. fn_debugserver;;
  292. install)
  293. fn_install;;
  294. auto-install)
  295. fn_autoinstall;;
  296. *)
  297. echo "Usage: $0 {start|stop|restart|update|update-restart|validate|validate-restart|monitor|email-test|details|backup|console|debug|install|auto-install}"
  298. exit 1;;
  299. esac
  300. exit