ipfs-cluster/docker/start-daemons.sh
Hector Sanjuan 4556cbe726 Docker: improve for CRDTs
This:

  * Allows choosing the consensus for the automatic "init" on Docker with
  IPFS_CLUSTER_CONSENSUS.

  * Removes IPFS_PATH and the sed replacements for 0.0.0.0 on RestAPI and
  Ipfsproxy endpoints because these are easily supported by setting env vars
  correctly and pose some security risk when running with net=host.

  * Brings up to date Dockerfile-test and Dockerfile-bundle, even if mostly
  unused.
2019-08-13 19:32:38 +02:00

40 lines
945 B
Bash
Executable File

#!/bin/sh
set -e
if [ -n "$DOCKER_DEBUG" ]; then
set -x
fi
user=ipfs
if [ `id -u` -eq 0 ]; then
echo "Changing user to $user"
# ensure directories are writable
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}"
exec su-exec "$user" "$0" $@
fi
# Second invocation with regular user
ipfs version
if [ -e "${IPFS_PATH}/config" ]; then
echo "Found IPFS fs-repo at ${IPFS_PATH}"
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 --consensus "${IPFS_CLUSTER_CONSENSUS}"
fi
exec ipfs-cluster-service $@