Re: how to check if its system bootup

2005-08-06 Thread Joe Smith


"LeVA" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

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?

Thanks!
Why would you want to do this? In general if a user is running the script 
with an argument of start it is for a very good reason such as manual 
booting, and should be treated the same as automatic booting. 




--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: how to check if its system bootup

2005-08-06 Thread Robert Brockway
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:  [EMAIL PROTECTED]
OpenTrend Solutions Ltd.Web:www.opentrend.net
We are open 24x7x365 for technical support.  Call us in a crisis.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: how to check if its system bootup

2005-08-06 Thread Bill Marcum
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.


-- 
Tonight you will pay the wages of sin; Don't forget to leave a tip.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



how to check if its system bootup

2005-08-06 Thread LeVA
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?

Thanks!

Daniel

-- 
LeVA


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]