core_getopt.sh 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. #!/bin/bash
  2. # LGSM core_getopt.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://gameservermanagers.com
  5. # Description: getopt arguments.
  6. local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  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. command_restart.sh;;
  15. u|update)
  16. command_update.sh;;
  17. fu|force-update|update-restart)
  18. forceupdate=1;
  19. command_update.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|deps-detect)
  43. command_dev_detect_deps.sh;;
  44. dg|detect-glibc)
  45. command_dev_detect_glibc.sh;;
  46. *)
  47. if [ -n "${getopt}" ]; then
  48. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  49. exitcode=2
  50. fi
  51. echo "Usage: $0 [option]"
  52. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  53. echo "https://gameservermanagers.com/${selfname}"
  54. echo -e ""
  55. echo -e "${lightyellow}Commands${default}"
  56. {
  57. echo -e "${blue}start\t${default}st |Start the server."
  58. echo -e "${blue}stop\t${default}sp |Stop the server."
  59. echo -e "${blue}restart\t${default}r |Restart the server."
  60. echo -e "${blue}update\t${default}u |Checks and applies updates from SteamCMD."
  61. echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD."
  62. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  63. echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD."
  64. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  65. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  66. echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
  67. echo -e "${blue}backup\t${default}b |Create archive of the server."
  68. echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
  69. echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
  70. echo -e "${blue}install\t${default}i |Install the server."
  71. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  72. } | column -s $'\t' -t
  73. esac
  74. }
  75. fn_getopt_teamspeak3(){
  76. case "${getopt}" in
  77. st|start)
  78. command_start.sh;;
  79. sp|stop)
  80. command_stop.sh;;
  81. r|restart)
  82. command_restart.sh;;
  83. u|update)
  84. command_update.sh;;
  85. uf|update-functions)
  86. command_update_functions.sh;;
  87. m|monitor)
  88. command_monitor.sh;;
  89. ta|test-alert)
  90. command_test_alert.sh;;
  91. dt|details)
  92. command_details.sh;;
  93. b|backup)
  94. command_backup.sh;;
  95. pw|change-password)
  96. command_ts3_server_pass.sh;;
  97. dev|dev-debug)
  98. command_dev_debug.sh;;
  99. i|install)
  100. command_install.sh;;
  101. ai|auto-install)
  102. fn_autoinstall;;
  103. dd|deps-detect)
  104. command_dev_detect_deps.sh;;
  105. dg|detect-glibc)
  106. command_dev_detect_glibc.sh;;
  107. *)
  108. if [ -n "${getopt}" ]; then
  109. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  110. exitcode=2
  111. fi
  112. echo "Usage: $0 [option]"
  113. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  114. echo "https://gameservermanagers.com/${selfname}"
  115. echo -e ""
  116. echo -e "${lightyellow}Commands${default}"
  117. {
  118. echo -e "${blue}start\t${default}st |Start the server."
  119. echo -e "${blue}stop\t${default}sp |Stop the server."
  120. echo -e "${blue}restart\t${default}r |Restart the server."
  121. echo -e "${blue}update\t${default}u |Checks and applies updates from SteamCMD."
  122. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  123. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  124. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  125. echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
  126. echo -e "${blue}change-password\t${default}pw |Changes TS3 serveradmin password."
  127. echo -e "${blue}backup\t${default}b |Create archive of the server."
  128. echo -e "${blue}install\t${default}i |Install the server."
  129. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  130. } | column -s $'\t' -t
  131. esac
  132. }
  133. fn_getopt_minecraft(){
  134. case "${getopt}" in
  135. st|start)
  136. command_start.sh;;
  137. sp|stop)
  138. command_stop.sh;;
  139. r|restart)
  140. command_restart.sh;;
  141. u|update)
  142. command_update.sh;;
  143. uf|update-functions)
  144. command_update_functions.sh;;
  145. m|monitor)
  146. command_monitor.sh;;
  147. ta|test-alert)
  148. command_test_alert.sh;;
  149. dt|details)
  150. command_details.sh;;
  151. b|backup)
  152. command_backup.sh;;
  153. pw|change-password)
  154. command_ts3_server_pass.sh;;
  155. dev|dev-debug)
  156. command_dev_debug.sh;;
  157. i|install)
  158. command_install.sh;;
  159. ai|auto-install)
  160. fn_autoinstall;;
  161. dd|deps-detect)
  162. command_dev_detect_deps.sh;;
  163. dg|detect-glibc)
  164. command_dev_detect_glibc.sh;;
  165. *)
  166. if [ -n "${getopt}" ]; then
  167. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  168. exitcode=2
  169. fi
  170. echo "Usage: $0 [option]"
  171. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  172. echo "https://gameservermanagers.com/${selfname}"
  173. echo -e ""
  174. echo -e "${lightyellow}Commands${default}"
  175. {
  176. echo -e "${blue}start\t${default}st |Start the server."
  177. echo -e "${blue}stop\t${default}sp |Stop the server."
  178. echo -e "${blue}restart\t${default}r |Restart the server."
  179. echo -e "${blue}update\t${default}u |Checks and applies updates from SteamCMD."
  180. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  181. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  182. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  183. echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
  184. echo -e "${blue}change-password\t${default}pw |Changes TS3 serveradmin password."
  185. echo -e "${blue}backup\t${default}b |Create archive of the server."
  186. echo -e "${blue}install\t${default}i |Install the server."
  187. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  188. } | column -s $'\t' -t
  189. esac
  190. }
  191. fn_getopt_mumble(){
  192. case "${getopt}" in
  193. st|start)
  194. command_start.sh;;
  195. sp|stop)
  196. command_stop.sh;;
  197. r|restart)
  198. command_restart.sh;;
  199. u|update)
  200. command_update.sh;;
  201. uf|update-functions)
  202. command_update_functions.sh;;
  203. m|monitor)
  204. command_monitor.sh;;
  205. ta|test-alert)
  206. command_test_alert.sh;;
  207. dt|details)
  208. command_details.sh;;
  209. b|backup)
  210. command_backup.sh;;
  211. dev|dev-debug)
  212. command_dev_debug.sh;;
  213. i|install)
  214. command_install.sh;;
  215. dd|deps-detect)
  216. command_dev_detect_deps.sh;;
  217. dg|detect-glibc)
  218. command_dev_detect_glibc.sh;;
  219. *)
  220. if [ -n "${getopt}" ]; then
  221. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  222. exitcode=2
  223. fi
  224. echo "Usage: $0 [option]"
  225. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  226. echo "https://gameservermanagers.com/${selfname}"
  227. echo -e ""
  228. echo -e "${lightyellow}Commands${default}"
  229. {
  230. echo -e "${blue}start\t${default}st |Start the server."
  231. echo -e "${blue}stop\t${default}sp |Stop the server."
  232. echo -e "${blue}restart\t${default}r |Restart the server."
  233. echo -e "${blue}update\t${default}u |Checks and applies updates from SteamCMD."
  234. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  235. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  236. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  237. echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
  238. echo -e "${blue}backup\t${default}b |Create archive of the server."
  239. echo -e "${blue}install\t${default}i |Install the server."
  240. } | column -s $'\t' -t
  241. esac
  242. }
  243. fn_getopt_gmodserver(){
  244. case "${getopt}" in
  245. st|start)
  246. command_start.sh;;
  247. sp|stop)
  248. command_stop.sh;;
  249. r|restart)
  250. command_restart.sh;;
  251. u|update)
  252. command_update.sh;;
  253. fu|force-update|update-restart)
  254. forceupdate=1;
  255. update_check.sh;;
  256. uf|update-functions)
  257. command_update_functions.sh;;
  258. v|validate)
  259. command_validate.sh;;
  260. m|monitor)
  261. command_monitor.sh;;
  262. ta|test-alert)
  263. command_test_alert.sh;;
  264. dt|details)
  265. command_details.sh;;
  266. b|backup)
  267. command_backup.sh;;
  268. c|console)
  269. command_console.sh;;
  270. d|debug)
  271. command_debug.sh;;
  272. dev|dev-debug)
  273. command_dev_debug.sh;;
  274. i|install)
  275. command_install.sh;;
  276. ai|auto-install)
  277. fn_autoinstall;;
  278. dd|deps-detect)
  279. command_dev_detect_deps.sh;;
  280. dg|detect-glibc)
  281. command_dev_detect_glibc.sh;;
  282. fd|fastdl)
  283. command_fastdl.sh;;
  284. *)
  285. if [ -n "${getopt}" ]; then
  286. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  287. exitcode=2
  288. fi
  289. echo "Usage: $0 [option]"
  290. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  291. echo "https://gameservermanagers.com/${selfname}"
  292. echo -e ""
  293. echo -e "${lightyellow}Commands${default}"
  294. {
  295. echo -e "${blue}start\t${default}st |Start the server."
  296. echo -e "${blue}stop\t${default}sp |Stop the server."
  297. echo -e "${blue}restart\t${default}r |Restart the server."
  298. echo -e "${blue}update\t${default}u |Checks and applies updates from SteamCMD."
  299. echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD."
  300. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  301. echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD."
  302. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  303. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  304. echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
  305. echo -e "${blue}backup\t${default}b |Create archive of the server."
  306. echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
  307. echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
  308. echo -e "${blue}install\t${default}i |Install the server."
  309. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  310. echo -e "${blue}fastdl\t${default}fd |Generates or update a FastDL folder for your server."
  311. } | column -s $'\t' -t
  312. esac
  313. }
  314. fn_getopt_unreal(){
  315. case "${getopt}" in
  316. st|start)
  317. command_start.sh;;
  318. sp|stop)
  319. command_stop.sh;;
  320. r|restart)
  321. command_restart.sh;;
  322. uf|update-functions)
  323. command_update_functions.sh;;
  324. m|monitor)
  325. command_monitor.sh;;
  326. ta|test-alert)
  327. command_test_alert.sh;;
  328. dt|details)
  329. command_details.sh;;
  330. b|backup)
  331. command_backup.sh;;
  332. c|console)
  333. command_console.sh;;
  334. d|debug)
  335. command_debug.sh;;
  336. dev|dev-debug)
  337. command_dev_debug.sh;;
  338. i|install)
  339. command_install.sh;;
  340. ai|auto-install)
  341. fn_autoinstall;;
  342. mc|map-compressor)
  343. compress_ut99_maps.sh;;
  344. dd|deps-detect)
  345. command_dev_detect_deps.sh;;
  346. dg|detect-glibc)
  347. command_dev_detect_glibc.sh;;
  348. *)
  349. if [ -n "${getopt}" ]; then
  350. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  351. exitcode=2
  352. fi
  353. echo "Usage: $0 [option]"
  354. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  355. echo "https://gameservermanagers.com/${selfname}"
  356. echo -e ""
  357. echo -e "${lightyellow}Commands${default}"
  358. {
  359. echo -e "${blue}start\t${default}st |Start the server."
  360. echo -e "${blue}stop\t${default}sp |Stop the server."
  361. echo -e "${blue}restart\t${default}r |Restart the server."
  362. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  363. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  364. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  365. echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
  366. echo -e "${blue}backup\t${default}b |Create archive of the server."
  367. echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
  368. echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
  369. echo -e "${blue}install\t${default}i |Install the server."
  370. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  371. echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps."
  372. } | column -s $'\t' -t
  373. esac
  374. }
  375. fn_getopt_unreal2(){
  376. case "${getopt}" in
  377. st|start)
  378. command_start.sh;;
  379. sp|stop)
  380. command_stop.sh;;
  381. r|restart)
  382. command_restart.sh;;
  383. u|update)
  384. command_update.sh;;
  385. fu|force-update|update-restart)
  386. forceupdate=1;
  387. update_check.sh;;
  388. uf|update-functions)
  389. command_update_functions.sh;;
  390. v|validate)
  391. command_validate.sh;;
  392. m|monitor)
  393. command_monitor.sh;;
  394. ta|test-alert)
  395. command_test_alert.sh;;
  396. dt|details)
  397. command_details.sh;;
  398. b|backup)
  399. command_backup.sh;;
  400. c|console)
  401. command_console.sh;;
  402. d|debug)
  403. command_debug.sh;;
  404. dev|dev-debug)
  405. command_dev_debug.sh;;
  406. i|install)
  407. command_install.sh;;
  408. ai|auto-install)
  409. fn_autoinstall;;
  410. dd|deps-detect)
  411. command_dev_detect_deps.sh;;
  412. dg|detect-glibc)
  413. command_dev_detect_glibc.sh;;
  414. mc|map-compressor)
  415. compress_unreal2_maps.sh;;
  416. *)
  417. if [ -n "${getopt}" ]; then
  418. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  419. exitcode=2
  420. fi
  421. echo "Usage: $0 [option]"
  422. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  423. echo "https://gameservermanagers.com/${selfname}"
  424. echo -e ""
  425. echo -e "${lightyellow}Commands${default}"
  426. {
  427. echo -e "${blue}start\t${default}st |Start the server."
  428. echo -e "${blue}stop\t${default}sp |Stop the server."
  429. echo -e "${blue}restart\t${default}r |Restart the server."
  430. echo -e "${blue}update\t${default}Checks and applies updates from SteamCMD."
  431. echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD."
  432. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  433. echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD."
  434. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  435. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  436. echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
  437. echo -e "${blue}backup\t${default}b |Create archive of the server."
  438. echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
  439. echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
  440. echo -e "${blue}install\t${default}i |Install the server."
  441. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  442. echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps."
  443. } | column -s $'\t' -t
  444. esac
  445. }
  446. fn_getopt_ut2k4(){
  447. case "${getopt}" in
  448. st|start)
  449. command_start.sh;;
  450. sp|stop)
  451. command_stop.sh;;
  452. r|restart)
  453. command_restart.sh;;
  454. uf|update-functions)
  455. command_update_functions.sh;;
  456. m|monitor)
  457. command_monitor.sh;;
  458. ta|test-alert)
  459. command_test_alert.sh;;
  460. dt|details)
  461. command_details.sh;;
  462. b|backup)
  463. command_backup.sh;;
  464. c|console)
  465. command_console.sh;;
  466. d|debug)
  467. command_debug.sh;;
  468. dev|dev-debug)
  469. command_dev_debug.sh;;
  470. i|install)
  471. command_install.sh;;
  472. ai|auto-install)
  473. fn_autoinstall;;
  474. cd|server-cd-key)
  475. install_ut2k4_key.sh;;
  476. mc|map-compressor)
  477. compress_unreal2_maps.sh;;
  478. dd|deps-detect)
  479. command_dev_detect_deps.sh;;
  480. dg|detect-glibc)
  481. command_dev_detect_glibc.sh;;
  482. *)
  483. if [ -n "${getopt}" ]; then
  484. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  485. exitcode=2
  486. fi
  487. echo "Usage: $0 [option]"
  488. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  489. echo "https://gameservermanagers.com/${selfname}"
  490. echo -e ""
  491. echo -e "${lightyellow}Commands${default}"
  492. {
  493. echo -e "${blue}start\t${default}st |Start the server."
  494. echo -e "${blue}stop\t${default}sp |Stop the server."
  495. echo -e "${blue}restart\t${default}r |Restart the server."
  496. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  497. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  498. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  499. echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
  500. echo -e "${blue}backup\t${default}b |Create archive of the server."
  501. echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
  502. echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
  503. echo -e "${blue}install\t${default}i |Install the server."
  504. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  505. echo -e "${blue}server-cd-key\t${default}cd |Add your server cd key"
  506. echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps."
  507. } | column -s $'\t' -t
  508. esac
  509. }
  510. if [ "${gamename}" == "Mumble" ]; then
  511. fn_getopt_mumble
  512. elif [ "${engine}" == "minecraft" ]; then
  513. fn_getopt_minecraft
  514. elif [ "${gamename}" == "TeamSpeak 3" ]; then
  515. fn_getopt_teamspeak3
  516. elif [ "${gamename}" == "Garry's Mod" ]; then
  517. fn_getopt_gmodserver
  518. elif [ "${engine}" == "unreal2" ]; then
  519. if [ "${gamename}" == "Unreal Tournament 2004" ]; then
  520. fn_getopt_ut2k4
  521. else
  522. fn_getopt_unreal2
  523. fi
  524. elif [ "${engine}" == "unreal" ]; then
  525. fn_getopt_unreal
  526. else
  527. fn_getopt_generic
  528. fi
  529. core_exit.sh