check_status.sh 772 B

123456789101112131415161718192021222324
  1. #!/bin/bash
  2. # LinuxGSM check_status.sh function
  3. # Author: Daniel Gibbs
  4. # Contributor: UltimateByte
  5. # Website: https://linuxgsm.com
  6. # Description: Checks the process status of the server. Either online or offline.
  7. local commandname="CHECK"
  8. local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  9. if [ "${shortname}" == "ts3" ]; then
  10. # 1: Server is running
  11. # 0: Server seems to have died
  12. # 0: No server running (ts3server.pid is missing)
  13. status=$("${executabledir}/ts3server_startscript.sh" status servercfgfullpathfile="${servercfgfullpath}")
  14. if [ "${status}" == "Server is running" ]; then
  15. status=1
  16. else
  17. ts3error="${status}"
  18. status=0
  19. fi
  20. else
  21. status=$(tmux list-sessions -F "#{session_name}" 2>/dev/null | grep -Ecx "^${servicename}")
  22. fi