All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saul Wold <sgw@linux.intel.com>
To: Vipin Nair <vipin.jn@gmail.com>, yocto@yoctoproject.org
Subject: Re: With my layer, Systemd not invoking my application at startup
Date: Wed, 01 Jul 2015 09:44:33 -0700	[thread overview]
Message-ID: <559418F1.1060704@linux.intel.com> (raw)
In-Reply-To: <CAFYg0Uq1yqubKPyn2r36h1xXRLTVQvzCvx=hYO3FvGpJzr1pfQ@mail.gmail.com>

On 06/30/2015 08:35 PM, Vipin Nair wrote:
> 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

It appears you did not try to use the useradd bbclass here.

>   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.
>
If you can send your full bb file, are you using the systemd bbclass as 
I suggested in a past email?

Sau!


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


  reply	other threads:[~2015-07-01 16:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAFYg0UpeehEy41ethe90thM+hL3EzkPZWcuKJ_3OS2hN4kuESQ@mail.gmail.com>
2015-07-01  3:35 ` With my layer, Systemd not invoking my application at startup Vipin Nair
2015-07-01 16:44   ` Saul Wold [this message]
2015-07-02  6:24     ` Vipin Nair
2015-07-02  6:27 ` Vipin Nair

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=559418F1.1060704@linux.intel.com \
    --to=sgw@linux.intel.com \
    --cc=vipin.jn@gmail.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.