2017-03-06 15:29:23 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2017-04-28 00:12:53 +00:00
|
|
|
set -e
|
2017-11-23 13:40:49 +00:00
|
|
|
user=ipfs
|
|
|
|
|
2017-10-31 10:46:32 +00:00
|
|
|
if [ -n "$DOCKER_DEBUG" ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
2017-03-06 15:29:23 +00:00
|
|
|
|
2017-04-28 00:12:53 +00:00
|
|
|
if [ `id -u` -eq 0 ]; then
|
2017-10-20 10:13:49 +00:00
|
|
|
echo "Changing user to $user"
|
2017-04-28 00:12:53 +00:00
|
|
|
# ensure directories are writable
|
2017-10-20 10:13:49 +00:00
|
|
|
su-exec "$user" test -w "${IPFS_CLUSTER_PATH}" || chown -R -- "$user" "${IPFS_CLUSTER_PATH}"
|
2017-10-31 10:46:32 +00:00
|
|
|
exec su-exec "$user" "$0" $@
|
2017-03-06 15:29:23 +00:00
|
|
|
fi
|
|
|
|
|
2017-11-23 13:40:49 +00:00
|
|
|
# Only ipfs user can get here
|
2017-03-06 15:29:23 +00:00
|
|
|
ipfs-cluster-service --version
|
|
|
|
|
2017-10-20 10:13:49 +00:00
|
|
|
if [ -e "${IPFS_CLUSTER_PATH}/service.json" ]; then
|
|
|
|
echo "Found IPFS cluster configuration at ${IPFS_CLUSTER_PATH}"
|
2017-03-06 15:29:23 +00:00
|
|
|
else
|
2018-04-26 18:02:10 +00:00
|
|
|
echo "This container only runs ipfs-cluster-service. ipfs needs to be run separately!"
|
|
|
|
echo "Initializing default configuration"
|
2017-03-06 15:29:23 +00:00
|
|
|
ipfs-cluster-service init
|
2017-11-23 13:40:49 +00:00
|
|
|
if [ -n "$IPFS_API" ]; then
|
2018-04-26 18:02:10 +00:00
|
|
|
echo "Using \$IPFS_API as value for ipfs_connector.ipfshttp.node_multiaddress in configuration"
|
2017-11-23 13:40:49 +00:00
|
|
|
sed -i "s;/ip4/127\.0\.0\.1/tcp/5001;$IPFS_API;" "${IPFS_CLUSTER_PATH}/service.json"
|
|
|
|
fi
|
2018-04-26 18:02:10 +00:00
|
|
|
|
|
|
|
echo "Warning: By default, the API and Proxy endpoints will listen on 0.0.0.0!"
|
2017-11-23 13:40:49 +00:00
|
|
|
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"
|
2017-03-06 15:29:23 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
exec ipfs-cluster-service $@
|