Init Script Status Support

This page tracks the currently informal and unofficial release goal to have all init scripts in Debian support the "status" action. Peter Eisentraut <petere@debian.org> is the initiator.

Purpose

Every init script shipped by a package in Debian (that is, a file in /etc/init.d/) should support the "status" action in an LSB-conforming and meaningful way. This information is useful for administrators and is frequently requested by users coming from other Linux distributions.

References

Howto

An init script that does set -e (as recommended), already uses the LSB init functions and just starts exactly one daemon program can usually just do:

. /lib/lsb/init-functions
NAME=foo

...

status)
    status_of_proc /usr/bin/$NAME $NAME
    ;;

If the base name of the PID file (without ".pid" extension) does not match the base name of the program, you have to specify the full PID file name explicitly. Note that -p needs to be the first argument:

status)
    status_of_proc -p /var/run/$NAME/$NAME-server.pid /usr/bin/$NAME $NAME
    ;;

If your init script doesn't set -e (as recommended elsewhere), then you can write instead:

status)
    status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
    ;;

This is what /etc/init.d/skeleton does.

In general, the status action should report on whether what "start" would start and what "stop" would stop is still active. For example, if "start" creates a file and "stop" removes it, "status" should report whether the file exists. (But only consider this when the action being done is related to the core functionality of the package. If the actions are creating directories for temporary storage, you could just ignore that.)

As a corollary, if either "start" or "stop" does nothing, "status" should always report success.

status_of_proc requires a run-time dependencies on lsb-base (>= 3.2-13). This version is in lenny, so you could just forget about the version.

Tracking