Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an install script for the operating system that I'm setting up and, in part of the script, I need to install the graphics card drivers. In order to do this, I'm required to switch to runlevel 2 using the command

init 2

So, if the script consists of

# In run level 3
echo "The";
init 2;
echo "quick";
init 3;
echo "brown";

, the only thing that is being printed is "The" due to the fact that the script is stopped in its tracks when the init command is sent. I'd like to make the installation of the operating system as automated as possible, but this seems to throw a wrench into the process. Any help would be very much appreciated.

Cheers, Charlie

share|improve this question

1 Answer 1

up vote 1 down vote accepted

As a general approach, what you could do is, in your script:

  1. create an 'init script' named scriptname dynamically, with the commands you need to execute in that particular run level.
  2. create the necessary symlinks from /etc/rc*runlevel*.d/S99*scriptname*.
  3. switch to the runlevel by invoking init runlevel
  4. init script scriptname will be executed
  5. scriptname could disable itself after running by removing the symlink /etc/rc*runlevel*.d/S99*scriptname*, and then repeat from 1 to 5.

It feels a bit ugly, but it does work (did it a long time ago).

share|improve this answer
    
Thank you! I'll be trying this out later today, but it seems like this strategy should do the trick. –  candrews Aug 3 '10 at 17:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.