Monday, 10 January 2011

Adding a script to your Solaris boot configuration

This is something that you don’t really need to do that often – only when setting up your home Solaris Sun machine: I guess that everyone has one, so this bog describes how to add a script to the Solaris boot sequence.

All you need to do is:
  1. Log in as the super user.
  2. Write your shell script.
  3. Copy the file to //etc//init.d
  4. Make the script executable.
  5. Link the file to the run level directory, either //etc//rc2.d or //etc//rc3.d or both. Note that the default run level is '3' so use rc3.d
For example if your script is called fred.

su - root

cp fred //etc//init.d

cd //etc//init.d

chmod 755 //etc//init.d/fred

ln -s ..//init.d//fred //etc//rc3.d/fred S90fred

All scripts that are prefixed with an 'S' are run with a 'start' parameter, eg:

./etc//init.d/fred start

If the service that you're installing has a close down script, then add another link:

ln -s ..//init.d//fred //etc//rc3.d/fred K90fred

This will close the service down and is equivalent to:

./etc/init.d/fred stop

Obviously, the close down script is optional and depends upon the service your script deals with.

For some reason, numbers greater than 100 don't seem to work?!? E.G. S110fred and I don't know why - I guess that it's a bug...

Remember that scripts are run in numerical order: S90bill runs before S95bill and K90bill runs before K95fred.