On 17/07/2023 20.58, Zhenfu Shi wrote:
> I’m looking for a way to import environment variables for a process started 
> by launchd. systemd on Linux has EnvironmentFile key which allows env vars to 
> be read from a file, can launchd do something similar?
> I’m asking this because my cloudflared port has command line options 
> hardcoded into its launchd script which gets overwritten on every upgrade. If 
> I can somehow make those options read in from another file I can make them 
> configuable to the users.

Unfortunately, I do not think this is easily possible with launchd.

The only solution I can think of would be to wrap it with a shell script. Or 
use an external start script that reads the arguments from a file.

<key>ProgramArguments</key>
<array>
    <string>/bin/sh</string>
    <string>-c</string>
    <string>source /opt/local/etc/foo/options && exec /opt/local/bin/foo 
$FOO_OPTIONS</string>
</array>


Rainer

Reply via email to