fn_getopt 3.0 KB

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