I'm looking for good resources to learn more about how to write/debug/maintain init.d scripts on Ubuntu.
Do you have any links or books to recommend ?
I'm looking for good resources to learn more about how to write/debug/maintain init.d scripts on Ubuntu.
Do you have any links or books to recommend ?
These days init is actually being replaced by upstart in Ubuntu server. So what you probably want to do if you are writing these scripts is to try to write upstart ones instead of init. Here is a Getting Started Guide for upstart in Ubuntu.
This seemed pretty good. You also want to learn as much about bash as you can.
In the /etc/init.d
directory, there's a skeleton
file. You can use that as the basis for writing your own init script.
Remember that everything in the specific runlevel directory, /etc/rc0.d
, /etc/rc1.d
and so forth are symbolic links (ln /etc/init.d/myscript /etc/rc2.d/S50myscript -s
, for example.) to scripts in /etc/init.d
.
The first letter of the link, S
or K
, means to execute it when entering the runlevel (S), or leaving the runlevel (K). The two digits after that letter determine the order init
calls it when that runlevel is entered.
Debugging is accomplished through liberal use of the echo
command so you know what the script it doing, and thorough testing.