Hi Robert,

On Mon, Oct 4, 2021 at 8:02 PM Robert P. J. Day <rpj...@crashcourse.ca> wrote:
>
>
>   just had a discussion with a colleague about the proper design of a
> systemd-based service, and my (admittedly sophomore) understanding is
> that, in the service file, there is an [Install] section, which
> contains a "WantedBy" line like:
>
>   fubar.service:WantedBy=sysinit.target
>
> upon installation in the image, from systemd.bbclass. the routine
> systemd_postinst() is invoked which (among other things), does this:
>
>         if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
>                 for service in ${SYSTEMD_SERVICE_ESCAPED}; do
>                         systemctl ${OPTS} enable "$service"
>                 done
>         fi
>
> and my understanding is that it is that call to "systemctl" that
> creates the appropriate symlink so that that service now exists under
> the directory "sysinit.target.wants".
>
>   my need for confirmation is based on muh collegaue's pointing at
> some existing systemd-based recipes in some legacy code, which
> manually do the following in do_install_append():
>
>   ln -s ${sysconfdir}/systemd/system/fubar.service \
>     ${D}/${sysconfdir}/systemd/system/sysinit.target.wants/
>
> i'm pretty sure that that "ln" command is unnecessary as long as the
> service file is defined properly, but now i just want to get that
> confirmed.
>
> rday
>
> p.s. hmmmmmm ... i wonder if the original recipe designer was unaware
> of systemd.bbclass and thought he had to do it all manually.

Correct, use an install section and systemd.bbclass and you do not
need to manually link into e.g. sysinit.target.wants. Do not forget to
set SYSTEMD_SERVICE, though.

https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#ref-classes-systemd

I think using the systemd.bbclass is more robust than the manual link.
Additionally, users of your recipe can use SYSTEMD_AUTO_ENABLE to
disable automatic start of the service during boot.

Cheers,
Mark
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#157041): 
https://lists.openembedded.org/g/openembedded-core/message/157041
Mute This Topic: https://lists.openembedded.org/mt/86073990/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to