core_getopt.sh 18 KB

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