[Pkg-sysvinit-devel] Two line init.d scripts? Sure, that will work!

Petter Reinholdtsen pere at hungry.com
Wed Feb 5 21:31:09 UTC 2014


The following message is a courtesy copy of an article
that has been posted to gmane.linux.debian.devel.general as well.

Hi.

A few months ago I drafted an idea to rewrite init.d scripts to use a
common implementation and only specify the unique parts in the init.d
scripts themselves.  That draft can be found on
<URL: http://people.skolelinux.org/pere/blog/Debian_init_d_boot_script_example_for_rsyslog.html >.

The idea is to let init.d scripts look like this:

  #!/lib/init/init-d-script
  ### BEGIN INIT INFO
  # Provides:          daemon
  # Required-Start:    $remote_fs $syslog
  # Required-Stop:     $remote_fs $syslog
  # Default-Start:     2 3 4 5
  # Default-Stop:      0 1 6
  # Short-Description: nice daemon
  # Description:       Provide service to others
  ### END INIT INFO
  DAEMON=/usr/sbin/daemond

Short and to the point, and in the simple case only list the path to
the daemon to start.  The code to implement init.d scripts is moved to
/lib/init/init-d-script, and the redundant code spread across
/etc/init.d/ can be dropped.

A few days ago I picked up the idea again, and wrote a more complete
draft of the /lib/init/init-d-script.  The code is available in the
simpler-init-scripts in the sysvinit GIT repository, available from
<URL: http://anonscm.debian.org/gitweb/?p=collab-maint/sysvinit;a=shortlog;h=refs/heads/simpler-init-scripts >.
I've tested it on a few packages, and believe the code is ready for
wider testing.

The main target group for this feature are the majority of packages
with init.d scripts, the ones starting a single daemon.  There are
around 1000 packages in Debian with init.d scripts.  Around 100 of
them start stuff using rcS.d/, and tend to be quite complex.  Most of
the rest start a simple daemon and are based on different generations
of /etc/init.d/skeleton.  The target for this feature is the latter
group.

The reason I bring this up on debian-devel@ is twofold.  First, I want
to gather feedback on the idea.  Will it work for your package, or are
some more hooks needed?  Second, I wonder where such script best would
belong.  My initial idea is to put it in the initscripts package,
installed on almost all Debian systems, but I suspect sysvinit-utils
is a good place too.  I plan to use the system in the initscripts
package, and am relucant to add new dependencies to it, as this would
make the new dependency a required package.

Comments?

CC to pkg-sysvinit-devel at lists.alioth.debian.org, where the system is
being drafted these days.

As for the line counting in the subject, I decided to ignore commented
lines.  Including those, we end up on 11 lines. :)

-- 
Happy hacking
Petter Reinholdtsen





More information about the Pkg-sysvinit-devel mailing list