[systemd-devel] Is it possible to load unit files from paths other than default paths ?

Raghavendra. H. R raghuhr84 at gmail.com
Mon Sep 26 09:00:37 UTC 2016


Andrei,

How to set SYSTEMD_UNIT_PATH in Systemd ?

I checked about systemd source code in github. Please see this link

https://github.com/search?q=org%3Asystemd+systemd_unit_path&type=Code

Even in these source files they are doing getenv and setenv for
SYSTEMD_UNIT_PATH. I dont see any conf file using which we can configure
the environment variable.


Regards,
Raghu.


--
Regards,

Raghavendra. H. R
(Raghu)

On Mon, Sep 26, 2016 at 1:59 PM, Andrei Borzenkov <arvidjaar at gmail.com>
wrote:

> On Mon, Sep 26, 2016 at 10:59 AM, Raghavendra. H. R <raghuhr84 at gmail.com>
> wrote:
> > These are instructions which I tried.
> >
> > mkdir -p /BingoDast
> > mount -t nfs -o nolock <ip_address>:/tftpboot/raghu/BingoDast /BingoDast
> >
> > export PATH=$PATH:/BingoDast/bin
> > export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/BingoDast/lib
> > export SYSTEMD_UNIT_PATH=/BingoDast/units
> > echo $SYSTEMD_UNIT_PATH
> > /BingoDast/units
> >
> > systemctl start bingod.service
> > Failed to start bingod.service: Unit bingod.service failed to load: No
> such
> > file or directory.
> >
>
> SYSTEMD_UNIT_PATH has to be set in environment of systemd, not systemctl.
>
> > Other options which I tried for setting SYSTEMD_UNIT_PATH are given
> below.
> >
> > 1. Just gave the environment variable directly on the console
> >  SYSTEMD_UNIT_PATH=/BingoDast/units
> >
> > 2. Gave the environment variable along with DefaultEnvinronment tag
> >  DefaultEnvironment=SYSTEMD_UNIT_PATH=/BingoDast/units
> >
> >
> > Regards,
> > Raghu
> >
> >
> > --
> > Regards,
> >
> > Raghavendra. H. R
> > (Raghu)
> >
> > On Mon, Sep 26, 2016 at 1:07 PM, Andrei Borzenkov <arvidjaar at gmail.com>
> > wrote:
> >>
> >> On Mon, Sep 26, 2016 at 10:06 AM, Raghavendra. H. R <
> raghuhr84 at gmail.com>
> >> wrote:
> >> > But SYTEMD_UNIT_PATH isn't working. I added my executables path for
> this
> >> > env
> >> > variable but whatever I add isn't reflected for this variable. If I do
> >> > echo
> >>
> >> Repeating this 100 times won't make it more clear. I already asked you
> >> to paste exact commands and their output that you used to "add your
> >> path for this env variable".
> >>
> >> > of $SYSTEMD_UNIT_PATH. Its all empty. My executables are not able to
> >> > find
> >> > the path and it is not running.
> >> >
> >> > --
> >> > Regards,
> >> >
> >> > Raghavendra. H. R
> >> > (Raghu)
> >> >
> >> > On Thu, Sep 22, 2016 at 12:26 PM, Andrei Borzenkov <
> arvidjaar at gmail.com>
> >> > wrote:
> >> >>
> >> >> On Thu, Sep 22, 2016 at 9:18 AM, Raghavendra. H. R
> >> >> <raghuhr84 at gmail.com>
> >> >> wrote:
> >> >> > Thank you for the suggestions.
> >> >> > But with this suggestion i.e., generator file, I again need to
> >> >> > add/modify
> >> >> > some files.
> >> >> >
> >> >>
> >> >> You need to add/modify some files to implement your service anyway. I
> >> >> do not see how one more file is a problem so far.
> >> >>
> >> >> > All I'm looking into is I mount my binaries and unit files under
> >> >> > /mnt.
> >> >> > By
> >> >> > setting any environment variable like SYSTEMD_UNIT_PATH, systemd
> >> >> > should
> >> >> > pick
> >> >> > the unit files from /mnt and execute my binaries as per the
> >> >> > instructions
> >> >> > given in unit file.
> >> >> >
> >> >>
> >> >> Which is exactly what it does. You just need to set variable in
> >> >> environment of systemd.
> >> >>
> >> >> > In normal init.d systems, we have environment variables like PATH &
> >> >> > LD_LIBRARY_PATH.
> >> >> > No matter where I place my new executable or library, adding new
> path
> >> >> > into
> >> >> > these environment variables is enough to execute or link the
> library.
> >> >> >
> >> >> > Probably this kind of facility is not available in Systemd init
> >> >> > systems.
> >> >> >
> >> >> > --
> >> >> > Regards,
> >> >> >
> >> >> > Raghavendra. H. R
> >> >> > (Raghu)
> >> >> >
> >> >> > On Wed, Sep 21, 2016 at 10:40 PM, Andrei Borzenkov
> >> >> > <arvidjaar at gmail.com>
> >> >> > wrote:
> >> >> >>
> >> >> >> 21.09.2016 14:26, Raghavendra. H. R пишет:
> >> >> >> > Hi,
> >> >> >> >
> >> >> >> > I'm newbie with systemd boot system and I need help in resolving
> >> >> >> > one
> >> >> >> > issue.
> >> >> >> >
> >> >> >> > I would like to create a service under a customized path Eg:/mnt
> >> >> >> > and
> >> >> >> > systemd should be able to pick my unit file from this.
> >> >> >> >
> >> >> >> > I tried by setting *Environment=SYSTEMD_UNIT_PATH=/mnt *from
> the
> >> >> >> > console
> >> >> >>
> >> >> >> This should be set in environment of srarted systemd, which in
> case
> >> >> >> of
> >> >> >> systemwide init effectively means either you need to use some
> >> >> >> wrapper
> >> >> >> to
> >> >> >> set it and exec systemd or hack initrd.
> >> >> >>
> >> >> >> Also SYSTEMD_UNIT_PATH does not really play nicely with priorities
> >> >> >> of
> >> >> >> unit locations (run-time vs. sysadmin vs. shipped).
> >> >> >>
> >> >> >> May be it is simpler to install generator that copies your unit
> >> >> >> definition in standard location. This guarantees it is available
> >> >> >> before
> >> >> >> systemd starts.
> >> >> >
> >> >> >
> >> >
> >> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20160926/9b3f1315/attachment.html>


More information about the systemd-devel mailing list