Exercise on init scripts
The purpose of this exercise is to learn how to make start and stop scripts for init. We will make a simple example script that makes our machine print a banner when it starts up, and another when it shuts down.
Needed for this exercise:
- The root password for your machine.
- When on Linux: the bsd-games package which contains the banner command. Use rpm -Uvh bsd-games-version.rpm or apt-get bsd-games if you don't have it installed.
Short task description:
- Make a script containing two case statements: in the case of start, make the script print a banner saying the machine is coming up, in the case of stop another banner saying it is going down.
- Put the script in your init.d directory (generally something on the lines of /etc/rc.d/init.d or /etc/init.d).
- Make symbolic links in the configuration directory for runlevel 3: K99banner runs the init script with the stop argument, while S99banner runs the script with the start argument.
Test your script: init 6: you should see your banner when the machine goes down; the startup banner should be displayed when it reboots.
Alternatively, you can use the play command and any of the sounds in /usr/share/sounds/*/*.wav for a machine with more personality.
See here for a step-by-step explanation.