initctl: if the system doesn't have logs, skip it in status output

On, e.g., a container based system logs may not be available so check
also that the messages fallback exists instead of causing confusing
error in the status output for the service.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2022-03-07 15:43:58 +01:00
parent 0e695aa0c7
commit 078a1d0c95
+4 -1
View File
@@ -161,8 +161,11 @@ static int do_log(char *svc)
if (!svc || !svc[0])
svc = "finit";
if (!fexist(logfile))
if (!fexist(logfile)) {
logfile = "/var/log/messages";
if (!fexist(logfile))
return 0; /* bail out, maybe in container */
}
return systemf("cat %s | grep %s | tail -10", logfile, svc);
}