core_getopt.sh 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. #!/bin/bash
  2. # LGSM core_getopt.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://gameservermanagers.com
  5. lgsm_version="210516"
  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. command_update_functions.sh;;
  22. v|validate)
  23. command_validate.sh;;
  24. m|monitor)
  25. command_monitor.sh;;
  26. ta|test-alert)
  27. command_test_alert.sh;;
  28. dt|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 "https://gameservermanagers.com/${selfname}"
  48. echo -e ""
  49. echo -e "\e[93mCommands\e[0m"
  50. {
  51. echo -e "\e[34mstart\t\e[0mst |Start the server."
  52. echo -e "\e[34mstop\t\e[0msp |Stop the server."
  53. echo -e "\e[34mrestart\t\e[0mr |Restart the server."
  54. echo -e "\e[34mupdate\t\e[0mu |Checks and applies updates from SteamCMD."
  55. echo -e "\e[34mforce-update\t\e[0mfu |Bypasses the check and applies updates from SteamCMD."
  56. echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded."
  57. echo -e "\e[34mvalidate\t\e[0mv |Validate server files with SteamCMD."
  58. echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running."
  59. echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert."
  60. echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server."
  61. echo -e "\e[34mbackup\t\e[0mb |Create archive of the server."
  62. echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server."
  63. echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal."
  64. echo -e "\e[34minstall\t\e[0mi |Install the server."
  65. echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts."
  66. } | column -s $'\t' -t
  67. esac
  68. }
  69. fn_getopt_teamspeak3(){
  70. case "$getopt" in
  71. st|start)
  72. command_start.sh;;
  73. sp|stop)
  74. command_stop.sh;;
  75. r|restart)
  76. fn_restart;;
  77. u|update)
  78. update_check.sh;;
  79. uf|update-functions)
  80. command_update_functions.sh;;
  81. m|monitor)
  82. command_monitor.sh;;
  83. et|test-alert)
  84. command_test_alert.sh;;
  85. dt|details)
  86. command_details.sh;;
  87. b|backup)
  88. command_backup.sh;;
  89. pw|change-password)
  90. command_ts3_server_pass.sh;;
  91. dev|dev-debug)
  92. command_dev_debug.sh;;
  93. i|install)
  94. command_install.sh;;
  95. ai|auto-install)
  96. fn_autoinstall;;
  97. dd|depsdetect)
  98. command_dev_detect_deps.sh;;
  99. *)
  100. echo "Usage: $0 [option]"
  101. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  102. echo "https://gameservermanagers.com/${selfname}"
  103. echo -e ""
  104. echo -e "\e[93mCommands\e[0m"
  105. {
  106. echo -e "\e[34mstart\t\e[0mst |Start the server."
  107. echo -e "\e[34mstop\t\e[0msp |Stop the server."
  108. echo -e "\e[34mrestart\t\e[0mr |Restart the server."
  109. echo -e "\e[34mupdate\t\e[0mu |Checks and applies updates from SteamCMD."
  110. echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded."
  111. echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running."
  112. echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert."
  113. echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server."
  114. echo -e "\e[34mchange-password\t\e[0mpw |Changes TS3 serveradmin password."
  115. echo -e "\e[34mbackup\t\e[0mb |Create archive of the server."
  116. echo -e "\e[34minstall\t\e[0mi |Install the server."
  117. echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts."
  118. } | column -s $'\t' -t
  119. esac
  120. }
  121. fn_getopt_mumble(){
  122. case "$getopt" in
  123. st|start)
  124. command_start.sh;;
  125. sp|stop)
  126. command_stop.sh;;
  127. r|restart)
  128. fn_restart;;
  129. uf|update-functions)
  130. command_update_functions.sh;;
  131. m|monitor)
  132. command_monitor.sh;;
  133. et|test-alert)
  134. command_test_alert.sh;;
  135. b|backup)
  136. command_backup.sh;;
  137. dev|dev-debug)
  138. command_dev_debug.sh;;
  139. console)
  140. command_console.sh;;
  141. d|debug)
  142. command_debug.sh;;
  143. dd|depsdetect)
  144. command_dev_detect_deps.sh;;
  145. *)
  146. echo "Usage: $0 [option]"
  147. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  148. echo "https://gameservermanagers.com/${selfname}"
  149. echo -e ""
  150. echo -e "\e[93mCommands\e[0m"
  151. {
  152. echo -e "\e[34mstart\t\e[0mst |Start the server."
  153. echo -e "\e[34mstop\t\e[0msp |Stop the server."
  154. echo -e "\e[34mrestart\t\e[0mr |Restart the server."
  155. echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded."
  156. echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running."
  157. echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert."
  158. echo -e "\e[34mbackup\t\e[0mb |Create archive of the server."
  159. echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server."
  160. echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal."
  161. } | column -s $'\t' -t
  162. esac
  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. command_update_functions.sh;;
  179. v|validate)
  180. command_validate.sh;;
  181. m|monitor)
  182. command_monitor.sh;;
  183. et|test-alert)
  184. command_test_alert.sh;;
  185. dt|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. fd|fastdl)
  202. command_fastdl.sh;;
  203. *)
  204. echo "Usage: $0 [option]"
  205. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  206. echo "https://gameservermanagers.com/${selfname}"
  207. echo -e ""
  208. echo -e "\e[93mCommands\e[0m"
  209. {
  210. echo -e "\e[34mstart\t\e[0mst |Start the server."
  211. echo -e "\e[34mstop\t\e[0msp |Stop the server."
  212. echo -e "\e[34mrestart\t\e[0mr |Restart the server."
  213. echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD."
  214. echo -e "\e[34mforce-update\t\e[0mfu |Bypasses the check and applies updates from SteamCMD."
  215. echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded."
  216. echo -e "\e[34mvalidate\t\e[0mv |Validate server files with SteamCMD."
  217. echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running."
  218. echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert."
  219. echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server."
  220. echo -e "\e[34mbackup\t\e[0mb |Create archive of the server."
  221. echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server."
  222. echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal."
  223. echo -e "\e[34minstall\t\e[0mi |Install the server."
  224. echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts."
  225. echo -e "\e[34mfastdl\t\e[0mfd |Generates or update a FastDL folder for your server."
  226. } | column -s $'\t' -t
  227. esac
  228. }
  229. fn_getopt_unreal(){
  230. case "$getopt" in
  231. st|start)
  232. command_start.sh;;
  233. sp|stop)
  234. command_stop.sh;;
  235. r|restart)
  236. fn_restart;;
  237. uf|update-functions)
  238. command_update_functions.sh;;
  239. m|monitor)
  240. command_monitor.sh;;
  241. et|test-alert)
  242. command_test_alert.sh;;
  243. dt|details)
  244. command_details.sh;;
  245. b|backup)
  246. command_backup.sh;;
  247. c|console)
  248. command_console.sh;;
  249. d|debug)
  250. command_debug.sh;;
  251. dev|dev-debug)
  252. command_dev_debug.sh;;
  253. i|install)
  254. command_install.sh;;
  255. ai|auto-install)
  256. fn_autoinstall;;
  257. mc|map-compressor)
  258. compress_ut99_maps.sh;;
  259. dd|depsdetect)
  260. command_dev_detect_deps.sh;;
  261. *)
  262. echo "Usage: $0 [option]"
  263. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  264. echo "https://gameservermanagers.com/${selfname}"
  265. echo -e ""
  266. echo -e "\e[93mCommands\e[0m"
  267. {
  268. echo -e "\e[34mstart\t\e[0mst |Start the server."
  269. echo -e "\e[34mstop\t\e[0msp |Stop the server."
  270. echo -e "\e[34mrestart\t\e[0mr |Restart the server."
  271. echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded."
  272. echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running."
  273. echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert."
  274. echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server."
  275. echo -e "\e[34mbackup\t\e[0mb |Create archive of the server."
  276. echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server."
  277. echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal."
  278. echo -e "\e[34minstall\t\e[0mi |Install the server."
  279. echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts."
  280. echo -e "\e[34mmap-compressor\t\e[0mmc |Compresses all ${gamename} server maps."
  281. } | column -s $'\t' -t
  282. esac
  283. }
  284. fn_getopt_unreal2(){
  285. case "$getopt" in
  286. st|start)
  287. command_start.sh;;
  288. sp|stop)
  289. command_stop.sh;;
  290. r|restart)
  291. fn_restart;;
  292. u|update)
  293. update_check.sh;;
  294. fu|force-update|update-restart)
  295. forceupdate=1;
  296. update_check.sh;;
  297. uf|update-functions)
  298. command_update_functions.sh;;
  299. v|validate)
  300. command_validate.sh;;
  301. m|monitor)
  302. command_monitor.sh;;
  303. et|test-alert)
  304. command_test_alert.sh;;
  305. dt|details)
  306. command_details.sh;;
  307. b|backup)
  308. command_backup.sh;;
  309. c|console)
  310. command_console.sh;;
  311. d|debug)
  312. command_debug.sh;;
  313. dev|dev-debug)
  314. command_dev_debug.sh;;
  315. i|install)
  316. command_install.sh;;
  317. ai|auto-install)
  318. fn_autoinstall;;
  319. dd|depsdetect)
  320. command_dev_detect_deps.sh;;
  321. mc|map-compressor)
  322. compress_unreal2_maps.sh;;
  323. *)
  324. echo "Usage: $0 [option]"
  325. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  326. echo "https://gameservermanagers.com/${selfname}"
  327. echo -e ""
  328. echo -e "\e[93mCommands\e[0m"
  329. {
  330. echo -e "\e[34mstart\t\e[0mst |Start the server."
  331. echo -e "\e[34mstop\t\e[0msp |Stop the server."
  332. echo -e "\e[34mrestart\t\e[0mr |Restart the server."
  333. echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD."
  334. echo -e "\e[34mforce-update\t\e[0mfu |Bypasses the check and applies updates from SteamCMD."
  335. echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded."
  336. echo -e "\e[34mvalidate\t\e[0mv |Validate server files with SteamCMD."
  337. echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running."
  338. echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert."
  339. echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server."
  340. echo -e "\e[34mbackup\t\e[0mb |Create archive of the server."
  341. echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server."
  342. echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal."
  343. echo -e "\e[34minstall\t\e[0mi |Install the server."
  344. echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts."
  345. echo -e "\e[34mmap-compressor\t\e[0mmc |Compresses all ${gamename} server maps."
  346. } | column -s $'\t' -t
  347. esac
  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. command_update_functions.sh;;
  359. m|monitor)
  360. command_monitor.sh;;
  361. et|test-alert)
  362. command_test_alert.sh;;
  363. dt|details)
  364. command_details.sh;;
  365. b|backup)
  366. command_backup.sh;;
  367. c|console)
  368. command_console.sh;;
  369. d|debug)
  370. command_debug.sh;;
  371. dev|dev-debug)
  372. command_dev_debug.sh;;
  373. i|install)
  374. command_install.sh;;
  375. ai|auto-install)
  376. fn_autoinstall;;
  377. cd|server-cd-key)
  378. install_ut2k4_key.sh;;
  379. mc|map-compressor)
  380. compress_unreal2_maps.sh;;
  381. dd|depsdetect)
  382. command_dev_detect_deps.sh;;
  383. *)
  384. echo "Usage: $0 [option]"
  385. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  386. echo "https://gameservermanagers.com/${selfname}"
  387. echo -e ""
  388. echo -e "\e[93mCommands\e[0m"
  389. {
  390. echo -e "\e[34mstart\t\e[0mst |Start the server."
  391. echo -e "\e[34mstop\t\e[0msp |Stop the server."
  392. echo -e "\e[34mrestart\t\e[0mr |Restart the server."
  393. echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded."
  394. echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running."
  395. echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert."
  396. echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server."
  397. echo -e "\e[34mbackup\t\e[0mb |Create archive of the server."
  398. echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server."
  399. echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal."
  400. echo -e "\e[34minstall\t\e[0mi |Install the server."
  401. echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts."
  402. echo -e "\e[34mserver-cd-key\t\e[0mcd |Add your server cd key"
  403. echo -e "\e[34mmap-compressor\t\e[0mmc |Compresses all ${gamename} server maps."
  404. } | column -s $'\t' -t
  405. esac
  406. }
  407. if [ "${gamename}" == "Mumble" ]; then
  408. fn_getopt_mumble
  409. elif [ "${gamename}" == "Teamspeak 3" ]; then
  410. fn_getopt_teamspeak3
  411. elif [ "${gamename}" == "Garry's Mod" ]; then
  412. fn_getopt_gmodserver
  413. elif [ "${engine}" == "unreal2" ]; then
  414. if [ "${gamename}" == "Unreal Tournament 2004" ]; then
  415. fn_getopt_ut2k4
  416. else
  417. fn_getopt_unreal2
  418. fi
  419. elif [ "${engine}" == "unreal" ]; then
  420. fn_getopt_unreal
  421. else
  422. fn_getopt_generic
  423. fi
  424. core_exit.sh