Skip to content

Commit

Permalink
Update renew-config.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyfilyanin authored Jul 19, 2024
1 parent adba1fc commit e9c7d74
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions scripts/renew-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,20 @@ production_meta_url="https://github.com/gear-tech/gear/releases/download/v"$tag"

echo "Downloading testnet metadata from $testnet_meta_url"
testnet_metadata=$(curl -L $testnet_meta_url)

if [ $? -ne 0 ]; then
echo "Failed to download testnet metadata"
exit 1
fi

echo "Downloading production metadata from $production_meta_url"
production_metadata=$(curl -L $production_meta_url)

if [ $? -ne 0 ]; then
echo "Failed to download production metadata"
exit 1
fi

# Convert metadata to JSON format if needed
testnet_metadata_json=$(echo "$testnet_metadata" | jq .)
if [ $? -ne 0 ]; then
echo "Failed to parse testnet metadata as JSON"
exit 1
fi

production_metadata_json=$(echo "$production_metadata" | jq .)
if [ $? -ne 0 ]; then
echo "Failed to parse production metadata as JSON"
exit 1
fi

echo "Updating testnet config"
jq --argjson version "$version" --argjson metadata "$testnet_metadata_json" \
jq --arg metadata "$testnet_metadata" --argjson version "$version" \
'.metadataRpc = $metadata | .specVersion = $version' \
"$TESTNET_CONFIG_PATH" > tmp.$$.json \
&& mv tmp.$$.json "$TESTNET_CONFIG_PATH"
Expand All @@ -50,14 +35,10 @@ if [ $? -ne 0 ]; then
fi

echo "Updating mainnet config"
jq --argjson version "$version" --argjson metadata "$production_metadata_json" \
jq --arg metadata "$production_metadata" --argjson version "$version" \
'.metadataRpc = $metadata | .specVersion = $version' \
"$MAINNET_CONFIG_PATH" > tmp.$$.json \
&& mv tmp.$$.json "$MAINNET_CONFIG_PATH"

if [ $? -ne 0 ]; then
echo "Failed to update mainnet config"
exit 1
fi

echo "Configuration update completed successfully"
echo "Failed to update mainnet config

0 comments on commit e9c7d74

Please sign in to comment.