From 5ed2322772c361cc8e5f902d43f8afa08a50751f Mon Sep 17 00:00:00 2001 From: Jonathan Dahan Date: Wed, 16 Dec 2015 11:31:55 -0500 Subject: [PATCH 1/2] Have install.sh use the full path to ipfs binary if detected License: MIT Signed-off-by: Jonathan Dahan --- misc/launchd/README.md | 1 - misc/launchd/install.sh | 6 +++++- misc/launchd/io.ipfs.ipfs-daemon.plist | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/misc/launchd/README.md b/misc/launchd/README.md index cd4d6207ee6..c9d30c9cad5 100644 --- a/misc/launchd/README.md +++ b/misc/launchd/README.md @@ -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. diff --git a/misc/launchd/install.sh b/misc/launchd/install.sh index 3d18e852664..7a02d3f9083 100755 --- a/misc/launchd/install.sh +++ b/misc/launchd/install.sh @@ -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" diff --git a/misc/launchd/io.ipfs.ipfs-daemon.plist b/misc/launchd/io.ipfs.ipfs-daemon.plist index e7bf9a6e3c5..72d4cf716f0 100644 --- a/misc/launchd/io.ipfs.ipfs-daemon.plist +++ b/misc/launchd/io.ipfs.ipfs-daemon.plist @@ -8,7 +8,7 @@ io.ipfs.ipfs-daemon ProgramArguments - ipfs + {{IPFS_BIN}} daemon EnvironmentVariables From 966cd8b7c7759e440ec3fe5d95687b8a44a3d954 Mon Sep 17 00:00:00 2001 From: Jonathan Dahan Date: Wed, 16 Dec 2015 11:32:09 -0500 Subject: [PATCH 2/2] Install daemon system-wide if on El Capitan License: MIT Signed-off-by: Jonathan Dahan --- misc/launchd/install.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/misc/launchd/install.sh b/misc/launchd/install.sh index 7a02d3f9083..247bd2499c3 100755 --- a/misc/launchd/install.sh +++ b/misc/launchd/install.sh @@ -23,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