I'm using a Raspberry Pi 2 Model B running the latest Raspbian Stretch Lite 2018-11-13.

I built a program that communicates with a LoRa chip (SX1276) using SPI, gets some data from a temperature sensor and prints the temperature on the screen.

My program consists of only one executable (apart from wiringpi library).

I was searching for a tutorial to make my program a *.deb package. Using this tutorial I managed to build a lora.deb package.

When I installed my lora.deb package sudo dpkg -i lora.deb the executable just deployed in a directory.

How can I make that package automatically run the executable and also run it every time the system boots?

  • 5
    Check out systemd service files. If your deb package contains a service file, and you add a postinstall script to your package, you can bring up a service after install automatically and on boot. – 111--- Jan 12 '19 at 20:48
  • 1
    See here here for guides to writing systemd unit files, which will be used by systemd (which handles startup) to start your service. – novice Jan 13 '19 at 1:00

change '/usr/bin/something' to '/directory/path/to/deployed/executable' below:

$ cat /etc/systemd/system/something.service

Description = Something Service
After = network.target

ExecStart = /usr/bin/something

WantedBy = multi-user.target

$ systemctl daemon-reload
$ systemctl enable something
$ systemctl start something
  • Thank you very much! Reading through all those sites and tutorials I came up to the solution for the whole method. First of all I need to add a myapp.service into my *.deb package, then I'll have to write a postinst script that will copy the myapp.service into the proper path and enable the service. I'm not quite sure if instead of a copy you just have to add the myapp.service into the *.deb package with the proper path. – MrBit Jan 13 '19 at 12:39
  • This is nice but it answers the question only partially. Where does this .service file go in the .deb file? How is the service activated by the .deb? – Jerther Mar 11 '19 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.