check_tmuxception.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. # LinuxGSM check_config.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: http://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Checks if run from tmux or screen.
  7. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  8. fn_check_is_in_tmux() {
  9. if [ "${TMUX}" ]; then
  10. fn_print_fail_nl "tmuxception error: Sorry Cobb you cannot start a tmux session inside of a tmux session."
  11. fn_script_log_fatal "Tmuxception error: Attempted to start a tmux session inside of a tmux session."
  12. fn_print_information_nl "LinuxGSM creates a tmux session when starting the server."
  13. echo -e "It is not possible to run a tmux session inside another tmux session"
  14. echo -e "https://docs.linuxgsm.com/requirements/tmux#tmuxception"
  15. core_exit.sh
  16. fi
  17. }
  18. fn_check_is_in_screen() {
  19. if [ "${STY}" ]; then
  20. fn_print_fail_nl "tmuxception error: Sorry Cobb you cannot start a tmux session inside of a screen session."
  21. fn_script_log_fatal "Tmuxception error: Attempted to start a tmux session inside of a screen session."
  22. fn_print_information_nl "LinuxGSM creates a tmux session when starting the server."
  23. echo -e "It is not possible to run a tmux session inside screen session"
  24. echo -e "https://docs.linuxgsm.com/requirements/tmux#tmuxception"
  25. core_exit.sh
  26. fi
  27. }
  28. fn_check_is_in_tmux
  29. fn_check_is_in_screen