Ubuntu Server would benefit from a "service" wrapper script

Bug #259043 reported by Dustin Kirkland  on 2008-08-18
6
Affects Status Importance Assigned to Milestone
debian-helper-scripts (Ubuntu)
Undecided
Unassigned
sysvconfig (Ubuntu)
Undecided
Unassigned
sysvinit (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: sysvinit

Ubuntu Server would benefit from a "service" wrapper script.

This script is simple shorthand for running scripts in /etc/init.d.

This functionality has long been present in Red Hat based Linux systems. Although I've been a using Ubuntu exclusively for several years now, I still find myself inadvertently typing "service apache2 restart", and such.

The functionality is trivial to implement, and would really assist Ubuntu Server administrators migrating from other distributions.

:-Dustin

Dustin Kirkland  (kirkland) wrote :

Patch attached.

Please review/sponsor.

:-Dustin

Dustin Kirkland  (kirkland) wrote :

As it turns out, there are at least two other implementations of "service" (besides my proposed patch to sysvinit):
 * sysvconfig
 * debian-helper-scripts

Additionally, the RH implementation is also a shell script that might be importable into Debian (must check the license/copyright). This is provided by the RH package
 * initscripts

Let me do some homework, and get back here.

:-Dustin

Dustin Kirkland  (kirkland) wrote :

Here is my analysis and suggested remedies:

 1) The "service" script in debian-helper-scripts is very, very basic. It simply does, `/etc/init.d/$1 $2 $3`, and there is no manpage. This script should be removed entirely, and the control file should be updated to depend on sysvinit-utils.

 2) The "service" script in sysvconfig is perhaps better, supporting a more complete feature set, and sporting it's own manpage. However, this package, as well as debian-helper-scripts are both in Universe. The script has commented out the status-all section, saying that Debian does not support "status" messages. Clearly, we've made some progress there [1], and this could actually be of some use now. This script should be moved (and modified) from this package, into sysvinit-utils, and the control file should be updated to depend on it.

 3) The Red Hat version of this script is closer to (2), and is GPLv2+, same as our source package for sysvinit. It should be possible to import and modify the RH version accordingly.

I will update the patch for a smarter "service" script, compatible with the ones used in debian-helper-scripts and sysvconfig, and as close as possible to the one in Red Hat. I will also attach subsequent patches to debian-helper-scripts and sysvconfig to prune out their provided "service" code, and set them to depend on sysvinit-utils.

:-Dustin

[1] https://wiki.ubuntu.com/InitScriptStatusActions

Dustin Kirkland  (kirkland) wrote :

Updated patch attached for sysvinit.

This patch:
 * Imports the "service" script functionality and manpage directly from the Fedora9 source, http://download.fedora.redhat.com/pub/fedora/linux/releases/9/Fedora/source/SRPMS/initscripts-8.76-1.src.rpm
  * Debian/Ubuntu changes include
   * service
    * Added header comments, with license/copyright in the shell script
    * Embedded a is_ignored_file() in the script; in the RH script, it was sourced from /etc/init.d/functions; we don't have/need that whole file. is_ignored_file() contains a more Debian/Ubuntu specific list of files to ignore. This list was taken from the sysvconfig version of the "service" script. There are probably some other scripts that could/should be added to this list over time.
    * Used INVOKERC="invoke-rc.d --force --quiet", rather than $SERVICEDIR/$SERVICE to execute the init script
    * Fixed one very minor bug in the RH version, which was using "-x" to test script execute-abilty in most places, but used a simpler "-f" test in one place; fixed this.
   * service.8
     * Removed the "See Also" links to non-existent (or not common) Debian/Ubuntu utilities (chkconfig, ntsysv).

I think this is a better implementation than:
 1) My previous version, which blindly just passed $@ to the init script, didn't use update-rc, didn't support --help, or --version, or --status-all, or --restart-all
 2) The sysvconfig version, which was a new implementation, which closely, but did not identically match the RH functionality
 3) The debian-helper-scripts version was was *very* primitive.

Requesting review and sponsorship/upload.

Followup patches will be posted to update debian-helper-scripts and sysvconfig to depend on sysvinit-utils.

:-Dustin

Dustin Kirkland  (kirkland) wrote :

Very minor update to the patch. Updated the debian/control package description of sysvinit-utils to mention that it provides the "service" utility.

:-Dustin

Dustin Kirkland  (kirkland) wrote :

Patch to remove "service" from debian-helper-scripts, and depend on sysvinit-utils.

:-Dustin

Dustin Kirkland  (kirkland) wrote :

Patch to remove "service" from sysvconfig, and depend on sysvinit-utils.

:-Dustin

Dustin Kirkland  (kirkland) wrote :

Updated sysvconfig.259043.debdiff.

The last one inadvertently deleted the installation of the sysvconfig.8 manpage. Whoops, sorry.

:-Dustin

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package sysvconfig - 0.80ubuntu1

---------------
sysvconfig (0.80ubuntu1) intrepid; urgency=low

  * service, service.8, debian/control, debian/rules: Remove the "service"
    utility and manpage provided by this package; and depend on a new
    sysvinit-utils, which provides a compatible "service" utility (LP: #259043).

 -- Dustin Kirkland <email address hidden> Tue, 19 Aug 2008 14:34:43 +0100

Changed in sysvconfig:
status: New → Fix Released
Kees Cook (kees) wrote :

Marking the "debian-helper-scripts" task invalid, as it will be removed from the archive. Please see bug 259492.

Changed in debian-helper-scripts:
status: New → Invalid
Dustin Kirkland  (kirkland) wrote :

Patch for sysvinit updated.
 * bumped version number due to another upload of this package.
 * added Red Hat copyright to service script
 * added Conflicts/Replaces bits to control file for other packages that provide "service"

:-Dustin

Dustin Kirkland  (kirkland) wrote :

Patch updated with trivial addition to debian/control, to fix Bug #259530.

:-Dustin

Dustin Kirkland  (kirkland) wrote :

Patch attached.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package sysvinit - 2.86.ds1-59ubuntu4

---------------
sysvinit (2.86.ds1-59ubuntu4) intrepid; urgency=low

  * debian/control: updated to mention that sysvinit-utils provides "service",
    added Conflicts/Replaces for other similar packages.
  * debian/control: update lsb-base to depend on 3.2-14 (LP: #259530).
  * debian/patches/00list: added 94_service.dpatch (LP: #259043).
  * debian/patches/94_service.dpatch: patch to add the service shell script to
    src/, and the manpage to man/.
  * src/service: imported and Debianized the Red Hat "service" shell script.
  * man/service.8: imported the Red Hat manpage for "service".

 -- Dustin Kirkland <email address hidden> Wed, 20 Aug 2008 00:12:47 +0100

Changed in sysvinit:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers