core_getopt.sh 15 KB

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