Skip to content

A live bird collage card for your Home Assistant dashboard.

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

frederikfea7ff0e0ce8
diff --git a/scripts/service_controls.php b/scripts/service_controls.php
index 97a3d6ec..506eb3a8 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 "<span style='color:green'>(active)</span>";
+ $op = shell_exec("sudo systemctl status ".$name." | grep Active");
+ if (stripos($op, " active (running)")) {
+ echo "<span style='color:green'>(active)</span>";
+ } elseif (stripos($op, " inactive ")) {
+ echo "<span style='color:#fc6603'>(inactive)</span>";
} else {
- echo "<span style='color:#fc6603'>(inactive)</span>";
+ $status = "ERROR";
+ if (preg_match("/(\S*)\s*\((\S+)\)/", $op, $matches)) {
+ $status = $matches[1]. " [" . $matches[2] . "]";
+ }
+ echo "<span style='color:red'>($status)</span>";
}
}
?>