On Friday 28 February 2003 12:57 pm, Mike Meyer wrote:
> Since nobody else stepped forward with an answer, I'll try....
> In <[EMAIL PROTECTED]>, Cliff Sarginson 
> > 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, good points.  I don't think there is an elegant way of doing it either. 
To that end I don't think there is a truly important distinction anyway. If 
you're just looking for the simple answer, Cliff, checking if you can switch 
to another virtual terminal, and looking at the output of ps and perhaps 
mount, should tell you which one you're in.  Presuming you get use to the 
output of those commands in both scenarios.


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

Reply via email to