All of lore.kernel.org
 help / color / mirror / Atom feed
* just want to confirm my understanding of how systemd services get symlinks
@ 2021-10-04 18:02 Robert P. J. Day
  2021-10-17 14:07 ` [OE-core] " Mark Jonas
  0 siblings, 1 reply; 2+ messages in thread
From: Robert P. J. Day @ 2021-10-04 18:02 UTC (permalink / raw)
  To: OE Core mailing list


  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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [OE-core] just want to confirm my understanding of how systemd services get symlinks
  2021-10-04 18:02 just want to confirm my understanding of how systemd services get symlinks Robert P. J. Day
@ 2021-10-17 14:07 ` Mark Jonas
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Jonas @ 2021-10-17 14:07 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: OE Core mailing list

Hi Robert,

On Mon, Oct 4, 2021 at 8:02 PM Robert P. J. Day <rpjday@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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-17 14:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-04 18:02 just want to confirm my understanding of how systemd services get symlinks Robert P. J. Day
2021-10-17 14:07 ` [OE-core] " Mark Jonas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.