fn_getopt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. #!/bin/bash
  2. # LGSM fn_getopt function
  3. # Author: Daniel Gibbs
  4. # Website: http://danielgibbs.co.uk
  5. # Version: 150414
  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. validate)
  18. fn_validate;;
  19. monitor)
  20. fn_monitor;;
  21. email-test)
  22. fn_email_test;;
  23. details)
  24. fn_details;;
  25. backup)
  26. fn_backup;;
  27. console)
  28. fn_console;;
  29. debug)
  30. fn_debug;;
  31. install)
  32. fn_install;;
  33. auto-install)
  34. fn_autoinstall;;
  35. *)
  36. echo "Usage: $0 {start|stop|restart|update|validate|monitor|email-test|details|backup|console|debug|install|auto-install}"
  37. exit 1;;
  38. esac
  39. exit
  40. }
  41. fn_getopt_teamspeak3(){
  42. case "$getopt" in
  43. start)
  44. fn_start;;
  45. stop)
  46. fn_stop;;
  47. restart)
  48. fn_restart;;
  49. update)
  50. fn_update_check;;
  51. backup)
  52. fn_backup;;
  53. monitor)
  54. fn_monitor;;
  55. email-test)
  56. fn_email_test;;
  57. details)
  58. fn_details;;
  59. backup)
  60. fn_backup;;
  61. *)
  62. echo "Usage: $0 {start|stop|restart|update|backup|monitor|email-test|details|backup}"
  63. exit 1;;
  64. esac
  65. exit
  66. }
  67. fn_getopt_gmodserver(){
  68. case "$getopt" in
  69. start)
  70. fn_start;;
  71. stop)
  72. fn_stop;;
  73. restart)
  74. fn_restart;;
  75. update)
  76. fn_update_check;;
  77. validate)
  78. fn_validate;;
  79. monitor)
  80. fn_monitor;;
  81. email-test)
  82. fn_email_test;;
  83. details)
  84. fn_details;;
  85. backup)
  86. fn_backup;;
  87. console)
  88. fn_console;;
  89. debug)
  90. fn_debug;;
  91. install)
  92. fn_install;;
  93. auto-install)
  94. fn_autoinstall;;
  95. content)
  96. fn_content_gmod;;
  97. *)
  98. echo "Usage: $0 {start|stop|restart|update|validate|monitor|email-test|details|backup|console|debug|install|auto-install|content}"
  99. exit 1;;
  100. esac
  101. exit
  102. }
  103. fn_getopt_unreal(){
  104. case "$getopt" in
  105. start)
  106. fn_start;;
  107. stop)
  108. fn_stop;;
  109. restart)
  110. fn_restart;;
  111. monitor)
  112. fn_monitor;;
  113. email-test)
  114. fn_email_test;;
  115. details)
  116. fn_details;;
  117. backup)
  118. fn_backup;;
  119. console)
  120. fn_console;;
  121. debug)
  122. fn_debug;;
  123. install)
  124. fn_install;;
  125. map-compressor)
  126. fn_compress_ut99maps;;
  127. *)
  128. echo "Usage: $0 {start|stop|restart|monitor|email-test|details|backup|console|debug|install|map-compressor}"
  129. exit 1;;
  130. esac
  131. exit
  132. }
  133. fn_getopt_unreal2(){
  134. case "$getopt" in
  135. start)
  136. fn_start;;
  137. stop)
  138. fn_stop;;
  139. restart)
  140. fn_restart;;
  141. update)
  142. fn_update_check;;
  143. validate)
  144. fn_validate;;
  145. monitor)
  146. fn_monitor;;
  147. email-test)
  148. fn_email_test;;
  149. details)
  150. fn_details;;
  151. backup)
  152. fn_backup;;
  153. console)
  154. fn_console;;
  155. debug)
  156. fn_debug;;
  157. install)
  158. fn_install;;
  159. auto-install)
  160. fn_autoinstall;;
  161. map-compressor)
  162. fn_compress_unreal2maps;;
  163. *)
  164. echo "Usage: $0 {start|stop|restart|update|validate|monitor|email-test|details|backup|console|debug|install|auto-install|map-compressor}"
  165. exit 1;;
  166. esac
  167. exit
  168. }
  169. fn_getopt_ut2k4(){
  170. case "$getopt" in
  171. start)
  172. fn_start;;
  173. stop)
  174. fn_stop;;
  175. restart)
  176. fn_restart;;
  177. monitor)
  178. fn_monitor;;
  179. email-test)
  180. fn_email_test;;
  181. details)
  182. fn_details;;
  183. backup)
  184. fn_backup;;
  185. console)
  186. fn_console;;
  187. debug)
  188. fn_debug;;
  189. install)
  190. fn_install;;
  191. map-compressor)
  192. fn_compress_unreal2maps;;
  193. *)
  194. echo "Usage: $0 {start|stop|restart|monitor|email-test|details|backup|console|debug|install|map-compressor}"
  195. exit 1;;
  196. esac
  197. exit
  198. }
  199. if [ "${gamename}" == "Teamspeak 3" ]; then
  200. fn_getopt_teamspeak3
  201. elif [ "${engine}" == "unreal2" ]; then
  202. if [ "${gamename}" == "Unreal Tournament 2004" ]; then
  203. fn_getopt_ut2k4
  204. else
  205. fn_getopt_unreal2
  206. fi
  207. elif [ "${engine}" == "unreal" ]; then
  208. fn_getopt_unreal
  209. elif [ "$gamename" == "Garry's Mod" ]; then
  210. fn_getopt_gmodserver
  211. else
  212. fn_getopt_generic
  213. fi