ipfs-cluster/docker/entrypoint.sh
Wyatt 07105dbb65 Update docker build, closes #94
Updates dockerfile and entrypoint script to have the same behavior the ipfs-go docker build
moved to in 3477.  This fixes a bug where the cluster entrypoint script does not have
sufficient permissions to access /data/ipfs. The entrypoint also now launches a process with
tini
2017-05-02 17:37:18 -07:00

39 lines
996 B
Bash

#!/bin/sh
set -e
user=ipfs
repo="$IPFS_PATH"
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" "$@"
fi
# Second invocation with regular user
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 $@