The book’s discussion of startup scripts on pages 28-35 presumes that you will manually add symbolic links in the appropriate rclevel.d directories (see bottom of page 30).
This is, in fact, the method you have to use with Ubuntu, because, as the book says, the Debian scripts are “fragile, uncodumented, and outrageously inconsistent.” Becaused you are manually setting up links, you will have to keep track of the numbers following the K or S to make sure everything is in the right order.
Systems that conform to the Linux Standard Base
have a better way of
setting up startup scripts. In each startup script, you include a block
of comments that give information to the init script. This
block of comments (called “init info”) tells:
Here is the detailed specification of the init info format.
A third method, which is what some other distributions use, is to insert
information that the chkconfig utility uses. Quoting from the
man page:
Each service which should be manageable by
chkconfigneeds two or more commented lines added to its init.d script. The first line tellschkconfigwhat runlevels the service should be started in by default, as well as the start and stop priority levels. If the service should not, by default, be started in any runlevels, a-should be used in place of the runlevels list. The second line contains a description for the service, and may be extended across multiple lines with backslash continuation.For example, random.init has these three lines:
# chkconfig: 2345 20 80 # description: Saves and restores system entropy pool for \ # higher quality random number generation.This says that the random script should be started in levels 2, 3, 4, and 5, that its start priority should be 20, and that its stop priority should be 80. You should be able to figure out what the description says; the \ causes the line to be continued. The extra space in front of the line is ignored.
In this assignment, you will change this incomplete init script as follows:
$syslog
(system logging) and resolvconf services
must be started before this script starts.
chkconfig and init info
information that tells the script to start in run level 2 only and
stop in all other levels.chkconfig information, set the
start priority of this script to 98, and its
stop priority to 95gprintf statements in the script and replace the words
[[your full name here]] with
your full name.
Ubuntu does not have the
insserv program on the standard install. Do not install and
use it; if you do, it will ruin your life.
Ubuntu is now using a system called
upstart for initializing system
services. When it is fully implemented, there will be no
/etc/init.d directory.
Instead, there will be scripts in
the /etc/event.d directory that are called when certain events
occur. As of Ubuntu 7.04, these scripts are set up to emulate the
existing /etc/rcn.d structure. (You can
see some
documentation on script-writing, but it’s not easy reading.)
Ubuntu (and Debian) treat run levels 2-5 as identical. The default runlevel is 2, and it is not specified in /etc/inittab; in fact, the file doesn’t exist.
Do not upload this script to the CIT054 server and install the service
right away! Instead, test it on your local Linux system. You will have to
put the script into the /etc/init.d directory, and change its
permissions to 0755. You’ll want to do the rest of
the testing in a text-only console, which you may get to by pressing
CTRL-ALT-F2. (You may return to graphic mode with
CTRL-ALT-F7.)
If you are using Mandriva,use chkconfig by going to a shell
prompt and typing
cd /etc/init.d chkconfig --add name_of_your_script
On Mandriva, the chkconfig program has been written to use
the Linux Standard Base init info.
Then, from the command line, you can type init 2 and
init 3 to see that your script is indeed being
called at the appropriate times and places.
After you switch runlevels, you may have to press ENTER to see the
shell prompt.
The script also places
output into a file /tmp/initstuff so that you can see
when the script started and stopped (in case the messages scroll past
too fast for you to read them).
Upload your script to the server into your home directory. You can’t
put the upload directly into /etc/init.d because you
can’t FTP into the server as root. After you FTP,
log in via secure shell, and use su or sudo
to move the file into the proper directory, set
its permissions, name it as you did on your own machine to install it. When you
finish, email me to let me know you’ve finished.