11 replies
Sign in or join Beachball Help to reply.
- 0
Camelot ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Edit /etc/launchd.plist (or create it if it doesn't exist) and add a line:
setenv YOUR
ENVVARIABLE /some/valueThis file is read by
launchd when the system boots and any environment variables set there are available for all processes. - 0
Gnarlodious ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
OOPS, I marked that as solved but it is only working on my home computer. Apparently the file is not loaded until a GUI starts up. So it does not work on my server.
- 0
Camelot ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Apparently the file is not loaded until a GUI starts up. So it does not work on my server.
Not so. /etc/launchd.conf should be loaded first at boot time.
launchd is responsible for the entire boot process - launching all background tasks and services. As such it has to read its configuration file at boot.
Now it is possible for an
individual to have their own
launchd.plist file that is loaded when they log in, but that would have to be stored in their home directory, not in /etc/Did you check permissions on the file? Or the logs?
It wouldn't surprise me to find that launchd won't load the file if it's world-writable since that could constitute a security violation (you don't want just anyone adding entries to this file). That could explain why it didn't load at boot.
- 0
Gnarlodious ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
The file has root:wheel 644, exact same as my home computer. So I don't get it.
- 0
Gnarlodious ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
OK, so I can log into the GUI with Remote Desktop and I get the variable in Terminal. Both in root and a user account. However, still no variable in ssh.
So I think you are wrong.
After much Googling and reading pages that say it is inordinately difficult to do what I want to do (in OSX), I am starting to agree. Ironically, this is about the simplest thing to do on any Linux box.
- 0
V.K. ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Camelot wrote:
Edit /etc/launchd.plistthat should be /etc/launchd.conf not /etc/launchd.plist, I think.
(or create it if it doesn't exist) and add a line:
setenv YOUR
ENVVARIABLE /some/valueThis file is read by
launchd when the system boots and any environment variables set there are available for all processes. - 0
Gnarlodious ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Yeah, I caught that error and made the correction. A .plist file is always XML.
- 0
Camelot ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
that should be /etc/launchd.conf not /etc/launchd.plist, I think.
You're right, V.K. - thanks for catching that one! 🙂
- 0
Jeffrey Jones2 ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
A .plist file is always XML.
If this is intended to be a general statement, then it is false. plists can have several formats. In recent editions of OS X, most preference files are binary.
- 0
Gnarlodious ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
> Not so. /etc/launchd.conf should be loaded first at boot time.
If that is true, the only explanation is that it must be a bug.
- 0
V.K. ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Gnarlodious wrote:
> Not so. /etc/launchd.conf should be loaded first at boot time.
If that is true, the only explanation is that it must be a bug.
I tested it and it does indeed work as you say. when I ssh into a computer, variables set in /etc/launchd.conf are not loaded. I don't know enough about these things to judge if it's a bug or if that's how it should be (I suspect the latter). but in any case if you need some variables to load when you ssh you can just add them to the global shell configuration files. for example, if you ssh into an account whose login shell is bash, add the following line to /etc/.profile
export YOURENVVARIABLE=some-valueif you need to you can do the corresponding things for global configuration files for other shells. the syntax will vary depending on the shell of course.
I strongly suspect there is a better way to do this but the above should work.