command_console.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. # LinuxGSM command_console.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://linuxgsm.com
  5. # Description: Gives access to the server tmux console.
  6. local commandname="CONSOLE"
  7. local commandaction="Console"
  8. local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  9. check.sh
  10. fn_print_header
  11. if [ "${shortname}" == "rust" ]||[ "${shortname}" == "hw" ]||[ "${shortname}" == "ark" ]; then
  12. fn_print_information_nl "${gamename} does not produce a verbose output to the console"
  13. fn_print_information_nl "${gamename} does not allow server commands to be entered in to the console"
  14. fi
  15. fn_print_information_nl "Press \"CTRL+b\" then \"d\" to exit console."
  16. fn_print_warning_nl "Do NOT press CTRL+c to exit."
  17. echo " * https://github.com/GameServerManagers/LinuxGSM/wiki/Console"
  18. echo ""
  19. if ! fn_prompt_yn "Continue?" Y; then
  20. echo Exiting; return
  21. fi
  22. fn_print_dots "Accessing console"
  23. sleep 0.5
  24. check_status.sh
  25. if [ "${status}" != "0" ]; then
  26. fn_print_ok_nl "Accessing console"
  27. fn_script_log_pass "Console accessed"
  28. sleep 0.5
  29. tmux attach-session -t "${servicename}"
  30. fn_print_ok_nl "Closing console"
  31. fn_script_log_pass "Console closed"
  32. else
  33. fn_print_error_nl "Server not running"
  34. fn_script_log_error "Failed to access: Server not running"
  35. sleep 0.5
  36. if fn_prompt_yn "Do you want to start the server?" Y; then
  37. exitbypass=1
  38. command_start.sh
  39. fi
  40. fi
  41. core_exit.sh