Skip to content

Instantly share code, notes, and snippets.

@NicolasMassart
Created December 8, 2021 11:47
Show Gist options
  • Save NicolasMassart/ce53b5c264b361174587b34b972582b8 to your computer and use it in GitHub Desktop.
Save NicolasMassart/ce53b5c264b361174587b34b972582b8 to your computer and use it in GitHub Desktop.
Besu local debugging help script
#!/bin/sh
usage() {
echo "Usage: $0 [-v <Besu version to run>] [-n <Node number>]" 1>&2;
echo " -v default version value is ${DEFAULT_VERSION}, you can also try 1.5.3" 1>&2;
echo " -n default node number value ${DEFAULT_NODE}" 1>&2;
exit 1;
}
clear_db() {
echo "Clearing Node-$1 database." 1>&2;
rm -rf Node-$1/data/caches
rm -rf Node-$1/data/database
rm -rf Node-$1/data/besu.networks
rm -rf Node-$1/data/besu.ports
rm -rf Node-$1/data/DATABASE_METADATA.json
echo "Node-$1 database cleared." 1>&2;
}
clear='false'
while getopts v:n:c flag
do
case "${flag}" in
v) version=${OPTARG};;
n) node=${OPTARG};;
c) clear='true';;
*)
usage
;;
esac
done
shift $((OPTIND-1))
# defaults
DEFAULT_VERSION="21.7.3"
DEFAULT_NODE="1"
if [ -z "${version}" ]; then
version=$DEFAULT_VERSION
fi
if [ -z "${node}" ]; then
node=$DEFAULT_NODE
fi
if ${clear}; then
clear_db $node
fi
#define bin and conf
besu_bin=../besu-$version/bin/besu
besu_conf=Node-$node/config.toml
#run node
echo "Running Node-${node} with besu-${version}"
$besu_bin --config-file=$besu_conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment