fn_console 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. # LGSM fn_console function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. # Version: 210115
  6. # Description: Gives access to the server tmux console.
  7. local modulename="Console"
  8. fn_check_root
  9. fn_check_systemdir
  10. echo ""
  11. echo "${gamename} Console"
  12. echo "============================"
  13. echo ""
  14. echo "Press \"CTRL+b d\" to exit console."
  15. fn_printwarningnl "Do NOT press CTRL+c to exit."
  16. echo ""
  17. while true; do
  18. read -p "Continue? [y/N]" yn
  19. case $yn in
  20. [Yy]* ) break;;
  21. [Nn]* ) echo Exiting; return 1;;
  22. * ) echo "Please answer yes or no.";;
  23. esac
  24. done
  25. fn_printdots "Starting"
  26. sleep 1
  27. fn_check_tmux
  28. tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -Ec "^${servicename}:")
  29. if [ "${tmuxwc}" -eq 1 ]; then
  30. fn_printoknl "Starting"
  31. fn_scriptlog "accessed"
  32. sleep 1
  33. tmux attach-session -t ${servicename}
  34. else
  35. fn_printfailnl "Server not running"
  36. fn_scriptlog "Failed to access: Server not running"
  37. sleep 1
  38. while true; do
  39. read -p "Do you want to start the server? [y/N]" yn
  40. case $yn in
  41. [Yy]* ) fn_start; break;;
  42. [Nn]* ) break;;
  43. * ) echo "Please answer yes or no.";;
  44. esac
  45. done
  46. fi