fn_console 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. # LGSM fn_console function
  3. # Author: Daniel Gibbs
  4. # Website: http://danielgibbs.co.uk
  5. # Version: 010115
  6. # Description: Gives access to the server tmux console.
  7. local modulename="Console"
  8. fn_rootcheck
  9. fn_syscheck
  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. tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -Ec "^${servicename}:")
  28. if [ "${tmuxwc}" -eq 1 ]; then
  29. fn_printoknl "Starting"
  30. fn_scriptlog "accessed"
  31. sleep 1
  32. tmux attach-session -t ${servicename}
  33. else
  34. fn_printfailnl "Server not running"
  35. fn_scriptlog "Failed to access: Server not running"
  36. sleep 1
  37. while true; do
  38. read -p "Do you want to start the server? [y/N]" yn
  39. case $yn in
  40. [Yy]* ) fn_startserver; break;;
  41. [Nn]* ) break;;
  42. * ) echo "Please answer yes or no.";;
  43. esac
  44. done
  45. fi