fn_getopt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. #!/bin/bash
  2. # LGSM fn_getopt function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. # Version: 011115
  6. # Description: getopt arguments.
  7. fn_getopt_generic(){
  8. case "$getopt" in
  9. st|start)
  10. fn_start;;
  11. sp|stop)
  12. fn_stop;;
  13. r|restart)
  14. fn_restart;;
  15. u|update)
  16. fn_update_check;;
  17. fu|force-update|update-restart)
  18. forceupdate=1;
  19. fn_update_check;;
  20. uf|update-functions)
  21. fn_update_functions;;
  22. v|validate)
  23. fn_validate;;
  24. m|monitor)
  25. fn_monitor;;
  26. et|email-test)
  27. fn_email_test;;
  28. d|details)
  29. fn_details;;
  30. b|backup)
  31. fn_backup;;
  32. c|console)
  33. fn_console;;
  34. d|debug)
  35. fn_debug;;
  36. i|install)
  37. fn_install;;
  38. ai|auto-install)
  39. fn_autoinstall;;
  40. dd|depsdetect)
  41. fn_deps_detect;;
  42. *)
  43. echo "Usage: $0 [option]"
  44. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  45. echo "http://gameservermanagers.com/${selfname}"
  46. echo -e ""
  47. echo -e "\e[93mCommands\e[0m"
  48. {
  49. echo -e "\e[34mstart\t\e[0mStart the server."
  50. echo -e "\e[34mstop\t\e[0mStop the server."
  51. echo -e "\e[34mrestart\t\e[0mRestart the server."
  52. echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD."
  53. echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD."
  54. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  55. echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD."
  56. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  57. echo -e "\e[34memail-test\t\e[0mSends test monitor email."
  58. echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
  59. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  60. echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
  61. echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
  62. echo -e "\e[34minstall\t\e[0mInstall the server."
  63. echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
  64. } | column -s $'\t' -t
  65. esac
  66. exit
  67. }
  68. fn_getopt_teamspeak3(){
  69. case "$getopt" in
  70. st|start)
  71. fn_start;;
  72. sp|stop)
  73. fn_stop;;
  74. r|restart)
  75. fn_restart;;
  76. u|update)
  77. fn_update_check;;
  78. uf|update-functions)
  79. fn_update_functions;;
  80. m|monitor)
  81. fn_monitor;;
  82. et|email-test)
  83. fn_email_test;;
  84. d|details)
  85. fn_details;;
  86. b|backup)
  87. fn_backup;;
  88. i|install)
  89. fn_install;;
  90. ai|auto-install)
  91. fn_autoinstall;;
  92. dd|depsdetect)
  93. fn_deps_detect;;
  94. *)
  95. echo "Usage: $0 [option]"
  96. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  97. echo "http://gameservermanagers.com/${selfname}"
  98. echo -e ""
  99. echo -e "\e[93mCommands\e[0m"
  100. {
  101. echo -e "\e[34mstart\t\e[0mStart the server."
  102. echo -e "\e[34mstop\t\e[0mStop the server."
  103. echo -e "\e[34mrestart\t\e[0mRestart the server."
  104. echo -e "\e[34mupdate\t\e[0mChecks and applies updates from teamspeak.com."
  105. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  106. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  107. echo -e "\e[34memail-test\t\e[0mSends test monitor email."
  108. echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
  109. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  110. echo -e "\e[34minstall\t\e[0mInstall the server."
  111. echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
  112. } | column -s $'\t' -t
  113. esac
  114. exit
  115. }
  116. fn_getopt_mumble(){
  117. case "$getopt" in
  118. st|start)
  119. fn_start;;
  120. sp|stop)
  121. fn_stop;;
  122. r|restart)
  123. fn_restart;;
  124. uf|update-functions)
  125. fn_update_functions;;
  126. m|monitor)
  127. fn_monitor;;
  128. et|email-test)
  129. fn_email_test;;
  130. b|backup)
  131. fn_backup;;
  132. console)
  133. fn_console;;
  134. d|debug)
  135. fn_debug;;
  136. dd|depsdetect)
  137. fn_deps_detect;;
  138. *)
  139. echo "Usage: $0 [option]"
  140. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  141. echo "http://gameservermanagers.com/${selfname}"
  142. echo -e ""
  143. echo -e "\e[93mCommands\e[0m"
  144. {
  145. echo -e "\e[34mstart\t\e[0mStart the server."
  146. echo -e "\e[34mstop\t\e[0mStop the server."
  147. echo -e "\e[34mrestart\t\e[0mRestart the server."
  148. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  149. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  150. echo -e "\e[34memail-test\t\e[0mSends test monitor email."
  151. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  152. echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
  153. echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
  154. } | column -s $'\t' -t
  155. esac
  156. exit
  157. }
  158. fn_getopt_gmodserver(){
  159. case "$getopt" in
  160. st|start)
  161. fn_start;;
  162. sp|stop)
  163. fn_stop;;
  164. r|restart)
  165. fn_restart;;
  166. u|update)
  167. fn_update_check;;
  168. fu|force-update|update-restart)
  169. forceupdate=1;
  170. fn_update_check;;
  171. uf|update-functions)
  172. fn_update_functions;;
  173. v|validate)
  174. fn_validate;;
  175. m|monitor)
  176. fn_monitor;;
  177. et|email-test)
  178. fn_email_test;;
  179. d|details)
  180. fn_details;;
  181. b|backup)
  182. fn_backup;;
  183. c|console)
  184. fn_console;;
  185. d|debug)
  186. fn_debug;;
  187. i|install)
  188. fn_install;;
  189. ai|auto-install)
  190. fn_autoinstall;;
  191. dd|depsdetect)
  192. fn_deps_detect;;
  193. gc|gmod-content)
  194. fn_content_gmod;;
  195. *)
  196. echo "Usage: $0 [option]"
  197. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  198. echo "http://gameservermanagers.com/${selfname}"
  199. echo -e ""
  200. echo -e "\e[93mCommands\e[0m"
  201. {
  202. echo -e "\e[34mstart\t\e[0mStart the server."
  203. echo -e "\e[34mstop\t\e[0mStop the server."
  204. echo -e "\e[34mrestart\t\e[0mRestart the server."
  205. echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD."
  206. echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD."
  207. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  208. echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD."
  209. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  210. echo -e "\e[34memail-test\t\e[0mSends test monitor email."
  211. echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
  212. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  213. echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
  214. echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
  215. echo -e "\e[34minstall\t\e[0mInstall the server."
  216. echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
  217. echo -e "\e[34mgmod-content\t\e[0mDownload gmod add-on content."
  218. } | column -s $'\t' -t
  219. esac
  220. exit
  221. }
  222. fn_getopt_unreal(){
  223. case "$getopt" in
  224. st|start)
  225. fn_start;;
  226. sp|stop)
  227. fn_stop;;
  228. r|restart)
  229. fn_restart;;
  230. uf|update-functions)
  231. fn_update_functions;;
  232. m|monitor)
  233. fn_monitor;;
  234. et|email-test)
  235. fn_email_test;;
  236. d|details)
  237. fn_details;;
  238. b|backup)
  239. fn_backup;;
  240. c|console)
  241. fn_console;;
  242. d|debug)
  243. fn_debug;;
  244. i|install)
  245. fn_install;;
  246. mc|map-compressor)
  247. fn_compress_ut99maps;;
  248. dd|depsdetect)
  249. fn_deps_detect;;
  250. *)
  251. echo "Usage: $0 [option]"
  252. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  253. echo "http://gameservermanagers.com/${selfname}"
  254. echo -e ""
  255. echo -e "\e[93mCommands\e[0m"
  256. {
  257. echo -e "\e[34mstart\t\e[0mStart the server."
  258. echo -e "\e[34mstop\t\e[0mStop the server."
  259. echo -e "\e[34mrestart\t\e[0mRestart the server."
  260. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  261. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  262. echo -e "\e[34memail-test\t\e[0mSends test monitor email."
  263. echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
  264. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  265. echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
  266. echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
  267. echo -e "\e[34minstall\t\e[0mInstall the server."
  268. echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps."
  269. } | column -s $'\t' -t
  270. esac
  271. exit
  272. }
  273. fn_getopt_unreal2(){
  274. case "$getopt" in
  275. st|start)
  276. fn_start;;
  277. sp|stop)
  278. fn_stop;;
  279. r|restart)
  280. fn_restart;;
  281. u|update)
  282. fn_update_check;;
  283. fu|force-update|update-restart)
  284. forceupdate=1;
  285. fn_update_check;;
  286. uf|update-functions)
  287. fn_update_functions;;
  288. v|validate)
  289. fn_validate;;
  290. m|monitor)
  291. fn_monitor;;
  292. et|email-test)
  293. fn_email_test;;
  294. d|details)
  295. fn_details;;
  296. b|backup)
  297. fn_backup;;
  298. c|console)
  299. fn_console;;
  300. d|debug)
  301. fn_debug;;
  302. i|install)
  303. fn_install;;
  304. ai|auto-install)
  305. fn_autoinstall;;
  306. dd|depsdetect)
  307. fn_deps_detect;;
  308. mc|map-compressor)
  309. fn_compress_unreal2maps;;
  310. *)
  311. echo "Usage: $0 [option]"
  312. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  313. echo "http://gameservermanagers.com/${selfname}"
  314. echo -e ""
  315. echo -e "\e[93mCommands\e[0m"
  316. {
  317. echo -e "\e[34mstart\t\e[0mStart the server."
  318. echo -e "\e[34mstop\t\e[0mStop the server."
  319. echo -e "\e[34mrestart\t\e[0mRestart the server."
  320. echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD."
  321. echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD."
  322. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  323. echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD."
  324. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  325. echo -e "\e[34memail-test\t\e[0mSends test monitor email."
  326. echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
  327. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  328. echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
  329. echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
  330. echo -e "\e[34minstall\t\e[0mInstall the server."
  331. echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
  332. echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps."
  333. } | column -s $'\t' -t
  334. esac
  335. exit
  336. }
  337. fn_getopt_ut2k4(){
  338. case "$getopt" in
  339. st|start)
  340. fn_start;;
  341. sp|stop)
  342. fn_stop;;
  343. r|restart)
  344. fn_restart;;
  345. uf|update-functions)
  346. fn_update_functions;;
  347. m|monitor)
  348. fn_monitor;;
  349. et|email-test)
  350. fn_email_test;;
  351. d|details)
  352. fn_details;;
  353. b|backup)
  354. fn_backup;;
  355. c|console)
  356. fn_console;;
  357. d|debug)
  358. fn_debug;;
  359. i|install)
  360. fn_install;;
  361. mc|map-compressor)
  362. fn_compress_ut99maps;;
  363. dd|depsdetect)
  364. fn_deps_detect;;
  365. *)
  366. echo "Usage: $0 [option]"
  367. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  368. echo "http://gameservermanagers.com/${selfname}"
  369. echo -e ""
  370. echo -e "\e[93mCommands\e[0m"
  371. {
  372. echo -e "\e[34mstart\t\e[0mStart the server."
  373. echo -e "\e[34mstop\t\e[0mStop the server."
  374. echo -e "\e[34mrestart\t\e[0mRestart the server."
  375. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  376. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  377. echo -e "\e[34memail-test\t\e[0mSends test monitor email."
  378. echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
  379. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  380. echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
  381. echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
  382. echo -e "\e[34minstall\t\e[0mInstall the server."
  383. echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps."
  384. } | column -s $'\t' -t
  385. esac
  386. exit
  387. }
  388. if [ "${gamename}" == "Mumble" ]; then
  389. fn_getopt_mumble
  390. elif [ "${gamename}" == "Teamspeak 3" ]; then
  391. fn_getopt_teamspeak3
  392. elif [ "${engine}" == "unreal2" ]; then
  393. if [ "${gamename}" == "Unreal Tournament 2004" ]; then
  394. fn_getopt_ut2k4
  395. else
  396. fn_getopt_unreal2
  397. fi
  398. elif [ "${engine}" == "unreal" ]; then
  399. fn_getopt_unreal
  400. else
  401. fn_getopt_generic
  402. fi