0

I am creating a Debian package for a software application which gets executed from a service script and could like to know the best way to do this.

My current thoughts are for the package to copy the executable to /usr/bin, and the service to /etc/systemd/system/, and have a postinst script to execute

systemctl enable myapp.service

Is this the correct approach or is there a more 'standard' procedure for handling services within Debian package management?

1

1 Answer 1

0

What I do is create a .../debian folder in my projects and create a .service file for the daemon. I also add one command line option like so in the .../debian/rules file:

%:
    dh $@ --with systemd --parallel

That option tells the system to use systemd to handle the .service file (otherwise it falls back on SYS-V).

The one other thing to remember to do is add the #DEBHELPER# in your post/pre inst/rm scripts. These are very important since that's what actually makes it all work.

For example, here is a configuration in a postinst script:

#!/bin/sh

if [ "$1" = "configure" ]
then
     # Turn on IP forwarding
     echo 1 > /proc/sys/net/ipv4/ip_forward
fi

#DEBHELPER#

The position in your script will depend on what you do in your script. i.e. if you want to run a command after the service was started, then place the #DEBHELPER# before. If you need to finish up configuration that your service is going to use, then place the #DEBHELPER# after that configuration.

I have example in my Snap! project.

Note: if you have a project with more than one daemon, you can use the .../debian folder trick for one of them. The other, you have to install by hand (on your own).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .