How do I use chkconfig to enable a script for a service that accepts start, stop, and status options?

Not all scripts with start/stop/status options are manageable by chkconfig. The script must adhere to the following requirements:

  1. The first line indicates what shell is used to run the script
  2. The second line is just a blank comment.
  3. The third line should be a comment that indicates which runlevels should the service be started by default as well as the start and stop priority levels.
  4. The fourth line should be a comment that contains the description for the service. The description may extend up to several (commented) lines as necessary. Use the backslash character (\) if the comment extends to several lines.

Below is an example for the Samba script /etc/init.d/smb:

# chkconfig: - 91 35
# description: Starts and stops the Samba smbd and nmbd daemons \
# used to provide SMB network services.

The start/stop priority levels (91 and 35, respectively, shown above) are important for services that depend on other services. For example, it is required that portmap is started before nfs. If the script does not depend on other services, you may choose to execute it after the system is completely up and running. The easiest way is to call it from /etc/rc.d/rc.local. The command to do that is

echo /etc/init.d/yourscript >> /etc/rc.d/rc.local

Make sure that the script is executable. Issue the command:

chmod 0755 /etc/init.d/yourscript