Re: need a shell script that can be executed manually or as part of the rc process. How can the script detect WHERE it is being called from to know how to handle various options.

2008-04-06 Thread Derek Ragona

At 03:21 PM 4/4/2008, Rance Hall wrote:

I have a sh script im working on that is going to be able to run by
the init/rc process.  That same script can also be run after the
system is started.

I need a way to have the sh script detect WHERE in the boot process
the server is when it is being executed.

for example, once a login prompt appears there should be a getty running.

prior to that time there shouldnt be a getty running, and if there
isnt a gettty running, then the script must be called from the rc
process and therefore I can do X instead of Y which I do when the
system is fully operational.

This is my thought process but I dont understand how to carry it out,
or if the thought process actually makes sense.

is there a better way for me to do what Im trying to do, and if there
isnt and Im on the right track, how do I do what Im asking?


There are a couple approaches you can take:

One simpler would be to use a cron job that runs @reboot
I believe these cron jobs would be run after the system is booted in 
multiuser.  You could experiment to determine if this is the case.


An alternative which would be more complex would be to write an rc script 
that runs from /usr/local/etc/rc.d.  Such a script would need to support at 
least the standard parameters of:

start
stop
status

You can easily add:
restart

where the restart function calls the stop and then the start functions.

In the start function if you need to verify a getty running, you can do:
ps -ax|grep getty
then test
$?
to see if it is 0 and a getty is found, or that it is 1 and the getty is 
not found.


-Derek

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: need a shell script that can be executed manually or as part of the rc process. How can the script detect WHERE it is being called from to know how to handle various options.

2008-04-06 Thread Wojciech Puchar

One simpler would be to use a cron job that runs @reboot
I believe these cron jobs would be run after the system is booted in


i'm sure it's run when cron deamon is started. which is when system boots 
but - when doing say /etc/rc.d/cron restart - too.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


need a shell script that can be executed manually or as part of the rc process. How can the script detect WHERE it is being called from to know how to handle various options.

2008-04-04 Thread Rance Hall
I have a sh script im working on that is going to be able to run by
the init/rc process.  That same script can also be run after the
system is started.

I need a way to have the sh script detect WHERE in the boot process
the server is when it is being executed.

for example, once a login prompt appears there should be a getty running.

prior to that time there shouldnt be a getty running, and if there
isnt a gettty running, then the script must be called from the rc
process and therefore I can do X instead of Y which I do when the
system is fully operational.

This is my thought process but I dont understand how to carry it out,
or if the thought process actually makes sense.

is there a better way for me to do what Im trying to do, and if there
isnt and Im on the right track, how do I do what Im asking?
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: need a shell script that can be executed manually or as part of the rc process. How can the script detect WHERE it is being called from to know how to handle various options.

2008-04-04 Thread Andrew Cid
Hi Rance,

 I have a sh script im working on that is going to be able to run by
 the init/rc process.  That same script can also be run after the
 system is started.
 
 I need a way to have the sh script detect WHERE in the boot process
 the server is when it is being executed.

You can control when your rc script runs with #REQUIRE: and #BEFORE:

Checkout the practical rc.d scripting article [1], chapter 7 has an
example.  Use rcorder(8) to see what runs when:

$ rcorder /etc/rc.d/*

Hope this helps,


Andrew 

[1] http://www.freebsd.org/doc/en/articles/rc-scripting/index.html
-- 
[EMAIL PROTECTED]

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]