#!/usr/bin/env bash # Script for generating configuration files and network presets for # Logos Storage. set -euo pipefail echoerr() { echo "[storage_config] $1" >&2 } # Needs bash 4 or higher if ((${BASH_VERSION:-0} < 4)); then echoerr "Error: This script requires Bash 4 or higher." exit 1 fi # Needs jq if ! command -v jq &> /dev/null; then echoerr "Error: jq is not installed" exit 1 fi # Valid networks declare -A _networks _networks=([dev]="Logos devnet" [test]="Logos testnet") check_network() { local network=$1 if [[ -z "${_networks[$network]+x}" ]]; then echoerr "Invalid network: $network. Use one of: ${!_networks[*]}" exit 1 fi } raw_data() { local network=$1 check_network "$network" curl -s "https://fleets.logos.co/logos-${network}/storage-network.json" } mix_pool_json() { local network=$1 check_network "$network" raw_data "$network" | jq -c '{ "version": 1, "relays": map({ "peerId": .peerId, "mixPubKey": .mixPubKey, "libp2pPubKey": .libp2pPubKey, "multiAddr": "/ip4/\(.address)/tcp/\(.port)", }) }' } bootstrap_sprs() { local network="$1" check_network "$network" raw_data "$network" | jq '[.[].spr]' } mix_proxy_sprs() { local network="$1" check_network "$network" raw_data "$network" | jq '[.[].tcpSpr]' } full_config() { local network="$1" check_network "$network" cat < [network] Generates configuration files and network presets for Logos Storage. Commands: raw_data Fetch raw storage-network data from fleets.logos.co mix_pool_json Generate mix pool JSON configuration bootstrap_sprs List bootstrap SPRs mix_proxy_sprs List mix proxy SPRs full_config Generate full node configuration JSON presets Generate network presets JSON for all networks Networks: ${!_networks[*]} Examples: $0 bootstrap_sprs dev $0 full_config dev $0 presets EOF } if [[ $# -eq 0 ]]; then usage exit 0 fi echoerr "Running command: $*" "$@" | jq . echoerr "Done."