Comment 12 for bug 203169

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Binary package hint: lsb

Ubuntu Hardy, lsb-base 3.1-24ubuntu2

This bug has been discussed on the Ubuntu-devel mailing list [1].

Only a very few of the service init scripts in /etc/init.d, (apparmor, cupsys, mysql, postfix, postgresql) have implemented the "status" action.

The Linux Standard Base init script specification [2] describes the status action in detail, and requires it for LSB compliance. It provides a centralized and direct way of determine if a given service is running or not, with a more sophistication than grepping a process listing. It logs a message to standard out, and exits with one of a number of meaningful codes, also defined in [2].

Users and system administrators with experience in LSB-compliant distributions can be frustrated by a lack of a standard way to determine if a given service is running or not in Ubuntu. Given the LTS designation of Hardy and our interest in furthering the Ubuntu Server, we'd like to add this functionality to several of the init scripts for core daemons that ship on the Ubuntu Server ISO. It will also facilitate the integration with ebox and other status gathering and reporting tools.

We suggest solving this by adding a function to /lib/lsb/init-functions, which is already sourced by most scripts in /etc/init.d. The heavy lifting is performed by the pidofproc() function, which is already defined in that same file. (A proper debdiff will follow.)

+status_of_proc () {
+ local daemon name status
+ daemon="$1"
+ name="$2"
+ pidofproc $daemon >/dev/null
+ status=$?
+ if [ $status -eq 0 ]; then
+ log_success_msg "$name is running."
+ else
+ log_failure_msg "$name is not running."
+ fi
+ return $status
+}

This addition would be followed by patches to init scripts essentially adding a case handler:

+ status)
+ status_of_proc "$DAEMON" "$NAME"
+ exit $?
+ ;;

The risk should be minimal. It will clearly not affect the functionality of starting and stopping daemons, and thus a minimal chance of regression. We will push the changes to Debian, as there is a similar bug in Debian's bug tracker [3].

[1] https://lists.ubuntu.com/archives/ubuntu-devel/2008-March/025176.html
[2] http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
[3] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=291148