fn_getopt 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. #!/bin/bash
  2. # LGSM fn_getopt function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. # Version: 301015
  6. # Description: getopt arguments.
  7. fn_getopt_generic(){
  8. case "$getopt" in
  9. start)
  10. fn_start;;
  11. stop)
  12. fn_stop;;
  13. restart)
  14. fn_restart;;
  15. update)
  16. fn_update_check;;
  17. force-update)
  18. forceupdate=1;
  19. fn_update_check;;
  20. update-restart)
  21. forceupdate=1;
  22. fn_update_check;;
  23. update-functions)
  24. fn_update_functions;;
  25. validate)
  26. fn_validate;;
  27. monitor)
  28. fn_monitor;;
  29. email-test)
  30. fn_email_test;;
  31. details)
  32. fn_details;;
  33. backup)
  34. fn_backup;;
  35. console)
  36. fn_console;;
  37. debug)
  38. fn_debug;;
  39. install)
  40. fn_install;;
  41. auto-install)
  42. fn_autoinstall;;
  43. depsdetect)
  44. fn_deps_detect;;
  45. *)
  46. echo "Usage: $0 {start|stop|restart|update|force-update|update-functions|validate|monitor|email-test|details|backup|console|debug|install|auto-install}"
  47. exit 1;;
  48. esac
  49. exit
  50. }
  51. fn_getopt_teamspeak3(){
  52. case "$getopt" in
  53. start)
  54. fn_start;;
  55. stop)
  56. fn_stop;;
  57. restart)
  58. fn_restart;;
  59. update)
  60. fn_update_check;;
  61. update-functions)
  62. fn_update_functions;;
  63. monitor)
  64. fn_monitor;;
  65. email-test)
  66. fn_email_test;;
  67. details)
  68. fn_details;;
  69. backup)
  70. fn_backup;;
  71. install)
  72. fn_install;;
  73. auto-install)
  74. fn_autoinstall;;
  75. depsdetect)
  76. fn_deps_detect;;
  77. *)
  78. echo "Usage: $0 {start|stop|restart|update|update-functions|monitor|email-test|details|backup|install|auto-install}"
  79. exit 1;;
  80. esac
  81. exit
  82. }
  83. fn_getopt_mumble(){
  84. case "$getopt" in
  85. start)
  86. fn_start;;
  87. stop)
  88. fn_stop;;
  89. restart)
  90. fn_restart;;
  91. update-functions)
  92. fn_update_functions;;
  93. monitor)
  94. fn_monitor;;
  95. email-test)
  96. fn_email_test;;
  97. backup)
  98. fn_backup;;
  99. console)
  100. fn_console;;
  101. debug)
  102. fn_debug;;
  103. depsdetect)
  104. fn_deps_detect;;
  105. *)
  106. echo "Usage: $0 {start|stop|restart|update-functions|monitor|email-test|backup|console|debug}"
  107. exit 1;;
  108. esac
  109. exit
  110. }
  111. fn_getopt_gmodserver(){
  112. case "$getopt" in
  113. start)
  114. fn_start;;
  115. stop)
  116. fn_stop;;
  117. restart)
  118. fn_restart;;
  119. update)
  120. fn_update_check;;
  121. force-update|update-restart)
  122. forceupdate=1;
  123. fn_update_check;;
  124. update-functions|updatefunctions)
  125. fn_update_functions;;
  126. validate)
  127. fn_validate;;
  128. monitor)
  129. fn_monitor;;
  130. email-test|emailtest)
  131. fn_email_test;;
  132. details)
  133. fn_details;;
  134. backup)
  135. fn_backup;;
  136. console)
  137. fn_console;;
  138. debug)
  139. fn_debug;;
  140. install)
  141. fn_install;;
  142. auto-install|autoinstall)
  143. fn_autoinstall;;
  144. content)
  145. echo
  146. fn_content_gmod;;
  147. depsdetect)
  148. fn_deps_detect;;
  149. *)
  150. echo "Usage: $0 [option]
  151. ${gamename} - Linux Game Server Manager - Version ${version}
  152. http://gameservermanagers.com/${selfname}"
  153. echo -e ""
  154. echo -e "\e[93mCommands\e[0m"
  155. {
  156. echo -e "\e[34mstart\t\e[0mStart the server."
  157. echo -e "\e[34mstop\t\e[0mStop the server."
  158. echo -e "\e[34mrestart\t\e[0mRestart the server."
  159. echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD."
  160. echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD."
  161. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  162. echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD."
  163. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  164. echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
  165. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  166. echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
  167. echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
  168. echo -e "\e[34minstall\t\e[0mInstall the server."
  169. echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
  170. echo -e "\e[34mgmod-content\t\e[0mDownload gmod add-on content."
  171. } | column -s $'\t' -t
  172. esac
  173. exit
  174. }
  175. fn_getopt_unreal(){
  176. case "$getopt" in
  177. start)
  178. fn_start;;
  179. stop)
  180. fn_stop;;
  181. restart)
  182. fn_restart;;
  183. update-functions)
  184. fn_update_functions;;
  185. monitor)
  186. fn_monitor;;
  187. email-test)
  188. fn_email_test;;
  189. details)
  190. fn_details;;
  191. backup)
  192. fn_backup;;
  193. console)
  194. fn_console;;
  195. debug)
  196. fn_debug;;
  197. install)
  198. fn_install;;
  199. map-compressor)
  200. fn_compress_ut99maps;;
  201. depsdetect)
  202. fn_deps_detect;;
  203. *)
  204. echo "Usage: $0 {start|stop|restart|update-functions|monitor|email-test|details|backup|console|debug|install|map-compressor}"
  205. exit 1;;
  206. esac
  207. exit
  208. }
  209. fn_getopt_unreal2(){
  210. case "$getopt" in
  211. start)
  212. fn_start;;
  213. stop)
  214. fn_stop;;
  215. restart)
  216. fn_restart;;
  217. update)
  218. fn_update_check;;
  219. force-update)
  220. forceupdate=1;
  221. fn_update_check;;
  222. update-restart)
  223. forceupdate=1;
  224. fn_update_check;;
  225. update-functions)
  226. fn_update_functions;;
  227. validate)
  228. fn_validate;;
  229. monitor)
  230. fn_monitor;;
  231. email-test)
  232. fn_email_test;;
  233. details)
  234. fn_details;;
  235. backup)
  236. fn_backup;;
  237. console)
  238. fn_console;;
  239. debug)
  240. fn_debug;;
  241. install)
  242. fn_install;;
  243. auto-install)
  244. fn_autoinstall;;
  245. map-compressor)
  246. fn_compress_unreal2maps;;
  247. depsdetect)
  248. fn_deps_detect;;
  249. *)
  250. echo "Usage: $0 {start|stop|restart|update|update-functions|validate|monitor|email-test|details|backup|console|debug|install|auto-install|map-compressor}"
  251. exit 1;;
  252. esac
  253. exit
  254. }
  255. fn_getopt_ut2k4(){
  256. case "$getopt" in
  257. start)
  258. fn_start;;
  259. stop)
  260. fn_stop;;
  261. restart)
  262. fn_restart;;
  263. update-functions)
  264. fn_update_functions;;
  265. monitor)
  266. fn_monitor;;
  267. email-test)
  268. fn_email_test;;
  269. details)
  270. fn_details;;
  271. backup)
  272. fn_backup;;
  273. console)
  274. fn_console;;
  275. debug)
  276. fn_debug;;
  277. install)
  278. fn_install;;
  279. map-compressor)
  280. fn_compress_unreal2maps;;
  281. depsdetect)
  282. fn_deps_detect;;
  283. *)
  284. echo "Usage: $0 {start|stop|restart|update-functions|monitor|email-test|details|backup|console|debug|install|map-compressor}"
  285. exit 1;;
  286. esac
  287. exit
  288. }
  289. if [ "${gamename}" == "Mumble" ]; then
  290. fn_getopt_mumble
  291. elif [ "${gamename}" == "Teamspeak 3" ]; then
  292. fn_getopt_teamspeak3
  293. elif [ "${engine}" == "unreal2" ]; then
  294. if [ "${gamename}" == "Unreal Tournament 2004" ]; then
  295. fn_getopt_ut2k4
  296. else
  297. fn_getopt_unreal2
  298. fi
  299. elif [ "${engine}" == "unreal" ]; then
  300. fn_getopt_unreal
  301. elif [ "$gamename" == "Garry's Mod" ]; then
  302. fn_getopt_gmodserver
  303. else
  304. fn_getopt_generic
  305. fi