entrypoint.sh 910 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. export IPFS_CONFIG_PATH="$IPFS_PATH/config"
  3. function ipfs_config_jq_edit {
  4. tmp=$(mktemp)
  5. (set -x; jq "$@" < "$IPFS_CONFIG_PATH" > "$tmp")
  6. mv "$tmp" "$IPFS_CONFIG_PATH"
  7. }
  8. if [ ! -e "$IPFS_CONFIG_PATH" ]; then
  9. (set -x; ipfs init --empty-repo --profile $IPFS_INIT_PROFILE)
  10. fi
  11. if [ "$IPFS_API_ADDR" != "default" ]; then
  12. ipfs_config_jq_edit '.Addresses.API = $ARGS.positional[0]' --args "$IPFS_API_ADDR"
  13. fi
  14. if [ "$IPFS_SWARM_ADDRS" != "default" ]; then
  15. # + ipfs config --json Addresses.Swarm '["/ip4/0.0.0.0/tcp/4001"]'
  16. # Error: api not running
  17. ipfs_config_jq_edit '.Addresses.Swarm |= $ARGS.positional' --args $IPFS_SWARM_ADDRS
  18. fi
  19. if [ ! -z "$IPFS_BOOTSTRAP_ADD" ]; then
  20. # + ipfs bootstrap add -- /dnsaddr/...
  21. # Error: api not running
  22. ipfs_config_jq_edit '.Bootstrap |= (. + $ARGS.positional | unique)' --args $IPFS_BOOTSTRAP_ADD
  23. fi
  24. (set -x; exec "$@")