Yocto enabling multiple systemd services with one recipe file
Asked Answered
C

1

6

I've taken over a project which uses Yocto to generate a customized Linux image.

I'm modifying a .bb recipe file which already creates and enables a systemd service. I need to create another systemd service and enable it from the same recipe file. Is this possible?

Below shows the bottom of the recipe file. app2.service is the service which is already enabled in the image. I wish to add update.service also. I have already appended the line : ${systemd_unitdir}/system/update.service to FILES_${PN} as shown

FILES_${PN} += "${sysconfdir} \
           ${systemd_unitdir}/system/app2.service \
           ${systemd_unitdir}/system/update.service \
"
inherit systemd

SYSTEMD_SERVICE_${PN} = "app2.service"

However, I believe the SYSTEMD_SERVICE_${PN} is what enables the service. Can I append the update.service with += to SYSTEMD_SERVICE_${PN} also in the same way?

I've looked online for an answer but it's not clear if I can enable multiple services like this.

Curio answered 4/6, 2019 at 18:0 Comment(1)
add update.service to SYSTEMD_SERVICE_${PN} and then SYSTEMD_AUTO_ENABLE_${PN} = "enable"Ceceliacecil
H
12

just seperate them with an space inbetween

SYSTEMD_SERVICE_${PN} = "app2.service update.service"

I found the solution in the nfs-utils recipe

yocto systemd documentation

Services are set up to start on boot automatically unless you have set SYSTEMD_AUTO_ENABLE to "disable".

Handbarrow answered 5/6, 2019 at 7:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.