I'm building a bunch of services to install on my own (automatically created) servers. I'm migrating from upstart on Ubuntu 14.04, where services are enabled by default (we have to do extra work if we don't want then to start when installed), to Ubuntu 16.04 where we want to use systemd as the new native service framework.
The services are installed using deb packages that I'm creating myself. I've upgraded the deb creation by adding --with systemd
to rules
and adding a package-name.service
with a systemd unit specification.
The problem I found is that even if I add an [Install]
section with WantedBy=multi-user.target
, the service will not be started on the system.
Instead, the service gets installed and then systemctl status package-name
shows:
● package-name.service - My Service
Loaded: loaded (/lib/systemd/system/package-name.service; disabled; vendor preset: enabled)
Active: inactive (dead)
I don't have any systemd overrides in my rules
, which as I've understood from the Debian packaging with systemd page as well as the dh_systemd_enable man page I can use to not enable services if I choose not to.
Also from the looks of the status display it appears that dh-systemd
did enable the services (the vendor preset bit), but that was not enough. What am I missing?
dh_systemd_enable
(to make the service run by default) anddh_systemd_start
(to actually start it after installation) manually from theoverride_dh_auto_install
target inrules
, but I still don't understand why it doesn't get called automatically - as promised in its documentation..deb
packages, but I have worked with custom.rpm
packages that I wanted to enable a service for. Withrpm
s there's apost
section, which will just run the commands in it after install is finished. That's where I threw in asystemctl enable
. I assume.deb
has something similar.dh_auto_install
step gets translated by dpkg-build into a trigger script. My question is more about how to setup SystemD so it enables and starts "vendor enabled" services automatically. For now I'll just post that comment as an answer and approve that :-)rules
to containdh $@ --with systemd
,control
to containBuild-Depends: dh-systemd
,postinst
to contain#DEBHELPER#
and a reasonable current build system