|
@@ -6,38 +6,28 @@ set -eu
|
|
|
ipfs_config_jq_edit() {
|
|
|
tmp=$(mktemp)
|
|
|
(set -x; jq "$@" < "$IPFS_CONFIG_PATH" > "$tmp")
|
|
|
+
|
|
|
mv "$tmp" "$IPFS_CONFIG_PATH"
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-args_to_json_array() {
|
|
|
- if [ -z "$@" ]; then
|
|
|
- printf '[]\n'
|
|
|
- else
|
|
|
- printf '%s\n' "$@" | jq -R . | jq -sc .
|
|
|
- fi
|
|
|
-}
|
|
|
-
|
|
|
if [ ! -e "$IPFS_CONFIG_PATH" ]; then
|
|
|
(set -x; ipfs init --empty-repo --profile $IPFS_INIT_PROFILE)
|
|
|
fi
|
|
|
|
|
|
if [ "$IPFS_API_ADDR" != "default" ]; then
|
|
|
- ipfs_config_jq_edit '.Addresses.API = $ARGS[0]' --argjson ARGS "$(args_to_json_array "$IPFS_API_ADDR")"
|
|
|
+ ipfs_config_jq_edit '.Addresses.API = $ARGS.positional[0]' --args "$IPFS_API_ADDR"
|
|
|
fi
|
|
|
|
|
|
if [ "$IPFS_SWARM_ADDRS" != "default" ]; then
|
|
|
|
|
|
|
|
|
- ipfs_config_jq_edit '.Addresses.Swarm |= $ARGS' --argjson ARGS "$(args_to_json_array $IPFS_SWARM_ADDRS)"
|
|
|
+ ipfs_config_jq_edit '.Addresses.Swarm |= $ARGS.positional' --args $IPFS_SWARM_ADDRS
|
|
|
fi
|
|
|
|
|
|
if [ ! -z "$IPFS_BOOTSTRAP_ADD" ]; then
|
|
|
|
|
|
|
|
|
- ipfs_config_jq_edit '.Bootstrap |= (. + $ARGS | unique)' --argjson ARGS "$(args_to_json_array $IPFS_BOOTSTRAP_ADD)"
|
|
|
+ ipfs_config_jq_edit '.Bootstrap |= (. + $ARGS.positional | unique)' --args $IPFS_BOOTSTRAP_ADD
|
|
|
fi
|
|
|
|
|
|
(set -x; exec "$@")
|