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

Russ Allbery rra at debian.org
Wed Feb 5 23:20:21 UTC 2014


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

Petter Reinholdtsen <pere at hungry.com> writes:

> 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.

It's probably worth mentioning that this is basically the path down which
OpenRC went, except that OpenRC has taken the concept somewhat further to
allow the dependencies to be specified in code instead of comments (using
special shell functions).  You may want to take a look at their syntax,
since it's extremely close to what you're doing but possibly a bit more
fleshed out.

-- 
Russ Allbery (rra at debian.org)               <http://www.eyrie.org/~eagle/>





More information about the Pkg-sysvinit-devel mailing list