Skip to content

Instantly share code, notes, and snippets.

@goosecoid
Created April 29, 2022 07:33
Show Gist options
  • Save goosecoid/1f308d25f4d59faf386eb5ae20d12f7f to your computer and use it in GitHub Desktop.
Save goosecoid/1f308d25f4d59faf386eb5ae20d12f7f to your computer and use it in GitHub Desktop.
script rename files
#!/bin/bash
# Small script that renames all files according to smart contact name (kvstore or smallbank), txCount & tps
SC="smallbank"
TXCOUNT=2500
TPS=100
NETWORK_URL="wss://fr3.ebsi-orange.eu/node0/ws"
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine="Linux";;
Darwin*) machine="Mac";;
esac
#Change yaml file in docker-compose.yaml
if [ "${machine}" = "Mac" ]
then
sed -i '' "s=CALIPER_BENCHCONFIG\=benchmarks/.*.yaml=CALIPER_BENCHCONFIG\=benchmarks/$SC.yaml=g" docker-compose.yaml
else
sed -i "s=CALIPER_BENCHCONFIG\=benchmarks/.*.yaml=CALIPER_BENCHCONFIG\=benchmarks/$SC.yaml=g" docker-compose.yaml
fi
if [ "${machine}" = "Mac" ] && [ "$SC" = "kvstore" ]
then
sed -i '' "s=txNumber: .*=txNumber: $TXCOUNT=" benchmarks/kvstore.yaml
sed -i '' "s=tps: .*=tps: $TPS=" benchmarks/kvstore.yaml
fi
if [ "${machine}" = "Linux" ] && [ "$SC" = "kvstore" ]
then
sed -i "s=txNumber: .*=txNumber: $TXCOUNT=" benchmarks/kvstore.yaml
sed -i "s=tps: .*=tps: $TPS=" benchmarks/kvstore.yaml
fi
if [ "${machine}" = "Mac" ] && [ "$SC" = "smallbank" ]
then
sed -i '' 's=\&number-of-accounts .*=\&number-of-accounts '"$TXCOUNT"' =' benchmarks/smallbank.yaml
sed -i '' "s=tps: .*=tps: $TPS=" benchmarks/smallbank.yaml
fi
if [ "${machine}" = "Linux" ] && [ "$SC" = "smallbank" ]
then
sed -i 's=\&number-of-accounts .*=\&number-of-accounts '"$TXCOUNT"' =' benchmarks/smallbank.yaml
sed -i "s=tps: .*=tps: $TPS=" benchmarks/smallbank.yaml
fi
# head -n 4 -> take only first four results
files=($(find networks/networkConfig_remote_node*.json | head -n 4))
for i in "${files[@]}"
do
contractPath="contract/$SC/$SC.json"
data=$(jq '.ethereum.contracts.'"$SC"' = .ethereum.contracts[] | .ethereum.contracts.'"$SC"'.path = "'"$contractPath"'" | del(first(.ethereum.contracts[])) | .ethereum.url = "'"$NETWORK_URL"'"' "$i")
echo "" > "$i"
echo "$data" > "$i"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment