mirror of
https://github.com/ipfs/kubo.git
synced 2025-10-24 15:12:55 +08:00
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.
This commit is contained in:
@ -1,9 +1,5 @@
|
||||
# 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.
|
||||
|
||||
23
misc/launchd/install.sh
Executable file
23
misc/launchd/install.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user