From fea7ff0e0ce838bd1f13b3b0611f74c3d1298701 Mon Sep 17 00:00:00 2001 From: frederik Date: Fri, 14 Mar 2025 16:34:32 +0100 Subject: [PATCH] fix: if icecast is not running, livestream.service is constantly restarting, but that does not show. make sure a service that is contantly "auto-restart" is show as such --- scripts/service_controls.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/service_controls.php b/scripts/service_controls.php index 97a3d6e..506eb3a 100644 --- a/scripts/service_controls.php +++ b/scripts/service_controls.php @@ -14,11 +14,17 @@ function service_status($name) { return; } } - $op = shell_exec("sudo systemctl status ".$name." | grep Active | grep ' active\| activating\|running\|waiting\|start'"); - if(strlen($op) > 0) { - echo "(active)"; + $op = shell_exec("sudo systemctl status ".$name." | grep Active"); + if (stripos($op, " active (running)")) { + echo "(active)"; + } elseif (stripos($op, " inactive ")) { + echo "(inactive)"; } else { - echo "(inactive)"; + $status = "ERROR"; + if (preg_match("/(\S*)\s*\((\S+)\)/", $op, $matches)) { + $status = $matches[1]. " [" . $matches[2] . "]"; + } + echo "($status)"; } } ?>