core_getopt.sh 13 KB

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