core_getopt.sh 14 KB

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