command_console.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  9. check.sh
  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 -e -i "y" -p "Continue? [y/N]" yn
  19. case $yn in
  20. [Yy]* ) break;;
  21. [Nn]* ) echo Exiting; return;;
  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]* ) command_start.sh; break;;
  41. [Nn]* ) break;;
  42. * ) echo "Please answer yes or no.";;
  43. esac
  44. done
  45. fi