core_getopt.sh 15 KB

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