1

The rc.subr ${name}_env specifies this for setting environment variable:

${name}_env   A list of environment variables to run command
              with.  This will be passed as arguments to
              env(1) utility.

So I tried using it like these methods, via my rc.conf for my daemon named /etc/rc.d/mydaemon.

in /etc/rc.conf:

mydaemon_env="MYD_ROOT"

This give error on starting:

# root @ rahul in /etc/rc.d [10:52:49]
$ service mydaemon onestart
Starting mydaemon.
env: MYD_ROOT: No such file or directory
/etc/rc.d/mydaemon: WARNING: failed to start mydaemon

Could someone help out on what I am missing?

2 Answers 2

1

It is supposed to be in format NAME=VALUE.

mydaemon_env="MYD_ROOT=value"
1
  • Ah, so there's no way to make service pick up the environment variable from the shell where it was invoked? Dec 9, 2022 at 6:08
0

A new flag has recently been added to the service command. With the -E flag, it is now possible to set the environment variables when starting a daemon with the service command. The new flag will be available in FreeBSD 14.0 and later. As of 2023-09-04, it has not been merged back into older stable branches.

Some references:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .