Răsfoiți Sursa

swarm addrs config: fix failure when api not running

Fabian Peter Hammerle 5 ani în urmă
părinte
comite
1b3b0f25e6
1 a modificat fișierele cu 8 adăugiri și 3 ștergeri
  1. 8 3
      entrypoint.sh

+ 8 - 3
entrypoint.sh

@@ -1,12 +1,17 @@
 #!/bin/sh
 
-if [ ! -e "$IPFS_PATH/config" ]; then
+export IPFS_CONFIG_PATH="$IPFS_PATH/config"
+
+if [ ! -e "$IPFS_CONFIG_PATH" ]; then
     (set -x; ipfs init --empty-repo --profile $IPFS_INIT_PROFILE)
 fi
 
 if [ "$IPFS_SWARM_ADDRS" != "default" ]; then
-    addrs_json=$(jq --null-input --compact-output '$ARGS.positional' --args $IPFS_SWARM_ADDRS)
-    (set -x; ipfs config --json Addresses.Swarm "$addrs_json")
+    # + ipfs config --json Addresses.Swarm '["/ip4/0.0.0.0/tcp/4001"]'
+    # Error: api not running
+    tmp=$(mktemp)
+    (set -x; jq '.Addresses.Swarm |= $ARGS.positional' --args $IPFS_SWARM_ADDRS <"$IPFS_CONFIG_PATH" >$tmp)
+    mv $tmp "$IPFS_CONFIG_PATH"
 fi
 
 if [ ! -z "$IPFS_BOOTSTRAP_ADD" ]; then