Friday, June 29, 2007

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

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

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

The first line indicates what shell is used to run the script
The second line is just a blank comment.
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.
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.

(The script must be in the /etc/init.d/ directory)

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

#!/bin/sh
#
# 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.localMake sure that the script is executable. Issue the command:

chmod 0755 /etc/init.d/yourscript

No comments: