2017-06-16 13:07:08 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
user=ipfs
|
|
|
|
|
|
|
|
if [ `id -u` -eq 0 ]; then
|
2017-10-20 10:13:49 +00:00
|
|
|
echo "Changing user to $user"
|
2017-06-16 13:07:08 +00:00
|
|
|
# ensure directories are writable
|
2017-10-20 10:13:49 +00:00
|
|
|
su-exec "$user" test -w "${IPFS_PATH}" || chown -R -- "$user" "${IPFS_PATH}"
|
|
|
|
su-exec "$user" test -w "${IPFS_CLUSTER_PATH}" || chown -R -- "$user" "${IPFS_CLUSTER_PATH}"
|
2017-06-16 13:07:08 +00:00
|
|
|
exec su-exec "$user" "$0" "$@"
|
|
|
|
fi
|
|
|
|
|
|
|
|
ipfs version
|
|
|
|
|
2017-10-20 10:13:49 +00:00
|
|
|
if [ -e "${IPFS_PATH}/config" ]; then
|
|
|
|
echo "Found IPFS fs-repo at ${IPFS_PATH}"
|
2017-06-16 13:07:08 +00:00
|
|
|
else
|
|
|
|
ipfs init
|
|
|
|
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
|
|
|
|
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
|
|
|
|
fi
|
|
|
|
|
|
|
|
ipfs daemon --migrate=true &
|
|
|
|
sleep 3
|
|
|
|
|
|
|
|
ipfs-cluster-service --version
|
|
|
|
|
|
|
|
if [ -e "$IPFS_CLUSTER_PATH/service.json" ]; then
|
|
|
|
echo "Found IPFS cluster configuration at $IPFS_CLUSTER_PATH"
|
|
|
|
else
|
2017-09-21 22:35:24 +00:00
|
|
|
export CLUSTER_SECRET=""
|
2017-06-16 13:07:08 +00:00
|
|
|
ipfs-cluster-service init
|
|
|
|
sed -i 's/127\.0\.0\.1\/tcp\/9094/0.0.0.0\/tcp\/9094/' "$IPFS_CLUSTER_PATH/service.json"
|
|
|
|
sed -i 's/127\.0\.0\.1\/tcp\/9095/0.0.0.0\/tcp\/9095/' "$IPFS_CLUSTER_PATH/service.json"
|
|
|
|
fi
|
2017-10-20 10:13:49 +00:00
|
|
|
|
2017-06-29 10:34:00 +00:00
|
|
|
ipfs-cluster-service --debug $@ &
|
|
|
|
# Testing scripts that spawn background processes are spawned and stopped here
|
2017-06-20 10:23:11 +00:00
|
|
|
/usr/local/bin/random-stopper.sh &
|
|
|
|
kill -STOP $!
|
|
|
|
echo $! > /data/ipfs-cluster/random-stopper-pid
|
|
|
|
/usr/local/bin/random-killer.sh &
|
|
|
|
kill -STOP $!
|
|
|
|
echo $! > /data/ipfs-cluster/random-killer-pid
|
2017-06-29 10:34:00 +00:00
|
|
|
/usr/local/bin/cluster-restart.sh &
|
|
|
|
kill -STOP $!
|
|
|
|
echo $! > /data/ipfs-cluster/cluster-restart-pid
|
2017-10-20 10:13:49 +00:00
|
|
|
|
2017-06-16 13:07:08 +00:00
|
|
|
echo "Daemons launched"
|
|
|
|
exec tail -f /dev/null
|