Discussion:
[yocto] Script being installed under /etc/init.d instead of /usr/lib/systemd folder
Dey, Megha
2016-06-09 01:11:35 UTC
Permalink
Hi,

I am trying to use the systemd init system from the existing system. I have added the following to my conf file:
DISTRO_FEATURES_append = " systemd"
VIRTUAL-RUNTIME_init_manager = "systemd"
VIRTUAL-RUNTIME_initscripts = ""
DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit"

I have also added the 'systemd' binary to the INSTALL_APPEND.
When I boot the resulting image, I do see systemd up and running and I am able to start and stop services.

However, I do have a script recipe which is currently placed as a bbappend to initscripts (meta/recipes-core/initscripts/initscript_..bb) in my custom meta layer.

This script even after shifting to systemd, is being placed in the /etc/init.d/ folder, and hence doesn't run on boot. I want this to be placed in the /usr/lib/system.d/ folder instead. How would I be able to do this?

Is it because this script is an append to initscripts, it by default gets installed under /etc/init.d? If so, where should I place the recipe?

Thanks,
Megha
piotr.lewicki
2016-06-14 15:32:53 UTC
Permalink
Take a look at example from my some-recipe.bb
:

inherit systemd

SYSTEMD_SERVICE_${PN} = "some-recipe.service"

do_install_append () {
install -d ${D}${systemd_unitdir}/system
install -m 0644 ${S}/configs/some-recipe.service
${D}${systemd_unitdir}/system
}

First in your recipe inherit from "systemd".
Then install your systemd service file in
"${D}${systemd_unitdir}/system" (there is also a variable for this
directory, I think it's ${systemd_system_unitdir} or something similar).
Remember to create a directory before placing a file there.

In the last step use "SYSTEMD_SERVICE_${PN}" where you specify systemd
services that should be run.

I hope that helps..

Best regards,
Piotr Lewicki
Post by Dey, Megha
Hi,
I am trying to use the systemd init system from the existing system. I
DISTRO_FEATURES_append = " systemd"
VIRTUAL-RUNTIME_init_manager = "systemd"
VIRTUAL-RUNTIME_initscripts = ""
DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit"
I have also added the ‘systemd’ binary to the INSTALL_APPEND.
When I boot the resulting image, I do see systemd up and running and I
am able to start and stop services.
However, I do have a script recipe which is currently placed as a
bbappend to initscripts
(meta/recipes-core/initscripts/initscript_..bb) in my custom meta layer.
This script even after shifting to systemd, is being placed in the
/etc/init.d/ folder, and hence doesn’t run on boot. I want this to be
placed in the /usr/lib/system.d/ folder instead. How would I be able
to do this?
Is it because this script is an append to initscripts, it by default
gets installed under /etc/init.d? If so, where should I place the recipe?
Thanks,
Megha
Burton, Ross
2016-06-14 16:41:23 UTC
Permalink
Post by Dey, Megha
However, I do have a script recipe which is currently placed as a bbappend
to initscripts (meta/recipes-core/initscripts/initscript_..bb) in my custom
meta layer.
This script even after shifting to systemd, is being placed in the
/etc/init.d/ folder, and hence doesn’t run on boot. I want this to be
placed in the /usr/lib/system.d/ folder instead. How would I be able to do
this?
sysv-style init scripts go into /etc/init.d, systemd units do into
/lib/system.d As this is your append then it is up to you to place the
file in the right location.

If you're installing a traditional init script then /etc/init.d is the
right place for it to be installed, if you're attempting to install a
systemd unit then look at the documentation for the systemd class.

Ross

Loading...