core_getopt.sh 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  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. *)
  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 information 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|detect-deps)
  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 information 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. c|console)
  154. command_console.sh;;
  155. d|debug)
  156. command_debug.sh;;
  157. dev|dev-debug)
  158. command_dev_debug.sh;;
  159. i|install)
  160. command_install.sh;;
  161. ai|auto-install)
  162. fn_autoinstall;;
  163. dd|detect-deps)
  164. command_dev_detect_deps.sh;;
  165. dg|detect-glibc)
  166. command_dev_detect_glibc.sh;;
  167. *)
  168. if [ -n "${getopt}" ]; then
  169. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  170. exitcode=2
  171. fi
  172. echo "Usage: $0 [option]"
  173. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  174. echo "https://gameservermanagers.com/${selfname}"
  175. echo -e ""
  176. echo -e "${lightyellow}Commands${default}"
  177. {
  178. echo -e "${blue}start\t${default}st |Start the server."
  179. echo -e "${blue}stop\t${default}sp |Stop the server."
  180. echo -e "${blue}restart\t${default}r |Restart the server."
  181. echo -e "${blue}update\t${default}u |Checks and applies updates from mojang.com."
  182. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  183. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  184. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  185. echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
  186. echo -e "${blue}backup\t${default}b |Create archive of the server."
  187. echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
  188. echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
  189. echo -e "${blue}install\t${default}i |Install the server."
  190. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  191. } | column -s $'\t' -t
  192. esac
  193. }
  194. fn_getopt_mumble(){
  195. case "${getopt}" in
  196. st|start)
  197. command_start.sh;;
  198. sp|stop)
  199. command_stop.sh;;
  200. r|restart)
  201. command_restart.sh;;
  202. u|update)
  203. command_update.sh;;
  204. uf|update-functions)
  205. command_update_functions.sh;;
  206. m|monitor)
  207. command_monitor.sh;;
  208. ta|test-alert)
  209. command_test_alert.sh;;
  210. dt|details)
  211. command_details.sh;;
  212. b|backup)
  213. command_backup.sh;;
  214. dev|dev-debug)
  215. command_dev_debug.sh;;
  216. i|install)
  217. command_install.sh;;
  218. dd|detect-deps)
  219. command_dev_detect_deps.sh;;
  220. dg|detect-glibc)
  221. command_dev_detect_glibc.sh;;
  222. *)
  223. if [ -n "${getopt}" ]; then
  224. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  225. exitcode=2
  226. fi
  227. echo "Usage: $0 [option]"
  228. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  229. echo "https://gameservermanagers.com/${selfname}"
  230. echo -e ""
  231. echo -e "${lightyellow}Commands${default}"
  232. {
  233. echo -e "${blue}start\t${default}st |Start the server."
  234. echo -e "${blue}stop\t${default}sp |Stop the server."
  235. echo -e "${blue}restart\t${default}r |Restart the server."
  236. echo -e "${blue}update\t${default}u |Checks and applies updates from SteamCMD."
  237. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  238. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  239. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  240. echo -e "${blue}details\t${default}dt |Displays useful information about the server."
  241. echo -e "${blue}backup\t${default}b |Create archive of the server."
  242. echo -e "${blue}install\t${default}i |Install the server."
  243. } | column -s $'\t' -t
  244. esac
  245. }
  246. fn_getopt_gmodserver(){
  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. u|update)
  255. command_update.sh;;
  256. fu|force-update|update-restart)
  257. forceupdate=1;
  258. update_check.sh;;
  259. uf|update-functions)
  260. command_update_functions.sh;;
  261. v|validate)
  262. command_validate.sh;;
  263. m|monitor)
  264. command_monitor.sh;;
  265. ta|test-alert)
  266. command_test_alert.sh;;
  267. dt|details)
  268. command_details.sh;;
  269. b|backup)
  270. command_backup.sh;;
  271. c|console)
  272. command_console.sh;;
  273. d|debug)
  274. command_debug.sh;;
  275. dev|dev-debug)
  276. command_dev_debug.sh;;
  277. i|install)
  278. command_install.sh;;
  279. ai|auto-install)
  280. fn_autoinstall;;
  281. dd|detect-deps)
  282. command_dev_detect_deps.sh;;
  283. dg|detect-glibc)
  284. command_dev_detect_glibc.sh;;
  285. fd|fastdl)
  286. command_fastdl.sh;;
  287. *)
  288. if [ -n "${getopt}" ]; then
  289. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  290. exitcode=2
  291. fi
  292. echo "Usage: $0 [option]"
  293. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  294. echo "https://gameservermanagers.com/${selfname}"
  295. echo -e ""
  296. echo -e "${lightyellow}Commands${default}"
  297. {
  298. echo -e "${blue}start\t${default}st |Start the server."
  299. echo -e "${blue}stop\t${default}sp |Stop the server."
  300. echo -e "${blue}restart\t${default}r |Restart the server."
  301. echo -e "${blue}update\t${default}u |Checks and applies updates from SteamCMD."
  302. echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD."
  303. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  304. echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD."
  305. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  306. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  307. echo -e "${blue}details\t${default}dt |Displays useful information about the server."
  308. echo -e "${blue}backup\t${default}b |Create archive of the server."
  309. echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
  310. echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
  311. echo -e "${blue}install\t${default}i |Install the server."
  312. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  313. echo -e "${blue}fastdl\t${default}fd |Generates or update a FastDL folder for your server."
  314. } | column -s $'\t' -t
  315. esac
  316. }
  317. fn_getopt_unreal(){
  318. case "${getopt}" in
  319. st|start)
  320. command_start.sh;;
  321. sp|stop)
  322. command_stop.sh;;
  323. r|restart)
  324. command_restart.sh;;
  325. uf|update-functions)
  326. command_update_functions.sh;;
  327. m|monitor)
  328. command_monitor.sh;;
  329. ta|test-alert)
  330. command_test_alert.sh;;
  331. dt|details)
  332. command_details.sh;;
  333. b|backup)
  334. command_backup.sh;;
  335. c|console)
  336. command_console.sh;;
  337. d|debug)
  338. command_debug.sh;;
  339. dev|dev-debug)
  340. command_dev_debug.sh;;
  341. i|install)
  342. command_install.sh;;
  343. ai|auto-install)
  344. fn_autoinstall;;
  345. mc|map-compressor)
  346. compress_ut99_maps.sh;;
  347. dd|detect-deps)
  348. command_dev_detect_deps.sh;;
  349. dg|detect-glibc)
  350. command_dev_detect_glibc.sh;;
  351. *)
  352. if [ -n "${getopt}" ]; then
  353. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  354. exitcode=2
  355. fi
  356. echo "Usage: $0 [option]"
  357. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  358. echo "https://gameservermanagers.com/${selfname}"
  359. echo -e ""
  360. echo -e "${lightyellow}Commands${default}"
  361. {
  362. echo -e "${blue}start\t${default}st |Start the server."
  363. echo -e "${blue}stop\t${default}sp |Stop the server."
  364. echo -e "${blue}restart\t${default}r |Restart the server."
  365. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  366. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  367. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  368. echo -e "${blue}details\t${default}dt |Displays useful information about the server."
  369. echo -e "${blue}backup\t${default}b |Create archive of the server."
  370. echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
  371. echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
  372. echo -e "${blue}install\t${default}i |Install the server."
  373. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  374. echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps."
  375. } | column -s $'\t' -t
  376. esac
  377. }
  378. fn_getopt_unreal2(){
  379. case "${getopt}" in
  380. st|start)
  381. command_start.sh;;
  382. sp|stop)
  383. command_stop.sh;;
  384. r|restart)
  385. command_restart.sh;;
  386. u|update)
  387. command_update.sh;;
  388. fu|force-update|update-restart)
  389. forceupdate=1;
  390. update_check.sh;;
  391. uf|update-functions)
  392. command_update_functions.sh;;
  393. v|validate)
  394. command_validate.sh;;
  395. m|monitor)
  396. command_monitor.sh;;
  397. ta|test-alert)
  398. command_test_alert.sh;;
  399. dt|details)
  400. command_details.sh;;
  401. b|backup)
  402. command_backup.sh;;
  403. c|console)
  404. command_console.sh;;
  405. d|debug)
  406. command_debug.sh;;
  407. dev|dev-debug)
  408. command_dev_debug.sh;;
  409. i|install)
  410. command_install.sh;;
  411. ai|auto-install)
  412. fn_autoinstall;;
  413. dd|detect-deps)
  414. command_dev_detect_deps.sh;;
  415. dg|detect-glibc)
  416. command_dev_detect_glibc.sh;;
  417. mc|map-compressor)
  418. compress_unreal2_maps.sh;;
  419. *)
  420. if [ -n "${getopt}" ]; then
  421. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  422. exitcode=2
  423. fi
  424. echo "Usage: $0 [option]"
  425. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  426. echo "https://gameservermanagers.com/${selfname}"
  427. echo -e ""
  428. echo -e "${lightyellow}Commands${default}"
  429. {
  430. echo -e "${blue}start\t${default}st |Start the server."
  431. echo -e "${blue}stop\t${default}sp |Stop the server."
  432. echo -e "${blue}restart\t${default}r |Restart the server."
  433. echo -e "${blue}update\t${default}Checks and applies updates from SteamCMD."
  434. echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD."
  435. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  436. echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD."
  437. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  438. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  439. echo -e "${blue}details\t${default}dt |Displays useful information about the server."
  440. echo -e "${blue}backup\t${default}b |Create archive of the server."
  441. echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
  442. echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
  443. echo -e "${blue}install\t${default}i |Install the server."
  444. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  445. echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps."
  446. } | column -s $'\t' -t
  447. esac
  448. }
  449. fn_getopt_ut2k4(){
  450. case "${getopt}" in
  451. st|start)
  452. command_start.sh;;
  453. sp|stop)
  454. command_stop.sh;;
  455. r|restart)
  456. command_restart.sh;;
  457. uf|update-functions)
  458. command_update_functions.sh;;
  459. m|monitor)
  460. command_monitor.sh;;
  461. ta|test-alert)
  462. command_test_alert.sh;;
  463. dt|details)
  464. command_details.sh;;
  465. b|backup)
  466. command_backup.sh;;
  467. c|console)
  468. command_console.sh;;
  469. d|debug)
  470. command_debug.sh;;
  471. dev|dev-debug)
  472. command_dev_debug.sh;;
  473. i|install)
  474. command_install.sh;;
  475. ai|auto-install)
  476. fn_autoinstall;;
  477. cd|server-cd-key)
  478. install_ut2k4_key.sh;;
  479. mc|map-compressor)
  480. compress_unreal2_maps.sh;;
  481. dd|detect-deps)
  482. command_dev_detect_deps.sh;;
  483. dg|detect-glibc)
  484. command_dev_detect_glibc.sh;;
  485. *)
  486. if [ -n "${getopt}" ]; then
  487. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  488. exitcode=2
  489. fi
  490. echo "Usage: $0 [option]"
  491. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  492. echo "https://gameservermanagers.com/${selfname}"
  493. echo -e ""
  494. echo -e "${lightyellow}Commands${default}"
  495. {
  496. echo -e "${blue}start\t${default}st |Start the server."
  497. echo -e "${blue}stop\t${default}sp |Stop the server."
  498. echo -e "${blue}restart\t${default}r |Restart the server."
  499. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  500. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  501. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  502. echo -e "${blue}details\t${default}dt |Displays useful information about the server."
  503. echo -e "${blue}backup\t${default}b |Create archive of the server."
  504. echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
  505. echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
  506. echo -e "${blue}install\t${default}i |Install the server."
  507. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  508. echo -e "${blue}server-cd-key\t${default}cd |Add your server cd key"
  509. echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps."
  510. } | column -s $'\t' -t
  511. esac
  512. }
  513. if [ "${gamename}" == "Mumble" ]; then
  514. fn_getopt_mumble
  515. elif [ "${engine}" == "lwjgl2" ]; then
  516. fn_getopt_minecraft
  517. elif [ "${gamename}" == "TeamSpeak 3" ]; then
  518. fn_getopt_teamspeak3
  519. elif [ "${gamename}" == "Garry's Mod" ]; then
  520. fn_getopt_gmodserver
  521. elif [ "${engine}" == "unreal2" ]; then
  522. if [ "${gamename}" == "Unreal Tournament 2004" ]; then
  523. fn_getopt_ut2k4
  524. else
  525. fn_getopt_unreal2
  526. fi
  527. elif [ "${engine}" == "unreal" ]; then
  528. fn_getopt_unreal
  529. else
  530. fn_getopt_generic
  531. fi
  532. core_exit.sh