init and init scripts

Brandon Peirce brandon_peirce at hotmail.com
Wed Aug 30 03:21:31 PDT 2006


dave frost wrote:

>Now i thought that the scripts would have to work out what the previous 
>runlevel was (using an exported shell variable) and stop the previous 
>runlevel, but this doesnt seem to be working.  It struck me that the shell 
>the init script runs in when entering a runlevel wont be the same shell the 
>init script for the other runlevel runs in so exported variable wont work, 
>make sense ?
>
>Could someone clarify how the current lfs init scripts detect the previous 
>runlevel.

AFAIK there are at least two techniques available.  I think probably
about 90% of all GNU/Linux systems use #2.

1) there is a binary called 'runlevel' which you can execute and it will
print the previous and current runlevel.

2) when the init process calls the scripts, it defines a couple of
environmonent variables like RUNLEVEL and PREVLEVEL which are
available to the scripts.  See the init(8) man page.

Brandon





More information about the lfs-support mailing list