Skip to content

Commit

Permalink
Merge pull request #2072 from jedahan/smarter-launchd-install
Browse files Browse the repository at this point in the history
Have install.sh put the full path to ipfs binary if detected
  • Loading branch information
jbenet committed Dec 17, 2015
2 parents df65bae + 966cd8b commit fb8189d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 0 additions & 1 deletion misc/launchd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

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.
13 changes: 11 additions & 2 deletions misc/launchd/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ dest_dir="$HOME/Library/LaunchAgents"
IPFS_PATH="${IPFS_PATH:-$HOME/.ipfs}"
escaped_ipfs_path=$(echo $IPFS_PATH|sed 's/\//\\\//g')

IPFS_BIN=$(which ipfs || echo ipfs)
escaped_ipfs_bin=$(echo $IPFS_BIN|sed 's/\//\\\//g')

mkdir -p "$dest_dir"

sed 's/{{IPFS_PATH}}/'"$escaped_ipfs_path"'/g' \
sed -e 's/{{IPFS_PATH}}/'"$escaped_ipfs_path"'/g' \
-e 's/{{IPFS_BIN}}/'"$escaped_ipfs_bin"'/g' \
"$src_dir/$plist" \
> "$dest_dir/$plist"

Expand All @@ -19,5 +23,10 @@ if [ $? ]; then
fi

echo Loading ipfs-daemon
launchctl load "$dest_dir/$plist"
if [[ `sw_vers -productVersion` == 10.1* ]]; then
sudo chown root "$dest_dir/$plist"
sudo launchctl bootstrap system "$dest_dir/$plist"
else
launchctl load "$dest_dir/$plist"
fi
launchctl list | grep ipfs-daemon
2 changes: 1 addition & 1 deletion misc/launchd/io.ipfs.ipfs-daemon.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<string>io.ipfs.ipfs-daemon</string>
<key>ProgramArguments</key>
<array>
<string>ipfs</string>
<string>{{IPFS_BIN}}</string>
<string>daemon</string>
</array>
<key>EnvironmentVariables</key>
Expand Down

0 comments on commit fb8189d

Please sign in to comment.