All you need to do is:
- Log in as the super user.
- Write your shell script.
- Copy the file to
//etc//init.d
- Make the script executable.
- 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
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
.