12345678910111213141516171819202122232425262728293031323334353637 |
- #!/bin/sh
- set -eu
- ipfs_config_jq_edit() {
- tmp=$(mktemp)
- (set -x; jq "$@" < "$IPFS_CONFIG_PATH" > "$tmp")
- mv "$tmp" "$IPFS_CONFIG_PATH"
- }
- args_to_json_array() {
- printf '%s\n' "$@" | jq -R . | jq -sc .
- }
- 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")"
- fi
- if [ "$IPFS_SWARM_ADDRS" != "default" ]; then
-
-
- ipfs_config_jq_edit '.Addresses.Swarm |= $ARGS' --argjson ARGS "$(args_to_json_array $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)"
- fi
- (set -x; exec "$@")
|