2017-03-06 15:29:23 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2017-04-28 00:12:53 +00:00
|
|
|
set -e
|
|
|
|
user=ipfs
|
2017-03-06 15:29:23 +00:00
|
|
|
repo="$IPFS_PATH"
|
|
|
|
|
2017-04-28 00:12:53 +00:00
|
|
|
if [ `id -u` -eq 0 ]; then
|
|
|
|
# ensure directories are writable
|
|
|
|
su-exec "$user" test -w "$repo" || chown -R -- "$user" "$repo"
|
|
|
|
su-exec "$user" test -w "$IPFS_CLUSTER_PATH" || chown -R -- "$user" "$IPFS_CLUSTER_PATH"
|
|
|
|
exec su-exec "$user" "$0" "$@"
|
2017-03-06 15:29:23 +00:00
|
|
|
fi
|
|
|
|
|
2017-04-28 00:12:53 +00:00
|
|
|
# Second invocation with regular user
|
2017-03-06 15:29:23 +00:00
|
|
|
ipfs version
|
|
|
|
|
|
|
|
if [ -e "$repo/config" ]; then
|
|
|
|
echo "Found IPFS fs-repo at $repo"
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
|
|
|
exec ipfs-cluster-service $@
|