core_getopt.sh 13 KB

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