4
0

core_getopt.sh 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. #!/bin/bash
  2. # LGSM core_getopt.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://gameservermanagers.com
  5. # Description: getopt arguments.
  6. local 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. et|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. uf|update-functions)
  138. command_update_functions.sh;;
  139. m|monitor)
  140. command_monitor.sh;;
  141. et|test-alert)
  142. command_test_alert.sh;;
  143. b|backup)
  144. command_backup.sh;;
  145. dev|dev-debug)
  146. command_dev_debug.sh;;
  147. console)
  148. command_console.sh;;
  149. d|debug)
  150. command_debug.sh;;
  151. dd|depsdetect)
  152. command_dev_detect_deps.sh;;
  153. *)
  154. if [ -n "${getopt}" ]; then
  155. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  156. exitcode=2
  157. fi
  158. echo "Usage: $0 [option]"
  159. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  160. echo "https://gameservermanagers.com/${selfname}"
  161. echo -e ""
  162. echo -e "${lightyellow}Commands${default}"
  163. {
  164. echo -e "${blue}start\t${default}st |Start the server."
  165. echo -e "${blue}stop\t${default}sp |Stop the server."
  166. echo -e "${blue}restart\t${default}r |Restart the server."
  167. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  168. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  169. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  170. echo -e "${blue}backup\t${default}b |Create archive of the server."
  171. echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
  172. echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
  173. } | column -s $'\t' -t
  174. esac
  175. }
  176. fn_getopt_gmodserver(){
  177. case "${getopt}" in
  178. st|start)
  179. command_start.sh;;
  180. sp|stop)
  181. command_stop.sh;;
  182. r|restart)
  183. command_restart.sh;;
  184. u|update)
  185. command_update.sh;;
  186. fu|force-update|update-restart)
  187. forceupdate=1;
  188. update_check.sh;;
  189. uf|update-functions)
  190. command_update_functions.sh;;
  191. v|validate)
  192. command_validate.sh;;
  193. m|monitor)
  194. command_monitor.sh;;
  195. et|test-alert)
  196. command_test_alert.sh;;
  197. dt|details)
  198. command_details.sh;;
  199. b|backup)
  200. command_backup.sh;;
  201. c|console)
  202. command_console.sh;;
  203. d|debug)
  204. command_debug.sh;;
  205. dev|dev-debug)
  206. command_dev_debug.sh;;
  207. i|install)
  208. command_install.sh;;
  209. ai|auto-install)
  210. fn_autoinstall;;
  211. dd|depsdetect)
  212. command_dev_detect_deps.sh;;
  213. fd|fastdl)
  214. command_fastdl.sh;;
  215. *)
  216. if [ -n "${getopt}" ]; then
  217. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  218. exitcode=2
  219. fi
  220. echo "Usage: $0 [option]"
  221. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  222. echo "https://gameservermanagers.com/${selfname}"
  223. echo -e ""
  224. echo -e "${lightyellow}Commands${default}"
  225. {
  226. echo -e "${blue}start\t${default}st |Start the server."
  227. echo -e "${blue}stop\t${default}sp |Stop the server."
  228. echo -e "${blue}restart\t${default}r |Restart the server."
  229. echo -e "${blue}update\t${default}Checks and applies updates from SteamCMD."
  230. echo -e "${blue}force-update\t${default}fu |Bypasses the check 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}validate\t${default}v |Validate server files with SteamCMD."
  233. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  234. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  235. echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
  236. echo -e "${blue}backup\t${default}b |Create archive of the server."
  237. echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
  238. echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
  239. echo -e "${blue}install\t${default}i |Install the server."
  240. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  241. echo -e "${blue}fastdl\t${default}fd |Generates or update a FastDL folder for your server."
  242. } | column -s $'\t' -t
  243. esac
  244. }
  245. fn_getopt_unreal(){
  246. case "${getopt}" in
  247. st|start)
  248. command_start.sh;;
  249. sp|stop)
  250. command_stop.sh;;
  251. r|restart)
  252. command_restart.sh;;
  253. uf|update-functions)
  254. command_update_functions.sh;;
  255. m|monitor)
  256. command_monitor.sh;;
  257. et|test-alert)
  258. command_test_alert.sh;;
  259. dt|details)
  260. command_details.sh;;
  261. b|backup)
  262. command_backup.sh;;
  263. c|console)
  264. command_console.sh;;
  265. d|debug)
  266. command_debug.sh;;
  267. dev|dev-debug)
  268. command_dev_debug.sh;;
  269. i|install)
  270. command_install.sh;;
  271. ai|auto-install)
  272. fn_autoinstall;;
  273. mc|map-compressor)
  274. compress_ut99_maps.sh;;
  275. dd|depsdetect)
  276. command_dev_detect_deps.sh;;
  277. *)
  278. if [ -n "${getopt}" ]; then
  279. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  280. exitcode=2
  281. fi
  282. echo "Usage: $0 [option]"
  283. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  284. echo "https://gameservermanagers.com/${selfname}"
  285. echo -e ""
  286. echo -e "${lightyellow}Commands${default}"
  287. {
  288. echo -e "${blue}start\t${default}st |Start the server."
  289. echo -e "${blue}stop\t${default}sp |Stop the server."
  290. echo -e "${blue}restart\t${default}r |Restart the server."
  291. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  292. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  293. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  294. echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
  295. echo -e "${blue}backup\t${default}b |Create archive of the server."
  296. echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
  297. echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
  298. echo -e "${blue}install\t${default}i |Install the server."
  299. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  300. echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps."
  301. } | column -s $'\t' -t
  302. esac
  303. }
  304. fn_getopt_unreal2(){
  305. case "${getopt}" in
  306. st|start)
  307. command_start.sh;;
  308. sp|stop)
  309. command_stop.sh;;
  310. r|restart)
  311. command_restart.sh;;
  312. u|update)
  313. command_update.sh;;
  314. fu|force-update|update-restart)
  315. forceupdate=1;
  316. update_check.sh;;
  317. uf|update-functions)
  318. command_update_functions.sh;;
  319. v|validate)
  320. command_validate.sh;;
  321. m|monitor)
  322. command_monitor.sh;;
  323. et|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. dd|depsdetect)
  340. command_dev_detect_deps.sh;;
  341. mc|map-compressor)
  342. compress_unreal2_maps.sh;;
  343. *)
  344. if [ -n "${getopt}" ]; then
  345. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  346. exitcode=2
  347. fi
  348. echo "Usage: $0 [option]"
  349. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  350. echo "https://gameservermanagers.com/${selfname}"
  351. echo -e ""
  352. echo -e "${lightyellow}Commands${default}"
  353. {
  354. echo -e "${blue}start\t${default}st |Start the server."
  355. echo -e "${blue}stop\t${default}sp |Stop the server."
  356. echo -e "${blue}restart\t${default}r |Restart the server."
  357. echo -e "${blue}update\t${default}Checks and applies updates from SteamCMD."
  358. echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD."
  359. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  360. echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD."
  361. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  362. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  363. echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
  364. echo -e "${blue}backup\t${default}b |Create archive of the server."
  365. echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
  366. echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
  367. echo -e "${blue}install\t${default}i |Install the server."
  368. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  369. echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps."
  370. } | column -s $'\t' -t
  371. esac
  372. }
  373. fn_getopt_ut2k4(){
  374. case "${getopt}" in
  375. st|start)
  376. command_start.sh;;
  377. sp|stop)
  378. command_stop.sh;;
  379. r|restart)
  380. command_restart.sh;;
  381. uf|update-functions)
  382. command_update_functions.sh;;
  383. m|monitor)
  384. command_monitor.sh;;
  385. et|test-alert)
  386. command_test_alert.sh;;
  387. dt|details)
  388. command_details.sh;;
  389. b|backup)
  390. command_backup.sh;;
  391. c|console)
  392. command_console.sh;;
  393. d|debug)
  394. command_debug.sh;;
  395. dev|dev-debug)
  396. command_dev_debug.sh;;
  397. i|install)
  398. command_install.sh;;
  399. ai|auto-install)
  400. fn_autoinstall;;
  401. cd|server-cd-key)
  402. install_ut2k4_key.sh;;
  403. mc|map-compressor)
  404. compress_unreal2_maps.sh;;
  405. dd|depsdetect)
  406. command_dev_detect_deps.sh;;
  407. *)
  408. if [ -n "${getopt}" ]; then
  409. echo -e "${red}Unknown command${default}: $0 ${getopt}"
  410. exitcode=2
  411. fi
  412. echo "Usage: $0 [option]"
  413. echo "${gamename} - Linux Game Server Manager - Version ${version}"
  414. echo "https://gameservermanagers.com/${selfname}"
  415. echo -e ""
  416. echo -e "${lightyellow}Commands${default}"
  417. {
  418. echo -e "${blue}start\t${default}st |Start the server."
  419. echo -e "${blue}stop\t${default}sp |Stop the server."
  420. echo -e "${blue}restart\t${default}r |Restart the server."
  421. echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
  422. echo -e "${blue}monitor\t${default}m |Checks that the server is running."
  423. echo -e "${blue}test-alert\t${default}ta |Sends test alert."
  424. echo -e "${blue}details\t${default}dt |Displays useful infomation about the server."
  425. echo -e "${blue}backup\t${default}b |Create archive of the server."
  426. echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
  427. echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
  428. echo -e "${blue}install\t${default}i |Install the server."
  429. echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
  430. echo -e "${blue}server-cd-key\t${default}cd |Add your server cd key"
  431. echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps."
  432. } | column -s $'\t' -t
  433. esac
  434. }
  435. if [ "${gamename}" == "Mumble" ]; then
  436. fn_getopt_mumble
  437. elif [ "${gamename}" == "Teamspeak 3" ]; then
  438. fn_getopt_teamspeak3
  439. elif [ "${gamename}" == "Garry's Mod" ]; then
  440. fn_getopt_gmodserver
  441. elif [ "${engine}" == "unreal2" ]; then
  442. if [ "${gamename}" == "Unreal Tournament 2004" ]; then
  443. fn_getopt_ut2k4
  444. else
  445. fn_getopt_unreal2
  446. fi
  447. elif [ "${engine}" == "unreal" ]; then
  448. fn_getopt_unreal
  449. else
  450. fn_getopt_generic
  451. fi
  452. core_exit.sh