fn_getopt 3.0 KB

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