I’m using a private IPFS swarm to push out OS updates to some lab equipment. IPFS is not usually running, so my update script has to launch ipfs daemon
and then ipfs pin add ...
the data I want to get.
Since ipfs daemon
runs in the foreground, I have a challenge finding out when IPFS is ready to accept commands. I’m essentially doing this:
#!/bin/bash
ipfs daemon --enable-gc & # backgrounded
ipfs pin add $CID
Since the daemon takes some time to start-up, the ipfs pin
command fails. Sure, I could add a sleep, but that’s a hack.
Is there a way to make ipfs pin
block until it succeeds, or some other means to wait for the daemon to be ready?
I tried the following, but it doesn’t work unless I remove the redirects:
#!/bin/bash
ipfs daemon --enable-gc & # backgrounded
until ipfs stats bitswap &>/dev/null
do
sleep 1
done
ipfs pin add $CID
If I remove the &>/dev/null
redirect it seems to work, but of course it outputs some lines to the screen. Especially when the daemon is starting up and the lock is held.