Thanks,
Checking for non-empty ypwhich output seems to do the trick.
(ypwhich will write an error message to stderr and nothing to stdout if
ypbind is not running at all, but will hang if ypbind is trying to find
a working server).
On 04/01/15 20:29, Avery Payne wrote:
On Sat, Jan 3, 2015 at 4:05 AM, Luke Diamand <[email protected]> wrote:
I'm trying to write a ./run file for autofs which will wait for ypbind to
come up before starting autofs.
I've got a line in autofs/run that says:
sv check ypbind
and then a ./check script inside the ypbind directory which runs ypwhich.
From http://smarden.org/runit/sv.8.html we get this snippet: "If the
requested state of the service is *up*, and the script *./check* exists in
the service directory, *sv* runs this script to check whether the service
is up and running; it’s considered to be up if *./check* exits with 0."
So you need a "sv start ypbind" before you can "sv check ypbind".
Does your check script look like this?
timeout 1 ypwhich
The manpage for ypwhich says that the command returns a name, which implies
a string inside of a shell.
Try this:
SERVERNAME=$(ypwhich)
test -n $SERVERNAME && exit 0
exit 1
...or something like that. I am working under the assumption that ypwhich
returns a blank string if there is no server.