[yocto] Fwd: With my layer, Systemd not invoking my application at startup

Vipin Nair vipin.jn at gmail.com
Tue Jun 30 20:35:57 PDT 2015


Hi All,

I have  created a layer (my first layer) and have build it with WindRiver
media which uses Systemd for the startup services.

As per my application need, I have to create a new user on the final image
and change the owner permissions of certain files to the new user.
Since I could not get it done on the build machine, I have written the post
install script such that it gets executed on the  target board during the
1st boot cycle
and from within the post install script I am creating the new user and
changing the file ownership. And this works.

But the only problem I have now is that, even though I register my service
with Systemd at pre-install (or postinstall) section (using the systemctl
enable command)
my service is not getting launched by Systemd during the 1st boot. On
subsequent reboots, it invokes my service at boot up.

As part of debugging I just modified my postinstall script, such that it
gets executed on the board (i.e without the exit 1)  and not executed on
the 1st boot. After that I see that
systemd invokes my service at boot up.  So I wonder if Systemd ignores the
services for which post-install is not invoked at build machine ?

Now I am confused on how to solve this problem.

Only 2 approaches comes to my mind :
1) Run the postinstall on the board only (not on 1st boot)  - But with this
(i.e running the postinstall section on board) I don't see the new user
creation happening and as a result it fails to change the file ownership.

2) Somehow force systemd to invoke my service at startup (even with
postinstall running during 1st boot)  - But I don't know what I have to do
to achieve this.

Here is the brief of my recipe file :
-----------------------------------------------

DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd',
'systemd-systemctl-native', '', d)}"


do_install() {
------------
------------
#if systemd configured
install -m 0755 -d ${D}/lib/systemd/system
cp ${WORKDIR}/${MA_BIN_DIR}/my_ser.service ${D}/lib/systemd/system/
------------
------------
}

pkg_preinst_${PN}() {
------------
------------

if [  "$IS_SYSTEMD_CONFIGURED" = "yes" ] ; then
systemctl --root=$D enable my_ser.service    # Have tried executing it only
on postinstall, but it does not help.
fi
------------
------------
}

pkg_postinst_${PN}() {
------------
------------
if [  "$IS_SYSTEMD_CONFIGURED" = "yes" ] ; then
systemctl --root=$D enable ma.service
fi
 if [ x"$D" = "x" ] ; then
 # Create group and user
groupadd test_grp
useradd -r -s /sbin/nologin -g  test_grp test_usr
 chown test_usr:test_grp /etc/test_folder/*
 if [  "$IS_SYSTEMD_CONFIGURED" = "yes" ] ; then
if [ "$1" == 1 ] || [ "$1" = 2 ] ; then  # only install and upgrade
scenario, not to exeute on 1st boot
systemctl daemon-reload
systemctl start my_ser.service
fi
else
exit 1
fi
}

I am new to the yacto project and the layer approach. So kindly guide me on
how to resolve this issue.

Also if this is not the right group to get help on this issue, please
suggest about the relevant group.

Thanks
Vipin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20150701/70b3990f/attachment.html>


More information about the yocto mailing list