entrypoint.sh 865 B

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