fn_getopt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. #!/bin/bash
  2. # LGSM fn_getopt function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. lgsm_version="061115"
  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. co|content)
  194. fn_content_gmod;;
  195. ica|install-content-all)
  196. gmod-content-mode=0
  197. fn_content_gmod;;
  198. iccss|install-content-css)
  199. gmod-content-mode=1
  200. fn_content_gmod;;
  201. ictf2|install-content-tf2)
  202. gmod-content-mode=2
  203. fn_content_gmod;;
  204. icp2|install-content-p2)
  205. gmod-content-mode=3
  206. fn_content_gmod;;
  207. rca|remove-content-all)
  208. gmod-content-mode=4
  209. fn_content_gmod;;
  210. rccss|remove-content-css)
  211. gmod-content-mode=5
  212. fn_content_gmod;;
  213. rctf2|remove-content-tf2)
  214. gmod-content-mode=6
  215. fn_content_gmod;;
  216. rcp2|remove-content-p2)
  217. gmod-content-mode=7
  218. fn_content_gmod;;
  219. uc|update-content)
  220. gmod-content-mode=7
  221. fn_content_gmod;;
  222. vc|validate-content)
  223. gmod-content-mode=8
  224. fn_content_gmod;;
  225. *)
  226. } | column -s $'\t' -t
  227. esac
  228. exit
  229. echo "Usage: $0 [option]"
  230. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  231. echo "http://gameservermanagers.com/${selfname}"
  232. echo -e ""
  233. echo -e "\e[93mCommands\e[0m"
  234. {
  235. echo -e "\e[34mstart\t\e[0mStart the server."
  236. echo -e "\e[34mstop\t\e[0mStop the server."
  237. echo -e "\e[34mrestart\t\e[0mRestart the server."
  238. echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD."
  239. echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD."
  240. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  241. echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD."
  242. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  243. echo -e "\e[34memail-test\t\e[0mSends test monitor email."
  244. echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
  245. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  246. echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
  247. echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
  248. echo -e "\e[34minstall\t\e[0mInstall the server."
  249. echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
  250. echo -e "\e[34mgmod-content\t\e[0mDownload gmod add-on content."
  251. echo -e "\e[34mcontent\t\e[0mList options for content mounting on ${gamename} server."
  252. } | column -s $'\t' -t
  253. esac
  254. exit
  255. }
  256. fn_getopt_unreal(){
  257. case "$getopt" in
  258. st|start)
  259. fn_start;;
  260. sp|stop)
  261. fn_stop;;
  262. r|restart)
  263. fn_restart;;
  264. uf|update-functions)
  265. fn_update_functions;;
  266. m|monitor)
  267. fn_monitor;;
  268. et|email-test)
  269. fn_email_test;;
  270. d|details)
  271. fn_details;;
  272. b|backup)
  273. fn_backup;;
  274. c|console)
  275. fn_console;;
  276. d|debug)
  277. fn_debug;;
  278. i|install)
  279. fn_install;;
  280. mc|map-compressor)
  281. fn_compress_ut99maps;;
  282. dd|depsdetect)
  283. fn_deps_detect;;
  284. *)
  285. echo "Usage: $0 [option]"
  286. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  287. echo "http://gameservermanagers.com/${selfname}"
  288. echo -e ""
  289. echo -e "\e[93mCommands\e[0m"
  290. {
  291. echo -e "\e[34mstart\t\e[0mStart the server."
  292. echo -e "\e[34mstop\t\e[0mStop the server."
  293. echo -e "\e[34mrestart\t\e[0mRestart the server."
  294. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  295. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  296. echo -e "\e[34memail-test\t\e[0mSends test monitor email."
  297. echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
  298. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  299. echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
  300. echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
  301. echo -e "\e[34minstall\t\e[0mInstall the server."
  302. echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps."
  303. } | column -s $'\t' -t
  304. esac
  305. exit
  306. }
  307. fn_getopt_unreal2(){
  308. case "$getopt" in
  309. st|start)
  310. fn_start;;
  311. sp|stop)
  312. fn_stop;;
  313. r|restart)
  314. fn_restart;;
  315. u|update)
  316. fn_update_check;;
  317. fu|force-update|update-restart)
  318. forceupdate=1;
  319. fn_update_check;;
  320. uf|update-functions)
  321. fn_update_functions;;
  322. v|validate)
  323. fn_validate;;
  324. m|monitor)
  325. fn_monitor;;
  326. et|email-test)
  327. fn_email_test;;
  328. d|details)
  329. fn_details;;
  330. b|backup)
  331. fn_backup;;
  332. c|console)
  333. fn_console;;
  334. d|debug)
  335. fn_debug;;
  336. i|install)
  337. fn_install;;
  338. ai|auto-install)
  339. fn_autoinstall;;
  340. dd|depsdetect)
  341. fn_deps_detect;;
  342. mc|map-compressor)
  343. fn_compress_unreal2maps;;
  344. *)
  345. echo "Usage: $0 [option]"
  346. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  347. echo "http://gameservermanagers.com/${selfname}"
  348. echo -e ""
  349. echo -e "\e[93mCommands\e[0m"
  350. {
  351. echo -e "\e[34mstart\t\e[0mStart the server."
  352. echo -e "\e[34mstop\t\e[0mStop the server."
  353. echo -e "\e[34mrestart\t\e[0mRestart the server."
  354. echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD."
  355. echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD."
  356. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  357. echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD."
  358. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  359. echo -e "\e[34memail-test\t\e[0mSends test monitor email."
  360. echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
  361. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  362. echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
  363. echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
  364. echo -e "\e[34minstall\t\e[0mInstall the server."
  365. echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
  366. echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps."
  367. } | column -s $'\t' -t
  368. esac
  369. exit
  370. }
  371. fn_getopt_ut2k4(){
  372. case "$getopt" in
  373. st|start)
  374. fn_start;;
  375. sp|stop)
  376. fn_stop;;
  377. r|restart)
  378. fn_restart;;
  379. uf|update-functions)
  380. fn_update_functions;;
  381. m|monitor)
  382. fn_monitor;;
  383. et|email-test)
  384. fn_email_test;;
  385. d|details)
  386. fn_details;;
  387. b|backup)
  388. fn_backup;;
  389. c|console)
  390. fn_console;;
  391. d|debug)
  392. fn_debug;;
  393. i|install)
  394. fn_install;;
  395. mc|map-compressor)
  396. fn_compress_ut99maps;;
  397. dd|depsdetect)
  398. fn_deps_detect;;
  399. *)
  400. echo "Usage: $0 [option]"
  401. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  402. echo "http://gameservermanagers.com/${selfname}"
  403. echo -e ""
  404. echo -e "\e[93mCommands\e[0m"
  405. {
  406. echo -e "\e[34mstart\t\e[0mStart the server."
  407. echo -e "\e[34mstop\t\e[0mStop the server."
  408. echo -e "\e[34mrestart\t\e[0mRestart the server."
  409. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  410. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  411. echo -e "\e[34memail-test\t\e[0mSends test monitor email."
  412. echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
  413. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  414. echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
  415. echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
  416. echo -e "\e[34minstall\t\e[0mInstall the server."
  417. echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps."
  418. } | column -s $'\t' -t
  419. esac
  420. exit
  421. }
  422. if [ "${gamename}" == "Mumble" ]; then
  423. fn_getopt_mumble
  424. elif [ "${gamename}" == "Teamspeak 3" ]; then
  425. fn_getopt_teamspeak3
  426. elif [ "${engine}" == "unreal2" ]; then
  427. if [ "${gamename}" == "Unreal Tournament 2004" ]; then
  428. fn_getopt_ut2k4
  429. else
  430. fn_getopt_unreal2
  431. fi
  432. elif [ "${engine}" == "unreal" ]; then
  433. fn_getopt_unreal
  434. elif [ "$gamename" == "Garry's Mod" ]; then
  435. fn_getopt_gmodserver
  436. else
  437. fn_getopt_generic
  438. fi