= 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 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 == * Relevant part of LSB: http://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html * Ancient policy bug: DebianBug:291148 * Related broader ancient policy bug that wants more LSB things in init scripts: DebianBug:208010 * Similar effort in Ubuntu: https://bugs.launchpad.net/debian/+source/debian-policy/+bug/203169 == 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. * '''Open question''': What to do if a service is disabled using a custom mechanism such as `/etc/default/foo`? == Tracking == * 1116 init scripts total (26 Feb 2012) * ~-try `zgrep '^etc/init.d' /var/cache/apt/apt-file/*_debian_dists_testing_*_Contents-i386.gz | wc -l`-~ * Lintian tag for tracking missing "status" support: http://lintian.debian.org/tags/init.d-script-does-not-implement-optional-option.html (shows 493 hits as of 26 Feb 2012) * I use the usertag initd-status-support with user petere@debian.org: [[http://bugs.debian.org/cgi-bin/pkgreport.cgi?users=petere@debian.org&tag=initd-status-support|bug list]] * Or have fun with [[UDD]], e.g., {{{#!highlight sql SELECT DISTINCT insts, lintian.package, essential, priority, information, bugs_packages.id AS bug_id, (select title from bugs_packages bp join bugs using (id) where title like '%FTBFS%' and bp.package = lintian.package limit 1) AS ftbfs FROM lintian LEFT JOIN (bugs_packages JOIN bugs_usertags ON bugs_packages.id = bugs_usertags.id AND email = 'petere@debian.org' AND tag = 'initd-status-support') USING (package) LEFT JOIN popcon USING (package) LEFT JOIN packages ON (lintian.package, package_arch, package_version) = (packages.package, architecture, version) WHERE lintian.tag = 'init.d-script-does-not-implement-optional-option' ORDER BY insts DESC NULLS LAST;}}}