command_console.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. # LGSM command_console.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://gameservermanagers.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. fn_print_information_nl "Press \"CTRL+b\" then \"d\" to exit console."
  12. fn_print_warning_nl "Do NOT press CTRL+c to exit."
  13. echo ""
  14. while true; do
  15. read -e -i "y" -p "Continue? [Y/n]" yn
  16. case $yn in
  17. [Yy]* ) break;;
  18. [Nn]* ) echo Exiting; return;;
  19. * ) echo "Please answer yes or no.";;
  20. esac
  21. done
  22. fn_print_dots "Accessing console"
  23. sleep 1
  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 1
  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 1
  36. while true; do
  37. read -e -i "y" -p "Do you want to start the server? [Y/n]" yn
  38. case $yn in
  39. [Yy]* ) exitbypass=1; command_start.sh; break;;
  40. [Nn]* ) break;;
  41. * ) echo "Please answer yes or no.";;
  42. esac
  43. done
  44. fi
  45. core_exit.sh