command_console.sh 1.6 KB

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