Score:0

How to pass environment variables with FreeBSD service command?

sn flag

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?

Score:1
jp flag

It is supposed to be in format NAME=VALUE.

mydaemon_env="MYD_ROOT=value"
Rahul Bharadwaj avatar
sn flag
Ah, so there's no way to make `service` pick up the environment variable from the shell where it was invoked?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.