status_of_proc cannot handle options after parameters. -p *needs* to be first
Use variable $NAME instead of hard coded foo for package binary name
|Deletions are marked like this.||Additions are marked like this.|
|Line 17:||Line 17:|
|Line 21:||Line 22:|
|status_of_proc /usr/bin/foo foo||status_of_proc /usr/bin/$NAME $NAME|
|Line 27:||Line 28:|
|status_of_proc -p /var/run/foo/foo-server.pid /usr/bin/foo foo||status_of_proc -p /var/run/$NAME/$NAME-server.pid /usr/bin/$NAME $NAME|
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 <email@example.com> is the initiator.
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.
Ancient policy bug: 291148
Related broader ancient policy bug that wants more LSB things in init scripts: 208010
Similar effort in Ubuntu: https://bugs.launchpad.net/debian/+source/debian-policy/+bug/203169
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?
- 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)
Or have fun with UDD, e.g.,
1 SELECT DISTINCT 2 insts, lintian.package, essential, priority, information, bugs_packages.id AS bug_id, 3 (select title from bugs_packages bp join bugs using (id) where title like '%FTBFS%' and bp.package = lintian.package limit 1) AS ftbfs 4 FROM lintian LEFT JOIN (bugs_packages JOIN bugs_usertags ON bugs_packages.id = bugs_usertags.id AND email = 'firstname.lastname@example.org' AND tag = 'initd-status-support') USING (package) 5 LEFT JOIN popcon USING (package) 6 LEFT JOIN packages ON (lintian.package, package_arch, package_version) = (packages.package, architecture, version) 7 WHERE lintian.tag = 'init.d-script-does-not-implement-optional-option' 8 ORDER BY insts DESC NULLS LAST;