core_getopt.sh 12 KB

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