A bit about

Hello, everyone! All you can see below is just my bank of information. Some material I've found in the fathomless net, some I've learned myself. Don't think all of the information here is right or actual, but may be it could be of use for you :) All feedback is welcome, especially constructive ones :)

Wednesday, June 2, 2010

Linux: add custom script to chkconfig

One of my servers runs Red Hat EL5 and thus there's chkconfig available to configure services for different run levels. I developed a script for my application (runs as daemon) which I put into /etc/init.d/my_app. This script has the same CLI as all other scripts which control services. I mean it accepts one argument that can be "start", "stop", "restart" and "status" (I know, there could be other options, but this set was enough for me).

Then I decided not to create symbolic links in /etc/rc* manually, but to use chkconfig instead and received the following:
# chkconfig --add my_app
service file does not support chkconfig

The reason is that chkconfig has some requirements for comments in the begining of the script. They should be something like this:
#!/bin/bash
# chkconfig: 2345 95 20
# description: This application was developed by me and is tested on this server
# processname: my_app

chkconfig line tells chkconfig that application should run on 2, 3, 4 and 5 run levels and activation and deactivation priorities. The greater the number, the less priority has your application (see numbers in /etc/rc*.d/ links names)

After these lines are inserted into your script, service should be added to chkconfig without any problems.