Unverified Commit 4747b661 authored by parazyd's avatar parazyd
parents ee9b964a b13d642c
if deb-systemd-helper debian-installed #UNITFILE#; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask #UNITFILE# >/dev/null || true
if deb-systemd-helper --quiet was-enabled #UNITFILE#; then
# Create new symlinks, if any.
deb-systemd-helper enable #UNITFILE# >/dev/null || true
# Update the statefile to add new symlinks (if any), which need to be cleaned
# up on purge. Also remove old symlinks.
deb-systemd-helper update-state #UNITFILE# >/dev/null || true
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask #UNITFILE# >/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled #UNITFILE#; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable #UNITFILE# >/dev/null || true
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state #UNITFILE# >/dev/null || true
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
if [ -n "$2" ]; then
deb-systemd-invoke $_dh_action #UNITFILES# >/dev/null || true
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
deb-systemd-invoke start #UNITFILES# >/dev/null || true
if [ "$1" = "remove" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper mask #UNITFILES# >/dev/null
if [ "$1" = "purge" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper purge #UNITFILES# >/dev/null
deb-systemd-helper unmask #UNITFILES# >/dev/null
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
if [ -d /run/systemd/system ]; then
deb-systemd-invoke stop #UNITFILES# >/dev/null
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
deb-systemd-invoke stop #UNITFILES# >/dev/null
This diff is collapsed.
......@@ -2,21 +2,38 @@ Source: init-system-helpers
Section: admin
Priority: extra
Maintainer: Daniel Reurich <daniel@centurion.net.nz>
Build-Depends: debhelper (>= 8.0.0), perl:any
Standards-Version: 3.9.6
Vcs-Git: https://git.devuan.org/pkg-admin/init-system-helpers.git
Uploaders: Michael Biebl <biebl@debian.org>,
Martin Pitt <mpitt@debian.org>,
Felipe Sateler <fsateler@debian.org>
Build-Depends: debhelper (>= 9),
Standards-Version: 4.0.0
Vcs-Git: https://git.devuan.org/pkg-admin/init-system-helpers.git
Vcs-Browser: https://git.devuan.org/pkg-admin/init-system-helpers
Package: init-system-helpers
Architecture: all
Priority: required
Essential: yes
Multi-Arch: foreign
Depends: perl-base (>= 5.20.1-3), ${perl:Depends}, ${misc:Depends}
Breaks: systemd (<< 44-12)
Depends: perl-base (>= 5.20.1-3),
Replaces: sysv-rc (<< 2.88dsf-59.3~),
sysvinit-utils (<< 2.88dsf-59.3),
# sysv-rc now pre-depends on us and if we break them we get:
# E: This installation run will require temporarily removing the essential package sysvinit-utils:amd64 due to a Conflicts/Pre-Depends loop. This is often bad, but if you really want to do it, activate the APT::Force-LoopBreak option.
#Breaks: sysv-rc (<< 2.88dsf-59.3~)
Breaks: systemd (<< 44-12),
sysvinit-utils (<< 2.88dsf-59.3~),
Conflicts: file-rc (<< 0.8.17~),
openrc (<= 0.18.3-1),
Description: helper tools for all init systems
This package contains helper tools that are necessary for switching between
the various init systems that Devuan contains (e.g. sysvinit, upstart).
Maintainers of other init systems are welcome to include their helpers in this package, provided it doesn't try to take over the world.
Maintainers of other init systems are welcome to include their helpers in this
package, provided it doesn't try to take over the world.
Package: dh-systemd
Architecture: all
......@@ -32,12 +49,11 @@ Description: [deprecated] debhelper add-on to handle systemd unit files
The dh_systemd_start command deals with start/stop/restart on upgrades for
systemd-only service files.
Package: init
Section: metapackages
Architecture: any
Essential: yes
Priority: required
Priority: important
XB-Important: yes
Multi-Arch: foreign
Pre-Depends: sysvinit-core | upstart [linux-any]
Depends: ${misc:Depends}
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Files: *
Copyright: 2013 Michael Stapelberg
License: BSD-3-clause
Files: systemd2init
Copyright: 2014 Ondřej Surý <ondrej@sury.org>
2014 Lukáš Zapletal <lzap+git@redhat.com>
License: GPL-3+
Files: debian/*
Copyright: 2013 Michael Stapelberg <stapelberg@debian.org>
License: BSD-3-clause
License: GPL-3+
On Debian systems the full text of the GNU General Public
License can be found in the `/usr/share/common-licenses/GPL'
Files: script/service man8/service.8
Copyright: 2006 Red Hat, Inc
2008 Canonical Ltd
License: GPL-2+
Files: script/invoke-rc.d man8/invoke-rc.d.8
Copyright: 2000,2001 Henrique de Moraes Holschuh <hmh@debian.org>
License: GPL-2+
Files: script/update-rc.d man8/update-rc.d.8
Copyright: 1997-2005 Miquel van Smoorenburg <miquels@cistron.nl>
Members of the pkg-sysvinit project
License: GPL-2+
License: GPL-2+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
On Debian systems, the complete text of the GNU General Public License
version 2 can be found in ‘/usr/share/common-licenses/GPL-2’.
License: BSD-3-clause
Copyright © 2013 Michael Stapelberg
script/dh_systemd_start usr/bin
script/dh_systemd_enable usr/bin
autoscripts usr/share/debhelper
lib/Debian/Debhelper/Sequence/systemd.pm usr/share/perl5/Debian/Debhelper/Sequence/
systemd2init/systemd2init usr/bin
systemd2init/skeleton.debian usr/share/dh-systemd
systemd2init/skeleton.redhat usr/share/dh-systemd
full = True
multimaint-merge = True
script/deb-systemd-helper usr/bin
script/deb-systemd-invoke usr/bin
script/invoke-rc.d usr/sbin
script/service usr/sbin
script/update-rc.d usr/sbin
......@@ -9,9 +9,7 @@
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
BUILD_DATE = $(shell dpkg-parsechangelog -S Date)
POD_MAN_DATE = $(shell date -u +"%Y-%m-%d" --date="$(BUILD_DATE)")
VERSION = $(shell dpkg-parsechangelog -S Version)
dh_perl -d --package=init-system-helpers
......@@ -19,9 +17,21 @@ override_dh_perl:
for file in $$(ls script); do \
pod2man --section=1p --utf8 script/$$file script/$$file.1p; \
for file in $$(ls script/deb-* script/dh_*); do \
pod2man --section=1p --utf8 $$file $$file.1p; \
[ ! -d debian/init-system-helpers ] || sed -i 's/__VERSION__/$(VERSION)/' debian/init-system-helpers/usr/sbin/service
if dpkg-vendor --derives-from ubuntu; then \
dh_gencontrol -- -Valt:sysvinit=""; \
else \
dh_gencontrol -- -Valt:sysvinit="| sysvinit-core"; \
dh $@
dh $@
Tests: t
Depends: @,
Restrictions: needs-root, breaks-testbed, allow-stderr, isolation-container
set -eu
mount --make-rprivate /
cpanm Linux::Clone
for test in t/*.t; do
echo "======== $(basename $test) ======="
perl $test
This is the internal documentation for invoke-rc.d, as
written by Henrique M Holschuh <hmh@debian.org>
This document can be found on the web as well at
There is also the Debian BTS entry for the invoke-rc.d policy change at
INVOKE-RC.D (/usr/sbin/invoke-rc.d) interface:
The interface for all implementations of invoke-rc.d is mandated by the base
implementation in the sysvinit package, just like it is done for
There is a provision for a "local initscript policy layer" (read: a call to
/usr/sbin/policy-rc.d if this executable is present in the local system),
which allows the local system administrator to control the behaviour of
invoke-rc.d for every initscript id and action. It is assumed that this
script is OPTIONAL and will by written and provided by packages other than
the initscript system (sysvinit and file-rc packages).
The basic interface for all implementations of policy-rc.d is mandated by
the requirements of the base implementation of invoke-rc.d. This interface
will be described either in the manpage of invoke-rc.d, and in a text file
stored in /usr/share/doc/sysvinit/ by package sysvinit (which will host the
base implementation of invoke-rc.d).
Proposed script interfaces:
invoke-rc.d [options] <basename> <action> [extra initscript parameters...]
basename - Initscript ID, as per update-rc.d(8)
action - Initscript action. Known actions are:
start, [force-]stop, [try-]restart,
[force-]reload, status
(status is there because of the LSB. Debian does not use it).
extra initscript parameters: These parameters are passed to the initscript
as is, after the action parameter. <action> is always the first paramenter
to the initscript, and may be modified by fallback actions or policy-rc.d
requests. Note, however, that the extra parameters are not dropped or
modified even if the action (first parameter) is modified.
Quiet mode, no error messages are generated by invoke-rc.d; policy-rc.d
is also called with --quiet if this option is in effect.
Try to run init script regardless of policy and non-fatal errors. Use
of this option in automated scripts is severely discouraged as it
bypasses integrity checks. If the initscript cannot be executed, error
status 102 is returned. Do note that the policy layer call
(policy-rc.d) is NOT skipped, although its results are ignored.
Try to run the initscript even if a non-fatal subsystem error is
detected (e.g: bad rc.d symlinks). A 102 status exit code will result
if init script fails to execute anyway). Unlike --force, policy is
still enforced with --try-anyway.
Return status code 101 instead of status code 0 if initscript action is
denied by local policy rules or runlevel constrains. An warning is
generated if the action is denied.
Returns one of status codes 100-106, does not execute the init.d
script. Implies --disclose-deny and --nofallback. Status codes 104-106
are only generated by this option.
Note many messages are still sent to stderr in --query mode, including
those regarding policy overrides and subsystem errors. Use --quiet if
silent --query operation is desired.
The policy layer (policy-rc.d) may return fallback actions to be run
instead of the requested action. If this option is active, a fallback
action request will be ignored and a "action not allowed" reply used in
its place. This is probably a BAD idea unless you know exactly what
you're doing.
Outputs help message to stdout
Unknown actions may generate warnings, but are passed to the underlying
initscript anyway. The reason for the warning is simple: It is very unlikely
that an unknown action (by invoke-rc.d) will be known to the policy layer
(policy-rc.d), and therefore it may cause an initscript to execute an action
which the local system administrator would have not allowed had he known
about it. If policy-rc.d is not present, no warnings for unknown actions
are generated.
Should an initscript be executed, invoke-rc.d ALWAYS returns the status code
returned by the initscript. Initscripts should not return status codes in
the 100+ range (this is also a LSB requirement).
Exit status codes (LSB compatible):
0 : success
either the init script was run and returned exit status 0 (note
that a fallback action may have been run instead of the one given
in the command line), or it was not run because of runlevel/local
policy constrains and --disclose-deny is not in effect.
1 - 99 : reserved for init.d script
100 : init script ID (basename) unknown
init script not registered sucessfully through
update-rc.d or init script does not exist.
This error is fatal for most initscript systems.
101 : action not allowed
requested action will not be performed because of
runlevel or local policy constrains, and
--disclose-deny is in effect. Note that a fallback
action is NOT considered "action not allowed",
unless --nofalback is in effect.
102 : subsystem error
initscript (or policy) subsystem malfuncion.
(e.g. broken /sbin/runlevel).
Also, forced initscript execution due to
--try-anyway or --force failed.
103 : syntax error
104 : action allowed
--query is in effect; init script would be run if
not for --query.
105 : behaviour uncertain
cannot determine if action should be carried out or
not, and --query in effect.
106 : fallback action requested
the policy layer denied the requested action, and
supplied an allowed fallback action.
This is the internal documentation for policy-rc.d, as
written by Henrique M Holschuh <hmh@debian.org>
This document can be found on the web as well at
There is also the Debian BTS entry for the invoke-rc.d policy change at
POLICY-RC.D Policy layer (/usr/sbin/policy-rc.d) interface:
Most Debian systems will not have this script as the need for a policy layer
is not very common. Most people using chroot jails just need an one-line
script which returns an exit status of 101 as the jailed
/usr/sbin/policy-rc.d script.
The /usr/sbin/policy-rc.d file *must* be managed through the alternatives
system (/usr/sbin/update-alternatives) by any packages providing it.
/usr/sbin/policy-rc.d [options] <initscript ID> <actions> [<runlevel>]
/usr/sbin/policy-rc.d [options] --list <initscript ID> [<runlevel> ...]
no error messages are generated.
instead of verifying policy, list (in a "human parseable" way) all
policies defined for the given initscript id (for all runlevels if no
runlevels are specified; otherwise, list it only for the runlevels
specified), as well as all known actions and their fallbacks for the
given initscript id (note that actions and fallback actions might be
global and not particular to a single initscript id).
<actions> is a space-separated list of actions (usually only one). Note that
the list is passed in a single parameter and not as multiple parameters.
The following actions are always known (even if specifying a policy for them
is not supported by whatever policy-rc.d system is in use): start,
[force-]stop, restart, [force-]reload, status.
If an out-of-runlevel start or restart attempt is detected by invoke-rc.d,
the "start" or "restart" action will be changed to "(start)" or "(restart)"
respectively. This allows policy-rc.d to differentiate an out-of-runlevel
start/restart from a normal one.
The runlevel parameters are optional. If a runlevel is not specified, it is
considered to be unknown/undefined. Note that for sysv-like initscript
systems, an undefined runlevel is very likely to cause a 105 exit status.
A runlevel for update-rc.d is defined as a character string, of which the
usual INIT one-character runlevels are only a subset. It may contain
embedded blanks.
stdout is used to output a single line containing fallback actions,
or to output --list results.
stderr is used to output error messages
stdin is not to be used, this is not an interactive interface.
Exit status codes:
0 - action allowed
1 - unknown action (therefore, undefined policy)
100 - unknown initscript id
101 - action forbidden by policy
102 - subsystem error
103 - syntax error
104 - [reserved]
105 - behaviour uncertain, policy undefined.
106 - action not allowed. Use the returned fallback actions
(which are implied to be "allowed") instead.
When in doubt (policy-rc.d returned status 105 or status 1), invoke-rc.d
will assume an action is allowed, but it will warn the user of the problem.
Returning fallback information:
Fallback actions are returned in the first line sent to stdout (other lines
will be discarded). Multiple actions to be tried are allowed, and must be
separated by spaces. Multiple actions are carried out one at a time, until
one is sucessful.
e.g.: returning status 106 and "restart stop" in stdout (without
the quotes) will cause invoke-rc.d to attempt action "restart",
and then only if "restart" failed, attempt action "stop".
invoke-rc.d built-in policy rules:
To shield policy-rc.d of the underlying initscript system (file-rc, links in
/etc/rc?.d or something else), invoke-rc.d implements the following built-in
1. action "start" out of runlevel is denied,
(policy-rc.d receives action "(start)" instead of "start");
2. action "restart" out of runlevel is denied,
(policy-rc.d receives action "(restart)" instead of "restart");
3. any action for a non-executable initscript is denied.
Rule 3 is absolute, policy-rc.d cannot override it.
use warnings;
use strict;
use Debian::Debhelper::Dh_Lib;
# dh_systemd_enable runs unconditionally, and before dh_installinit, so that
# the latter can use invoke-rc.d and all symlinks are already in place.
insert_before("dh_installinit", "dh_systemd_enable");
# dh_systemd_start handles the case where there is no corresponding init
# script, so it runs after dh_installinit.
insert_after("dh_installinit", "dh_systemd_start");
.\" Hey, Emacs! This is an -*- nroff -*- source file.
.\" Authors: Ian Jackson
.\" (c) 2003 Software in the Public Interest
.\" Traductor: Rubén Porras (nahoo@inicia.es)
.\" Revisado por : Javier Fernández-Sanguino Peńa (jfs@debian.org)
.\" Esteban Manchado Velázquez (zoso@demiurgo.org)
.\" Está basada en la página de manual original:
.\" versión 1.2 del CVS de /cvs/debian-doc/manpages/english/sysvinit/update-rc.d.8
.TH UPDATE\-RC.D 8 "23 de Diciembre de 2003" "Proyecto Debian" "sysv-rc"
update\-rc.d \- crea y borra los enlaces a los scripts init de tipo
System V
.B update\-rc.d
.RI [ -n ]
.RI [ -f ]
.IB nombre " remove"
.B update-rc.d
.RI [ -n ]
.IB nombre " defaults"
.RI [ NN " | " NN-start " " NN-stop ]
.B update-rc.d
.RI [ -n ]
.I nombre
.BR start | stop
.IR "NN nivel_de_ejecución nivel_de_ejecución " ...
.B .
.BR start | stop
.IR "NN nivel_de_ejecución nivel_de_ejecución " ...
.BR . " ..."
.B update-rc.d
actualiza automáticamente los enlaces a los scripts de init tipo
System V que se encuentran en
.BI /etc/rc[nivel_de_ejecución].d/NNnombre
y que apuntan a los script
.BI /etc/init.d/nombre\fR.
Estos son ejecutados por
.B init
cuando se cambia de nivel de ejecución y se usan generalmente para
arrancar y parar servicios del sistema (por ejemplo, demonios).
.I nivel_de_ejecución
es uno de los soportados por
.BR init ", " 0123456789S ,
es el código de secuencia de dos dígitos usado por
.B init
para decidir en que orden se ejecutan los scripts.
Esta página del manual documenta sólo el modo de uso y comportamiento de
.BR update-rc.d .
Para una explicación más detallada sobre la administración de los
scripts de init estilo System V, por favor, lea
.BR init (8)
y el
.IR "Manual de normativa de Debian" .
Cuando se ejecuta con una o varias de las opciones
.BR defaults ", " start ", o " stop ,
.B update-rc.d
crea los enlaces
.BI /etc/rc[nivel_de_ejecución].d/[SK]NNnombre
apuntando al script
.BI /etc/init.d/nombre\fR.
Si ya existe algún fichero con el nombre
.BI /etc/rc[nivel_de_ejecución].d/[SK]??
.B update-rc.d
no hace nada. Esto es así para que el administrador del sistema pueda
reorganizar los enlaces ( teniendo en cuenta que debe dejar al
menos un enlace si los quiere eliminar ) sin que se sobreescriba su
Si se usa la opción
.B defaults
.B update-rc.d
creará enlaces para arrancar los servicios en los niveles de ejecución
.B 2345
y parar los servicios en los niveles de ejecución
.BR 016 .
Por omisión todos los enlaces tendrán el código de secuencia 20, pero
esto puede cambiarse especificando uno o dos argumentos
.I NN.
Un argumento cambia el valor por omisión del código de secuencia tanto
para los enlaces de arranque como para los de parada, y si se
proporcionan dos argumentos el primero cambia el código de los enlaces
de arranque y el segundo el de los enlaces de parada.
En vez de usar
.B defaults
, los niveles de ejecución en los que se arranca o se para un servicio
pueden ser especificados explícitamente mediante un conjunto de
Cada uno de estos conjuntos empieza con un argumento
.BR start " o " stop
para especificar cuándo se van a crear enlaces para arrancar o parar
el servicio.
Luego les sigue
.IR NN ,
el código de secuencia para todos los enlaces del conjunto, y uno o
más números de nivel de ejecución, cada uno como un solo argumento. El
conjunto se termina con el argumento
.B '.'
(un punto).
Cuando se especifican explícitamente los niveles de ejecución,
normalmente habrá un conjunto
.B start
y otro
.B stop .
Si son necesarios diferentes códigos de secuencia para los
distintos niveles de ejecución, entonces es necesario especificar
varios conjuntos
.B start
.B stop .
El script
.BI /etc/init.d/nombre
debe existir antes de ejecutar
.B update-rc.d
para crear los enlaces.
Cuando se ejecuta con la opción
.I remove
, update-rc.d borra todos los enlaces dentro del directorio
.BI /etc/rc[nivel_de_ejecución].d
que apunten al script
.BI /etc/init.d/nombre\fR .
El script debe haber sido borrado previamente (
.B update-rc.d
lo comprueba ).
Normalmente los scripts post-eliminación de los paquetes ejecutan
.B update-rc.d
cuando detectan que su primer argumento es
.BR purge
, dado que esto indica que el administrador ha pedido explícitamente
que se borren los scripts de configuración proporcionados por el paquete.
Cualquier fichero en los directorios
.BI /etc/rc[nivel_de_ejecución].d
que no sea un enlace simbólico apuntando a un script en
.BI /etc/init.d/nombre
se mantendrá intacto.
.I -n
No hacer nada, solamente indicar que hubiera hecho.
.I -f
Borrar los enlaces incluso si todavía existe el script
.BI /etc/init.d/nombre .
Crear los enlaces usando los parámetros por omisión:
.B update-rc.d foobar defaults
Comando equivalente usando explícitamente un conjunto de argumentos:
.B update-rc.d foobar start 20 2 3 4 5 . stop 20 0 1 6 .