core_getopt.sh 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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. 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. email_test.sh;;
  28. d|details)
  29. command_details.sh;;
  30. b|backup)
  31. fn_backup;;
  32. c|console)
  33. command_console.sh;;
  34. d|debug)
  35. command_debug.sh;;
  36. dev|dev-debug)
  37. dev_debug.sh;;
  38. i|install)
  39. command_install.sh;;
  40. ai|auto-install)
  41. fn_autoinstall;;
  42. dd|depsdetect)
  43. 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. email_test.sh;;
  86. d|details)
  87. command_details.sh;;
  88. b|backup)
  89. fn_backup;;
  90. dev|dev-debug)
  91. dev_debug.sh;;
  92. i|install)
  93. command_install.sh;;
  94. ai|auto-install)
  95. fn_autoinstall;;
  96. dd|depsdetect)
  97. 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. email_test.sh;;
  134. b|backup)
  135. fn_backup;;
  136. dev|dev-debug)
  137. dev_debug.sh;;
  138. console)
  139. command_console.sh;;
  140. d|debug)
  141. command_debug.sh;;
  142. dd|depsdetect)
  143. 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. email_test.sh;;
  185. d|details)
  186. command_details.sh;;
  187. b|backup)
  188. fn_backup;;
  189. c|console)
  190. command_console.sh;;
  191. d|debug)
  192. command_debug.sh;;
  193. dev|dev-debug)
  194. dev_debug.sh;;
  195. i|install)
  196. command_install.sh;;
  197. ai|auto-install)
  198. fn_autoinstall;;
  199. dd|depsdetect)
  200. dev_detect_deps.sh;;
  201. gc|gmod-content)
  202. fn_content_gmod;;
  203. *)
  204. echo "Usage: $0 [option]"
  205. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  206. echo "http://gameservermanagers.com/${selfname}"
  207. echo -e ""
  208. echo -e "\e[93mCommands\e[0m"
  209. {
  210. echo -e "\e[34mstart\t\e[0mStart the server."
  211. echo -e "\e[34mstop\t\e[0mStop the server."
  212. echo -e "\e[34mrestart\t\e[0mRestart the server."
  213. echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD."
  214. echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD."
  215. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  216. echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD."
  217. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  218. echo -e "\e[34memail-test\t\e[0mSends test monitor email."
  219. echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
  220. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  221. echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
  222. echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
  223. echo -e "\e[34minstall\t\e[0mInstall the server."
  224. echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
  225. echo -e "\e[34mgmod-content\t\e[0mDownload gmod add-on content."
  226. } | column -s $'\t' -t
  227. esac
  228. exit
  229. }
  230. fn_getopt_unreal(){
  231. case "$getopt" in
  232. st|start)
  233. command_start.sh;;
  234. sp|stop)
  235. command_stop.sh;;
  236. r|restart)
  237. fn_restart;;
  238. uf|update-functions)
  239. update_functions.sh;;
  240. m|monitor)
  241. command_monitor.sh;;
  242. et|email-test)
  243. email_test.sh;;
  244. d|details)
  245. command_details.sh;;
  246. b|backup)
  247. fn_backup;;
  248. c|console)
  249. command_console.sh;;
  250. d|debug)
  251. command_debug.sh;;
  252. dev|dev-debug)
  253. dev_debug.sh;;
  254. i|install)
  255. command_install.sh;;
  256. mc|map-compressor)
  257. compress_ut99_maps.sh;;
  258. dd|depsdetect)
  259. dev_detect_deps.sh;;
  260. *)
  261. echo "Usage: $0 [option]"
  262. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  263. echo "http://gameservermanagers.com/${selfname}"
  264. echo -e ""
  265. echo -e "\e[93mCommands\e[0m"
  266. {
  267. echo -e "\e[34mstart\t\e[0mStart the server."
  268. echo -e "\e[34mstop\t\e[0mStop the server."
  269. echo -e "\e[34mrestart\t\e[0mRestart the server."
  270. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  271. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  272. echo -e "\e[34memail-test\t\e[0mSends test monitor email."
  273. echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
  274. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  275. echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
  276. echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
  277. echo -e "\e[34minstall\t\e[0mInstall the server."
  278. echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps."
  279. } | column -s $'\t' -t
  280. esac
  281. exit
  282. }
  283. fn_getopt_unreal2(){
  284. case "$getopt" in
  285. st|start)
  286. command_start.sh;;
  287. sp|stop)
  288. command_stop.sh;;
  289. r|restart)
  290. fn_restart;;
  291. u|update)
  292. update_check.sh;;
  293. fu|force-update|update-restart)
  294. forceupdate=1;
  295. update_check.sh;;
  296. uf|update-functions)
  297. update_functions.sh;;
  298. v|validate)
  299. command_validate.sh;;
  300. m|monitor)
  301. command_monitor.sh;;
  302. et|email-test)
  303. email_test.sh;;
  304. d|details)
  305. command_details.sh;;
  306. b|backup)
  307. fn_backup;;
  308. c|console)
  309. command_console.sh;;
  310. d|debug)
  311. command_debug.sh;;
  312. dev|dev-debug)
  313. dev_debug.sh;;
  314. i|install)
  315. command_install.sh;;
  316. ai|auto-install)
  317. fn_autoinstall;;
  318. dd|depsdetect)
  319. dev_detect_deps.sh;;
  320. mc|map-compressor)
  321. compress_unreal2_maps.sh;;
  322. *)
  323. echo "Usage: $0 [option]"
  324. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  325. echo "http://gameservermanagers.com/${selfname}"
  326. echo -e ""
  327. echo -e "\e[93mCommands\e[0m"
  328. {
  329. echo -e "\e[34mstart\t\e[0mStart the server."
  330. echo -e "\e[34mstop\t\e[0mStop the server."
  331. echo -e "\e[34mrestart\t\e[0mRestart the server."
  332. echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD."
  333. echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD."
  334. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  335. echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD."
  336. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  337. echo -e "\e[34memail-test\t\e[0mSends test monitor email."
  338. echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
  339. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  340. echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
  341. echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
  342. echo -e "\e[34minstall\t\e[0mInstall the server."
  343. echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
  344. echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps."
  345. } | column -s $'\t' -t
  346. esac
  347. exit
  348. }
  349. fn_getopt_ut2k4(){
  350. case "$getopt" in
  351. st|start)
  352. command_start.sh;;
  353. sp|stop)
  354. command_stop.sh;;
  355. r|restart)
  356. fn_restart;;
  357. uf|update-functions)
  358. update_functions.sh;;
  359. m|monitor)
  360. command_monitor.sh;;
  361. et|email-test)
  362. email_test.sh;;
  363. d|details)
  364. command_details.sh;;
  365. b|backup)
  366. fn_backup;;
  367. c|console)
  368. command_console.sh;;
  369. d|debug)
  370. command_debug.sh;;
  371. dev|dev-debug)
  372. dev_debug.sh;;
  373. i|install)
  374. command_install.sh;;
  375. mc|map-compressor)
  376. compress_ut99_maps.sh;;
  377. dd|depsdetect)
  378. dev_detect_deps.sh;;
  379. *)
  380. echo "Usage: $0 [option]"
  381. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  382. echo "http://gameservermanagers.com/${selfname}"
  383. echo -e ""
  384. echo -e "\e[93mCommands\e[0m"
  385. {
  386. echo -e "\e[34mstart\t\e[0mStart the server."
  387. echo -e "\e[34mstop\t\e[0mStop the server."
  388. echo -e "\e[34mrestart\t\e[0mRestart the server."
  389. echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded."
  390. echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
  391. echo -e "\e[34memail-test\t\e[0mSends test monitor email."
  392. echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
  393. echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
  394. echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server."
  395. echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
  396. echo -e "\e[34minstall\t\e[0mInstall the server."
  397. echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps."
  398. } | column -s $'\t' -t
  399. esac
  400. exit
  401. }
  402. if [ "${gamename}" == "Mumble" ]; then
  403. fn_getopt_mumble
  404. elif [ "${gamename}" == "Teamspeak 3" ]; then
  405. fn_getopt_teamspeak3
  406. elif [ "${engine}" == "unreal2" ]; then
  407. if [ "${gamename}" == "Unreal Tournament 2004" ]; then
  408. fn_getopt_ut2k4
  409. else
  410. fn_getopt_unreal2
  411. fi
  412. elif [ "${engine}" == "unreal" ]; then
  413. fn_getopt_unreal
  414. else
  415. fn_getopt_generic
  416. fi