Commit 9fc7dfbd authored by Stephen Sugden's avatar Stephen Sugden

Template plist to work around launchd limitations

`launchd` doesn't allow you to *use* environment variables. Nor does it support
tilde-expansion of program names & arguments after OSX 10.10.

To work around this, I've made the plist file a template and included a small
install script that will interpolate the correct values.
parent 904ce108
# ipfs launchd agent
A bare-bones launchd agent file for ipfs. To have launchd automatically run the ipfs daemon for you, do the following:
mkdir -p ~/Library/LaunchAgents
cp misc/launchctl/io.ipfs.ipfs-daemon.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/io.ipfs.ipfs-daemon.plist
A bare-bones launchd agent file for ipfs. To have launchd automatically run the ipfs daemon for you, run `./misc/launchd/install.sh`
Note that the `ipfs` binary must be on the *system* PATH for this to work. Adding a symlink in /usr/bin works well enough for me.
#!/bin/bash
src_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
plist=io.ipfs.ipfs-daemon.plist
dest_dir="$HOME/Library/LaunchAgents"
IPFS_PATH="${IPFS_PATH:-$HOME/.ipfs}"
escaped_ipfs_path=$(echo $IPFS_PATH|sed 's/\//\\\//g')
mkdir -p "$dest_dir"
sed 's/{{IPFS_PATH}}/'"$escaped_ipfs_path"'/g' \
"$src_dir/$plist" \
> "$dest_dir/$plist"
launchctl list | grep ipfs-daemon >/dev/null
if [ $? ]; then
echo Unloading existing ipfs-daemon
launchctl unload "$dest_dir/$plist"
fi
echo Loading ipfs-daemon
launchctl load "$dest_dir/$plist"
launchctl list | grep ipfs-daemon
......@@ -11,12 +11,17 @@
<string>ipfs</string>
<string>daemon</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>IPFS_PATH</key>
<string>{{IPFS_PATH}}</string>
</dict>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/usr/local/var/log/ipfs.err</string>
<string>{{IPFS_PATH}}/logs/stderr.log</string>
<key>StandardOutPath</key>
<string>/usr/local/var/log/ipfs.log</string>
<string>{{IPFS_PATH}}/logs/stdout.log</string>
</dict>
</plist>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment