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.
@@ -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);
}
