command_console.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. commandname="CONSOLE"
  7. commandaction="Access console"
  8. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  9. fn_firstcommand_set
  10. check.sh
  11. fn_print_header
  12. if [ "${consoleverbose}" == "yes" ]; then
  13. echo -e "* Verbose output: ${lightgreen}yes${default}"
  14. elif [ "${consoleverbose}" == "no" ]; then
  15. echo -e "* Verbose output: ${red}no${default}"
  16. else
  17. echo -e "* Verbose output: ${red}unknown${default}"
  18. fi
  19. if [ "${consoleinteract}" == "yes" ]; then
  20. echo -e "* Interactive output: ${lightgreen}yes${default}"
  21. elif [ "${consoleinteract}" == "no" ]; then
  22. echo -e "* Interactive output: ${red}no${default}"
  23. else
  24. echo -e "* Interactive output: ${red}unknown${default}"
  25. fi
  26. echo ""
  27. fn_print_information_nl "Press \"CTRL+b\" then \"d\" to exit console."
  28. fn_print_warning_nl "Do NOT press CTRL+c to exit."
  29. echo -e "* https://docs.linuxgsm.com/commands/console"
  30. echo -e ""
  31. if ! fn_prompt_yn "Continue?" Y; then
  32. exitcode=0
  33. core_exit.sh
  34. fi
  35. fn_print_dots "Accessing console"
  36. check_status.sh
  37. if [ "${status}" != "0" ]; then
  38. fn_print_ok_nl "Accessing console"
  39. fn_script_log_pass "Console accessed"
  40. tmux attach-session -t "${sessionname}"
  41. fn_print_ok_nl "Closing console"
  42. fn_script_log_pass "Console closed"
  43. else
  44. fn_print_error_nl "Server not running"
  45. fn_script_log_error "Failed to access: Server not running"
  46. if fn_prompt_yn "Do you want to start the server?" Y; then
  47. exitbypass=1
  48. command_start.sh
  49. fn_firstcommand_reset
  50. fi
  51. fi
  52. core_exit.sh