From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BEFAC433EF for ; Tue, 12 Oct 2021 03:00:15 +0000 (UTC) Received: from mail-ua1-f47.google.com (mail-ua1-f47.google.com [209.85.222.47]) by mx.groups.io with SMTP id smtpd.web08.8472.1634007610960578831 for ; Mon, 11 Oct 2021 20:00:11 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: gmail.com, ip: 209.85.222.47, mailfrom: fede.evol@gmail.com) Received: by mail-ua1-f47.google.com with SMTP id h4so16040578uaw.1 for ; Mon, 11 Oct 2021 20:00:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OmL527CmddVCFsrP5vd0luflnfZSNzGz/MgUr5dYWo4=; b=dxQwNUXDbzFSPhkHo05VDIx+tT2J8OmgBT/Td++YCd2tNr3pe93vH+L+99ASi1EKsW Za/7kVsLLNRzTrZdvbVn32jQgfSJhNuZIzMTeM5g/SS/xFb8ZFA4kGv72s8UoJ/qLBli HAnCcPc+bs6WduQikHp4BD2COfV2PhDsbvWJu9UrM+jdELSt2y1oYDYw3SElym1DF7uZ T5gWSXIG5wUidl6t34TgErvFGnhsJ1hhW8143OnUAmO9jSd5fNr6xLxccqglo3krSSfr Te3u6ybTCRsZS4PhOKuIZ7S4jwk2M/R/to4qZHBBVXgh6KeMcF7dBrAR1ctdeVquyMZ/ rp+g== X-Gm-Message-State: AOAM532Vx8k3460N2HXVQ4O+yc0wxNr/eXl6jvzS361ryVIxAApm7MZJ 4ZPeBy5ojddUoGEvxTm83p85ZKQ/XZmZLGMjw60= X-Google-Smtp-Source: ABdhPJyD2N7qsPfsd7TbqoOam0ZnvvTvdWy6yLLsReNqaIWmxLB8zsU2TsnKfsMEDqcHu0d+u/h1/05tLwg0castfj4= X-Received: by 2002:ab0:36b8:: with SMTP id v24mr11977032uat.112.1634007609857; Mon, 11 Oct 2021 20:00:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Federico Pellegrin Date: Tue, 12 Oct 2021 04:59:58 +0200 Message-ID: Subject: Re: [OE-core] How to trigger Yocto Linux /etc/profile or shell scripts in /etc/profile.d without shell logging in? To: Jupiter Cc: yocto , OE Content-Type: multipart/alternative; boundary="0000000000002559a205ce1f0b02" List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 12 Oct 2021 03:00:15 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/55025 --0000000000002559a205ce1f0b02 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Jupiter, To centralize, agreed that you are using systemd, one way I could see is setting the variables in systemd-system.conf using the DefaultEnvironment directive, see: https://freedesktop.org/software/systemd/man/systemd-system.conf.html This states: ---- DefaultEnvironment=3D=C2=B6 Configures environment variables passed to all executed processes. Takes a space-separated list of variable assignments. See environ(7) for details about environment variables. Simple "%"-specifier expansion is supported, see below for a list of supported specifiers. Example: DefaultEnvironment=3D"VAR1=3Dword1 word2" VAR2=3Dword3 "VAR3=3Dword 5 6" Sets three variables "VAR1", "VAR2", "VAR3". ---- This should have you variables management in each. Otherwise as you mention one can put in each script with either Environment to have them explicitly enumerated or with EnvironmentFile to read from a file, which may also fit your centralization hopes (but still require one line per startup script at least) and could be further sourced by non-systemd components as well if needed. (https://www.freedesktop.org/software/systemd/man/systemd.exec.html under Environment section) HTH, Federico Il giorno lun 11 ott 2021 alle ore 11:05 Jupiter ha scritto: > Hi Federico, > > Thanks for your response. > > > /etc/profile and similar are interactive shell (/bash) concepts, not > really > > system startup ones. So indeed: just on a login (be it local, ssh and s= o > > on) they are executed. > > Understood, here is what I try to figure out. I use several systemd > services to start my tasks, each task is not just a system process, I > found it also has a system environment similar in user login from > /etcprofile, /home/user/.profile, my question is where is a system > environment file that each systemd service runs from? > > I also thought that /etc/profile.d files should be automatically > invoked for each user login, but a systemd service does not run > /etc/profile.d files. > > > If you want to execute something else without the need for logging it, > you > > should look elsewhere, depending on your system manager: if systemd you > > should create a service and enable it, if sysvinit a init.d script. > > Understood, that was what I did originally, I have to run the setup > system environment in each service ExecStart script, that is why I am > looking for a global environment setup file to avoid duplication of > putting my environment scripts in each ExecStart execution file. > > Thank you. > > Kind regards, > > - jupiter > > > HTH, > > Federico > > > > > > Il giorno lun 11 ott 2021 alle ore 06:30 JH ha > > scritto: > > > >> Hi, > >> > >> The Yocto uses /etc/profile for root login, but there is no root > >> physical login in an embedded device so the /etc/profile is never > >> called, I added a shell script to /etc/profile.d, it was not called > >> either. Both /etc/profile and scripts in /etc/profile.d can only be > >> invoked when I physically log into the debug console, that is > >> impractical. Appreciate your advice, how do you resolve that kind of > >> problem? > >> > >> Thank you. > >> > >> Kind regards, > >> > >> - jupiter > >> > >> -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- > >> Links: You receive all messages sent to this group. > >> View/Reply Online (#156808): > >> https://lists.openembedded.org/g/openembedded-core/message/156808 > >> Mute This Topic: https://lists.openembedded.org/mt/86229953/5117409 > >> Group Owner: openembedded-core+owner@lists.openembedded.org > >> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub = [ > >> fede@evolware.org] > >> -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- > >> > >> > > > > > -- > "A man can fail many times, but he isn't a failure until he begins to > blame somebody else." > -- John Burroughs > --0000000000002559a205ce1f0b02 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hi Jupiter,
To centralize, agreed that you are using systemd, one way I could see is s= etting the variables in systemd-system.conf using the DefaultEnvironment di= rective, see: https://freedesktop.org/software/systemd/man/systemd-s= ystem.conf.html

This states:
----
DefaultEnvironment=3D<= /code>=C2=B6

Configures environment var= iables passed to all executed processes. Takes a space-separated list of variable assignments. See environ(7) for details about environment variables.

Simple "%"-specifier expansion is supported, see bel= ow for a list of supported specifiers.

Example:

DefaultEnvironment=3D"=
VAR1=3Dword1 word2" VAR2=3Dword3 "VAR3=3Dword 5 6"

Sets three variables "VAR1", "VAR2", "VAR3".

----

This should have you variables m= anagement in each. Otherwise as you mention one can put in each script with= either Environment to have them explicitly enumerated or with EnvironmentF= ile to read from a file, which may also fit your centralization hopes (but = still require one line per startup script at least) and could be further so= urced by non-systemd components as well if needed. (https://www.freedes= ktop.org/software/systemd/man/systemd.exec.html under Environment secti= on)

HTH,
Federico


Il giorno lun 11 ott 2021 alle ore 11:05 Jupiter <jupiter.hce@gmail.com> ha scritto:
Hi Federico,

Thanks for your response.

> /etc/profile and similar are interactive shell (/bash) concepts, not r= eally
> system startup ones. So indeed: just on a login (be it local, ssh and = so
> on) they are executed.

Understood, here is what I try to figure out. I use several systemd
services to start my tasks, each task is not just a system process, I
found it also has a system environment similar in user login from
/etcprofile, /home/user/.profile, my question is where is a system
environment file that each systemd service runs from?

I also thought that /etc/profile.d files should be automatically
invoked for each user login, but a systemd service does not run
/etc/profile.d files.

> If you want to execute something else without the need for logging it,= you
> should look elsewhere, depending on your system manager: if systemd yo= u
> should create a service and enable it, if sysvinit a init.d script.
Understood, that was what I did originally, I have to run the setup
system environment in each service ExecStart script, that is why I am
looking for a global environment setup file to avoid duplication of
putting my environment scripts in each ExecStart execution file.

Thank you.

Kind regards,

- jupiter

> HTH,
> Federico
>
>
> Il giorno lun 11 ott 2021 alle ore 06:30 JH <jupiter.hce@gmail.com> ha
> scritto:
>
>> Hi,
>>
>> The Yocto uses /etc/profile for root login, but there is no root >> physical login in an embedded device so the /etc/profile is never<= br> >> called, I added a shell script to /etc/profile.d, it was not calle= d
>> either. Both /etc/profile and scripts in /etc/profile.d can only b= e
>> invoked when I physically log into the debug console, that is
>> impractical. Appreciate your advice, how do you resolve that kind = of
>> problem?
>>
>> Thank you.
>>
>> Kind regards,
>>
>> - jupiter
>>
>> -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#156808):
>> https://lists.openembedded= .org/g/openembedded-core/message/156808
>> Mute This Topic: https://lists.openembedd= ed.org/mt/86229953/5117409
>> Group Owner: openembedded-core+owner@lists.openembedded= .org
>> Unsubscribe: https://lists.openembe= dded.org/g/openembedded-core/unsub [
>> fede@evolwa= re.org]
>> -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-
>>
>>
>


--
"A man can fail many times, but he isn't a failure until he begins= to
blame somebody else."
-- John Burroughs
--0000000000002559a205ce1f0b02--