github.com/status-im/status-go@v1.1.0/_assets/scripts/update-fleet-config.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  DIR="$(cd $(dirname "$0")/../../config/cli; pwd)"
     4  
     5  echo "Downloading https://fleets.status.im/"
     6  json=$(curl --silent https://fleets.status.im/)
     7  fleets=(
     8      'eth.prod'
     9  )
    10  
    11  wakufleets=(
    12      'status.prod'
    13      'status.staging'
    14      'waku.sandbox'
    15      'waku.test'
    16  )
    17  
    18  # Notify fleet is configured for all fleets.
    19  push=$(echo $json | jq '
    20      .fleets."notify.prod"."tcp/p2p/waku"
    21          | to_entries
    22          | map(.value
    23                | match("enode://([a-z0-9]+)@.*$")
    24                | .captures[0].string
    25      )'
    26  )
    27  
    28  for fleet in "${fleets[@]}"; do
    29      echo "Processing $fleet fleet..."
    30      fleetJSON=$(echo $json | jq ".fleets.\"$fleet\"")
    31      boot=$(echo $fleetJSON | jq ".boot | map(.)" -r)
    32      mail=$(echo $fleetJSON | jq ".mail | map(.)" -r)
    33  
    34  
    35      # Get random nodes from whisper node list
    36      maxStaticNodeCount=3
    37      staticNodeCount=$(echo $fleetJSON | jq ".whisper | length")
    38      index=$(($RANDOM % ($staticNodeCount - ($maxStaticNodeCount - 1))))
    39      whisper=$(echo $fleetJSON | jq ".whisper | map(.) | .[$index:($index + $maxStaticNodeCount)]" -r)
    40  
    41      git checkout $DIR/fleet-$fleet.json \
    42          && jq \
    43                ".ClusterConfig.BootNodes = $boot \
    44               | .ClusterConfig.TrustedMailServers = $mail \
    45               | .ClusterConfig.PushNotificationsServers = $push \
    46               | .ClusterConfig.StaticNodes = $whisper" \
    47               $DIR/fleet-$fleet.json \
    48          | tee "$DIR/tmp.json" >/dev/null \
    49          && mv $DIR/tmp.json $DIR/fleet-$fleet.json
    50  done
    51  
    52  for fleet in "${wakufleets[@]}"; do
    53      echo "Processing $fleet fleet..."
    54      fleetJSON=$(echo $json | jq ".fleets.\"$fleet\"")
    55      waku=$(echo $fleetJSON | jq '."tcp/p2p/waku" | map(.)' -r)
    56  
    57      git checkout $DIR/fleet-$fleet.json \
    58          && jq \
    59                ".ClusterConfig.WakuNodes = $waku \
    60               | .ClusterConfig.PushNotificationsServers = $push" \
    61               $DIR/fleet-$fleet.json \
    62          | tee "$DIR/tmp.json" >/dev/null \
    63          && mv $DIR/tmp.json $DIR/fleet-$fleet.json
    64  done