command_console.sh 1.1 KB

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