Creating a .deb package and autorun it

debpackaging

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?

Best Answer

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

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

[Unit]
Description = Something Service
After = network.target

[Service]
ExecStart = /usr/bin/something

[Install]
WantedBy = multi-user.target

$ systemctl daemon-reload
$ systemctl enable something
$ systemctl start something
Related Question