command_console.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # LinuxGSM command_console.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://linuxgsm.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. if [ "${gamename}" == "Rust" ]||[ "${gamename}" == "Hurtworld" ]||[ "${gamename}" == "ARK: Survival Evolved" ]; then
  12. fn_print_information_nl "${gamename} does not produce a verbose output to the console"
  13. fi
  14. if [ "${gamename}" == "Rust" ]||[ "${gamename}" == "Hurtworld" ]||[ "${gamename}" == "ARK: Survival Evolved" ]; then
  15. fn_print_information_nl "${gamename} does not allow server commands to be entered in to the console"
  16. fi
  17. fn_print_information_nl "Press \"CTRL+b\" then \"d\" to exit console."
  18. fn_print_warning_nl "Do NOT press CTRL+c to exit."
  19. echo " * https://github.com/GameServerManagers/LinuxGSM/wiki/Console"
  20. echo ""
  21. if ! fn_prompt_yn "Continue?" Y; then
  22. echo Exiting; return
  23. fi
  24. fn_print_dots "Accessing console"
  25. sleep 0.5
  26. check_status.sh
  27. if [ "${status}" != "0" ]; then
  28. fn_print_ok_nl "Accessing console"
  29. fn_script_log_pass "Console accessed"
  30. sleep 0.5
  31. tmux attach-session -t="${servicename}"
  32. fn_print_ok_nl "Closing console"
  33. fn_script_log_pass "Console closed"
  34. else
  35. fn_print_error_nl "Server not running"
  36. fn_script_log_error "Failed to access: Server not running"
  37. sleep 0.5
  38. if fn_prompt_yn "Do you want to start the server?" Y; then
  39. exitbypass=1
  40. command_start.sh
  41. fi
  42. fi
  43. core_exit.sh