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.
derek at computinginnovations.com
Sun Apr 6 12:42:47 UTC 2008
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:
You can easily add:
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
to see if it is 0 and a getty is found, or that it is 1 and the getty is
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the freebsd-questions