Since nobody else stepped forward with an answer, I'll try....

In <[EMAIL PROTECTED]>, Cliff Sarginson <[EMAIL PROTECTED]> typed:
> No I can think of kludgy ways to do this, but I want to know the way
> it should be done. How can you tell from with a shell script whether you
> are in single-user mode or not ?

The difference between starting single-user and starting multi-user is
that init just starts a shell in one case, and in the other it runs
/etc/rc then deals with /etc/ttys. Shutting down to single-user shuts
down the things in /etc/ttys - and anything else - then launches a
shell.  There doesn't appear to be a way to ask init if it's running
in single-user or multi-user mode.

I'd say the best way is to look for a shell process with a ppid of
1. This can be fooled by having a shell started in /etc/ttys. Looking
for things to be running in multi-user mode depends on them running,
which may fail during (ab)normal system operation.


Might I suggest that you're not really worried about being
single-user, but instead worried about some condition that is usually
true in single-user mode (quiescent file systems, no network daemons,
etc)? If that's the case, you'd probably be better off checking that
condition than checking for single-user mode. After all, given any
assumption you make about single-user mode, I can violate that
assumption if I really want to.

        <mike
-- 
Mike Meyer <[EMAIL PROTECTED]>          http://www.mired.org/consulting.html
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message

Reply via email to