#!/usr/bin/with-contenv bash if [[ ! -d "$IPFS_PATH" ]]; then ipfs init # remove default bootstraps ipfs bootstrap rm --all # enable Private Network feature by copying swarm.key to $IPFS_PATH # https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#private-networks cp /defaults/ipfs_preshared_swarm.key $IPFS_PATH/swarm.key # to check that Private Network is enabled, look for a line # 'Swarm is limited to private network of peers with the swarm key' # in IPFS logs fi if [[ "$IPFS_MIGRATE_FS" == true ]]; then fs-repo-migrations -y fi to_json() { echo "$1" | jq -Rc 'split(",")' } ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]' ipfs config --json Addresses.API $(to_json ${IPFS_ADDRESSES_API}) ipfs config --json Addresses.Gateway $(to_json ${IPFS_ADDRESSES_GATEWAY}) ipfs config --json Addresses.Swarm $(to_json ${IPFS_ADDRESSES_SWARM}) ipfs config --json Addresses.Announce $(to_json ${IPFS_ADDRESSES_ANNOUNCE}) mkdir -p $IPFS_PATH $IPFS_LOG_DIR chown -R abc:abc $IPFS_PATH $IPFS_LOG_DIR