[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to check if its system bootup



On Sat, 6 Aug 2005, Bill Marcum wrote:

> On Sat, Aug 06, 2005 at 01:44:45PM +0200, LeVA wrote:
> > Hi!
> > 
> > I wonder if there is a way to check at an init.d script, if it is system 
> > bootup, or the user just executing the the script from a console, while the 
> > system is already up. Any way to do this?
> > 
> Use the "runlevel" command.

Unfortunately that won't work.  The runlevel when the init scripts are 
being executed is the same runlevel that the system will be running in.

I'll present three options here.  Each one has issues which I will note.  
The list of issues is probably not exhaustive :)

Option 1: Check to see if the shell is interactive.

The PS1 environment variable is set if the shell is interactive. A problem 
here is that a shell executed from cron and changing the state of a 
service would probably look just like a shell involved in the bootup.  A 
crafty user could also fool this by deliberately making the shell 
non-interactive.  This may not be a big deal.

Option 2: Check to see if the shell has a tty attached to STDIN.

Use the "tty" command for this.  A problem here is that a shell executed 
from cron and changing the state of a service would probably look just 
like a shell involved in the bootup.

Option 3:  Checking the state of the system through signature files

Some files do get added and removed during bootup.  You could research 
files which are present during the service start but not present later.  
This is problematic as these files may vary from release to release and 
across different distros.

Rob

-- 
Robert Brockway B.Sc.		Phone:	+1-416-669-3073
Senior Technical Consultant	Email:	support@opentrend.net
OpenTrend Solutions Ltd.	Web:	www.opentrend.net
We are open 24x7x365 for technical support.  Call us in a crisis.



Reply to: