InitScriptStatusActions
4751
Comment: add dpkg -S bit
|
← Revision 79 as of 2009-11-29 13:27:58 ⇥
8458
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
= Overview = | ||<tablestyle="float:right; font-size: 0.9em; width:40%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;"><<TableOfContents(3)>>|| |
Line 3: | Line 3: |
The LSB suggests that init scripts provide a '''status''' action: | == Background == The LSB suggests that init scripts provide a ''status'' action: |
Line 6: | Line 8: |
== status_of_proc() library function in lsb-base == | DustinKirkland worked with Debian to [[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=490095|provide a method]], {{{ status_of_proc() }}}, in /lib/lsb/init-functions, in the [[http://packages.qa.debian.org/l/lsb.html|lsb-base]] library package. This function is fully integrated in Intrepid as of [[https://launchpad.net/ubuntu/+source/lsb|lsb-3.2-14]]. |
Line 8: | Line 10: |
DustinKirkland has worked with Debian to provide a status_of_proc() method in /lib/lsb/init-functions, which is provided by the lsb-base package. This function is fully integrated in Debian's lsb-3.2-14: * http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=490095 * http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=483285 * http://packages.qa.debian.org/l/lsb.html |
== Adding status actions to init scripts == |
Line 13: | Line 12: |
== various init script callers == DustinKirkland has provided patches to the key service init scripts that are installable from the Ubuntu Server CD: * at: wiki:Bug:247091 * bind9: wiki:Bug:247084 * cron: wiki:Bug:201504 * dovecot: wiki:Bug:247096 * openssh: wiki:Bug:247103 * samba: wiki:Bug:247087 * syslogkd: wiki:Bug:247106 OnnoBenschop has provided a script to detect, and compiled a list of init scripts that are lacking '''status''' action here: * https://wiki.ubuntu.com/OnnoBenschop/ubuntu-server/init.d-status Countless other init scripts could/should be patched to provide this functionality. |
Numerous init scripts should be patched to call {{{ status_of_proc() }}} and provide a ''status'' action. A simple recipe follows for adding such functionality. |
Line 30: | Line 15: |
When you encounter an init script that lacks a status action: | When you encounter an init script that [[https://wiki.ubuntu.com/InitScriptStatusActions#head-75448d0a482c28a007476b3be2394d9db3213662|lacks a status action]]: |
Line 32: | Line 17: |
* dpkg -S /etc/init.d/FOO 1. Open a Bug in Launchpad against the package |
* {{{ dpkg -S /etc/init.d/FOO }}} 1. Open a bug in Launchpad against the package |
Line 35: | Line 20: |
1. Grab the source * apt-get source FOO * sudo apt-get build-dep FOO 1. Locate the init script in the source tree, often: * debian/*.init * debian/rc |
1. Grab the source and build dependencies * {{{ apt-get source FOO }}} * {{{ sudo apt-get build-dep FOO }}} 1. Locate the init script in the source tree, sometimes * {{{ debian/*.init }}} * {{{ debian/rc }}} |
Line 44: | Line 29: |
* add a dependency in debian/control for lsb-base >= 3.2-12ubuntu3 * if you're sending to Ubuntu * add the changelog entry referencing your Launchpad bug 1. Test your patched init script * sh debian/FOO.init status * echo $? * sudo sh debian/FOO.init stop * sh debian/FOO.init status * echo $? * sudo sh debian/FOO.init start * sh debian/FOO.init status * echo $? |
* add a dependency in debian/control for lsb-base >= 3.2-14 * add the changelog entry referencing your Launchpad bug, (LP: #999999) 1. Assuming that you have the package installed, test your patched init script for the new functionality and regressions. Check that $? after the status calls are 0 on success, and non-zero on failure. * {{{ sudo sh debian/FOO.init start }}} * {{{ * Starting FOO [ OK ] }}} * {{{ sh debian/FOO.init status; echo $? }}} * {{{ * FOO is running. }}} * {{{ sudo sh debian/FOO.init stop }}} * {{{ * Stopping FOO [ OK ] }}} * {{{ sh debian/FOO.init status; echo $? }}} * {{{ * FOO is not running. }}} * {{{ sudo sh debian/FOO.init start }}} * {{{ * Starting FOO [ OK ] }}} |
Line 57: | Line 43: |
* debuild -S | * {{{ debuild -S }}} |
Line 59: | Line 45: |
* debdiff 1. Compare your work to some of the other patches that did similar things. * See the patch for ''atd'': * http://launchpadlibrarian.net/15924139/at.status.debdiff * Or, perhaps have a look at the patch for ''openssh-server'', which passes a pidfile to status_of_proc(): * http://launchpadlibrarian.net/15924489/openssh.status.debdiff * However, some are more complicated than others, such as ''samba'': * http://launchpadlibrarian.net/15925572/samba.status.debdiff 1. Add your patch to the Launchpad bug you filed |
* {{{ debdiff }}} 1. Compare your work to some of the other patches * [[http://launchpadlibrarian.net/15924139/at.status.debdiff|atd]] * [[http://launchpadlibrarian.net/15936081/openssh.status.debdiff|openssh-server]] 1. Add your patch to the Launchpad bug you filed, mark as ''Confirmed'' 1. Subscribe ''kirkland'', and (''ubuntu-main-sponsors'' or ''ubuntu-universe-sponsors'') as appropriate 1. For bonus points, file a bug in Debian, and work the patch back upstream * Use [[Debian/Usertagging]] * {{{User: ubuntu-devel@lists.ubuntu.com}}} * {{{Usertags: origin-ubuntu ubuntu-patch intrepid}}} |
Line 73: | Line 60: |
You can run '''dpkg -S /etc/init.d/...''' to determine the source package of any of the following scripts. | You can run {{{ dpkg -S /etc/init.d/... }}} to determine the source package of any of the following scripts. |
Line 75: | Line 62: |
=== /etc/init.d/... === 1. acpid |
=== Init scripts with daemon(s) === ===== /etc/init.d/... ===== 1. acpid: Bug:251681 (FIXED) 1. at: Bug:247091 (FIXED) 1. bind9: Bug:247084 (Patch submitted, awaiting main sponsorship) 1. bip: Bug:251287 (FIXED), [[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=492126|Debian #492126]] 1. bluetooth: Bug:251684 (FIXED) 1. bootlogd: Bug:259435 (Patch submitted, awaiting main sponsorship) 1. brltty: Bug:251626 (FIXED) 1. cron: Bug:201504 (FIXED) 1. dbus Bug:252214 (FIXED), [[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=492541|Debian #492541]] 1. dhcdbd: Bug:251624 (FIXED) 1. dovecot: Bug:247096 (FIXED) 1. gdm: Bug:251375 (FIXED) 1. hal: Bug:252350 (FIXED), [[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=492625|Debian #492625]] 1. kdm: Bug:259446 (Patch submitted, awaiting main sponsorship) 1. lighttpd: Bug:251924 (FIXED) 1. mysql 1. mysql-ndb 1. mysql-ndb-mgm 1. mythtv-backend Bug:251325 (FIXED) 1. nginx: Bug:251985 (FIXED) 1. nis 1. openvpn 1. openssh: Bug:247103 (FIXED) 1. portmap: Bug:254499 (Patch submitted, awaiting main sponsorship) 1. powernowd 1. pulseaudio (Be careful with this one: the default for desktop installs is via session, not via this initscript.) 1. rsync: Bug:251320 (FIXED), [[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=492138|Debian #492138]] 1. samba: Bug:247087 (Patch submitted, awaiting main sponsorship) 1. squid: Bug:251299 (FIXED), [[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=492131|Debian #492131]] 1. sysklogd: Bug:247106 (FIXED) 1. system-tools-backends: Bug:300743 (Patch submitted) 1. usplash 1. winbind: Bug:247087 (FIXED) 1. xinetd: Bug:251975 (FIXED) === Init scripts without daemon(s) === ==== No daemon, but detectable status ==== The following init scripts do not have an associated daemon, however, they do perform actions on the system which could be algorithmically checked. I'm noting some suggested items that could be checked in a 'status' action. ===== /etc/init.d/... ===== 1. apport - status should look at /proc/sys/kernel/core_pattern 1. binfmt-support - status should check update-binfmts --display, perhaps 1. checkfs.sh - status could show the time/date/results of the last check 1. checkroot.sh - similar to checkfs.sh, perhaps? 1. mountoverflowtmp - status could check the tmp mountpoint 1. mythtv-status: Bug:251330 (Patch awaiting sponsorship), checks if mythtv-status has run successfully 1. networking - status could check network connectivity 1. pcmciautils - status could check lsmod for needed modules 1. policykit - status could check directory existence and permissions 1. rmnologin - status could check /var/lib/initscripts/nologin 1. screen-cleanup - status could check /var/run/screen 1. single - status could check if in single user mode or not 1. skeleton - the skeleton init script itself should be enhanced to have a status action! 1. urandom - status could check /dev/urandom 1. firehol - status could check if current iptables match those firehol generates from its configuration ("firehol debug") else dispay the diff. Bug:185978 ==== No daemon ==== The following init scripts do not have an associated deamon. On initial review of the code, a 'status' action for these scripts does not necessarily make sense. If you have an idea of a sensible status action, please note the suggestion and move the item to the list above (detectable status). ===== /etc/init.d/... ===== |
Line 79: | Line 133: |
1. apport 1. binfmt-support 1. bluetooth 1. bootlogd |
|
Line 84: | Line 134: |
1. brltty 1. checkfs.sh 1. checkroot.sh |
|
Line 89: | Line 136: |
1. dbus 1. dhcdbd |
|
Line 92: | Line 137: |
1. gdm | |
Line 94: | Line 138: |
1. hal | |
Line 100: | Line 143: |
1. kdm | |
Line 111: | Line 153: |
1. mountoverflowtmp 1. mtab.sh 1. mysql 1. mysql-ndb 1. mysql-ndb-mgm 1. networking 1. openvpn 1. pcmciautils 1. policykit 1. powernowd |
|
Line 124: | Line 156: |
1. pulseaudio | |
Line 132: | Line 163: |
1. rmnologin 1. rsync 1. screen-cleanup |
|
Line 136: | Line 164: |
1. single 1. skeleton |
|
Line 141: | Line 167: |
1. system-tools-backends 1. udev 1. udev-finish |
|
Line 147: | Line 170: |
1. urandom 1. usplash |
|
Line 150: | Line 171: |
1. winbind | |
Line 153: | Line 173: |
== References == 1. http://lists.debian.org/debian-devel/2008/07/msg01031.html 1. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=490095 1. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=483285 1. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=291148 1. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=208010 1. http://packages.qa.debian.org/l/lsb.html 1. https://wiki.ubuntu.com/OnnoBenschop/ubuntu-server/init.d-status |
Background
The LSB suggests that init scripts provide a status action:
DustinKirkland worked with Debian to provide a method, status_of_proc() , in /lib/lsb/init-functions, in the lsb-base library package. This function is fully integrated in Intrepid as of lsb-3.2-14.
Adding status actions to init scripts
Numerous init scripts should be patched to call status_of_proc() and provide a status action. A simple recipe follows for adding such functionality.
Patch Checklist
When you encounter an init script that lacks a status action:
- Determine the source package
dpkg -S /etc/init.d/FOO
- Open a bug in Launchpad against the package
- Grab the source and build dependencies
apt-get source FOO
sudo apt-get build-dep FOO
- Locate the init script in the source tree, sometimes
debian/*.init
debian/rc
- Patch the source to
- have the init script call status_of_proc()
- have the init script add "status" to the usage statement
add a dependency in debian/control for lsb-base >= 3.2-14
- add the changelog entry referencing your Launchpad bug, (LP: #999999)
- Assuming that you have the package installed, test your patched init script for the new functionality and regressions. Check that $? after the status calls are 0 on success, and non-zero on failure.
sudo sh debian/FOO.init start
* Starting FOO [ OK ]
sh debian/FOO.init status; echo $?
* FOO is running.
sudo sh debian/FOO.init stop
* Stopping FOO [ OK ]
sh debian/FOO.init status; echo $?
* FOO is not running.
sudo sh debian/FOO.init start
* Starting FOO [ OK ]
- Build a source package
debuild -S
- Generate a patch
debdiff
- Compare your work to some of the other patches
Add your patch to the Launchpad bug you filed, mark as Confirmed
Subscribe kirkland, and (ubuntu-main-sponsors or ubuntu-universe-sponsors) as appropriate
- For bonus points, file a bug in Debian, and work the patch back upstream
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch intrepid
Init Scripts that Need a Status Action
The following is a crude list of init scripts in Intrepid that are lacking a "status" action. I say "crude" in that this list was generated on 2008-07-21 by installing the Intrepid Ubuntu (server, ubuntu-desktop, kubuntu-desktop, xubuntu-desktop), and grepping through /etc/init.d for scripts that lacked the string "status)". Please help improve this list by adding/removing init scripts to/from this list, and linking to a bug number. Please leave an informative note in this wiki page's changelog.
You can run dpkg -S /etc/init.d/... to determine the source package of any of the following scripts.
Init scripts with daemon(s)
/etc/init.d/...
acpid: 251681 (FIXED)
at: 247091 (FIXED)
bind9: 247084 (Patch submitted, awaiting main sponsorship)
bip: 251287 (FIXED), Debian #492126
bluetooth: 251684 (FIXED)
bootlogd: 259435 (Patch submitted, awaiting main sponsorship)
brltty: 251626 (FIXED)
cron: 201504 (FIXED)
dbus 252214 (FIXED), Debian #492541
dhcdbd: 251624 (FIXED)
dovecot: 247096 (FIXED)
gdm: 251375 (FIXED)
hal: 252350 (FIXED), Debian #492625
kdm: 259446 (Patch submitted, awaiting main sponsorship)
lighttpd: 251924 (FIXED)
- mysql
- mysql-ndb
- mysql-ndb-mgm
mythtv-backend 251325 (FIXED)
nginx: 251985 (FIXED)
- nis
- openvpn
openssh: 247103 (FIXED)
portmap: 254499 (Patch submitted, awaiting main sponsorship)
- powernowd
- pulseaudio (Be careful with this one: the default for desktop installs is via session, not via this initscript.)
rsync: 251320 (FIXED), Debian #492138
samba: 247087 (Patch submitted, awaiting main sponsorship)
squid: 251299 (FIXED), Debian #492131
sysklogd: 247106 (FIXED)
system-tools-backends: 300743 (Patch submitted)
- usplash
winbind: 247087 (FIXED)
xinetd: 251975 (FIXED)
Init scripts without daemon(s)
No daemon, but detectable status
The following init scripts do not have an associated daemon, however, they do perform actions on the system which could be algorithmically checked. I'm noting some suggested items that could be checked in a 'status' action.
/etc/init.d/...
- apport - status should look at /proc/sys/kernel/core_pattern
- binfmt-support - status should check update-binfmts --display, perhaps
- checkfs.sh - status could show the time/date/results of the last check
- checkroot.sh - similar to checkfs.sh, perhaps?
- mountoverflowtmp - status could check the tmp mountpoint
mythtv-status: 251330 (Patch awaiting sponsorship), checks if mythtv-status has run successfully
- networking - status could check network connectivity
- pcmciautils - status could check lsmod for needed modules
- policykit - status could check directory existence and permissions
- rmnologin - status could check /var/lib/initscripts/nologin
- screen-cleanup - status could check /var/run/screen
- single - status could check if in single user mode or not
- skeleton - the skeleton init script itself should be enhanced to have a status action!
- urandom - status could check /dev/urandom
firehol - status could check if current iptables match those firehol generates from its configuration ("firehol debug") else dispay the diff. 185978
No daemon
The following init scripts do not have an associated deamon. On initial review of the code, a 'status' action for these scripts does not necessarily make sense. If you have an idea of a sensible status action, please note the suggestion and move the item to the list above (detectable status).
/etc/init.d/...
- acpi-support
- alsa-utils
- bootmisc.sh
- console-screen.sh
- console-setup
- dns-clean
- glibc.sh
- halt
- hostname.sh
- hotkey-setup
- hwclockfirst.sh
- hwclock.sh
- keyboard-setup
- killprocs
- loopback
- module-init-tools
- mountall-bootclean.sh
- mountall.sh
- mountdevsubfs.sh
- mountkernfs.sh
- mountnfs-bootclean.sh
- mountnfs.sh
- powernowd.early
- pppd-dns
- procps
- rc
- rc.local
- rcS
- readahead
- readahead-desktop
- reboot
- resolvconf
- sendsigs
- stop-bootlogd
- stop-bootlogd-single
- stop-readahead
- umountfs
- umountnfs.sh
- umountroot
- vbesave
- wpa-ifupdown
- xserver-xorg-input-wacom
References
InitScriptStatusActions (last edited 2009-11-29 13:27:58 by 77-21-62-108-dynip)