]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/ExtSearchIdx.pm
extsearchidx: improve missing machine-id fallback
[public-inbox.git] / lib / PublicInbox / ExtSearchIdx.pm
index c6fb398beec13d90da2c9ba44a660ba343488682..b82d05462671500f97c4a04701804004bed1370c 100644 (file)
@@ -530,8 +530,10 @@ sub host_ident () {
        state $retval = hostname . '-' . do {
                my $m; # machine-id(5) is systemd
                if (open(my $fh, '<', '/etc/machine-id')) { $m = <$fh> }
-               # hostid(1) is in GNU coreutils, kern.hostid is FreeBSD
-               chomp($m ||= `hostid` || `sysctl -n kern.hostid`);
+               # (g)hostid(1) is in GNU coreutils, kern.hostid is most BSDs
+               chomp($m ||= `{ sysctl -n kern.hostid ||
+                               hostid || ghostid; } 2>/dev/null`
+                       || "no-machine-id-or-hostid-on-$^O");
                $m;
        };
 }