core_getopt.sh 17 KB

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