5
1
I have a custom Debian package I've built for our software that creates a systemd service. What is the preferred/idiomatic way to have the installation of said package enable/start the service at install time?
What I did was add the following three lines to my postinst
script:
systemctl --system daemon-reload
systemctl enable my_service.service
systemctl start my_service.service
This worked fine until we tried to include loading this package in our initial image creation running under debootstrap
at which point it turned out that systemctl
appears to want a lot of environment stuff set up that just isn't normally up in that process.
1I have a similar question related to RPMs. I eventually gave up trying to start the system from the RPM post install script, because the way yum upgrade works: it first installs the new package, then uninstalls the old package. That means that the service is started, then stopped if you do an upgrade! – Mark Lakata – 2015-07-06T16:33:41.010
@MarkLakata thanks for the heads up, you potentially saved me a lot of trouble – haventchecked – 2016-01-27T18:13:22.920