core_getopt.sh 17 KB

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