hardy init script status action

Dustin Kirkland dustin.kirkland at canonical.com
Fri Mar 14 00:01:01 GMT 2008


Howdy-

Several members of the Ubuntu Server community (primarily Onno Benschop
and myself) have been looking at the init scripts that drive
starting/stopping of some of the core daemons in Ubuntu Server.  We've
noticed that only a very few (apparmor, cupsys, mysql, postfix,
postgresql) have implemented the "status" action.

The Linux Standard Base init script specification [1] describes the
status action in detail, and requires it for LSB compliance.  In brief,
it provides a centralized and direct way of determine if a given service
is running or not, with a bit 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 [1].

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.

First, we'd like to add a function, status_of_proc(),
to /lib/lsb/init-functions (owned by lsb-base), 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.

+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 a series of patches to various init
scripts essentially adding the following to the 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 there should be no
chance of regression, as we're talking about adding a "status" handler
where this functionality did not exist before.

We will work through the appropriate channels for filing Launchpad bugs,
submitting debdiffs, and requesting Feature Freeze exceptions.  As minor
as these code changes are, it would affect several packages, and we're
mentioning it here in the interest of gathering any meaningful comments
on the matter as soon as possible.


[1]http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html

Thanks,
-- 
:-Dustin

Dustin Kirkland
Ubuntu Server Team
Canonical, LTD
dustin.kirkland at canonical.com
GPG: 1024D/83A61194
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/ubuntu-devel/attachments/20080313/9e1da120/attachment.pgp 


More information about the ubuntu-devel mailing list