Skip to content

Commit

Permalink
Feat/script cluster (0xPolygon#1678)
Browse files Browse the repository at this point in the history
* Added help functionality on script

* check if docker-compose is installed when needed

* Added write-logs
  • Loading branch information
criadoperez authored Jul 20, 2023
1 parent 195b619 commit c3e23fa
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion scripts/cluster
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,37 @@ if [[ "$1" == "polybft" ]] && ! command -v nc >/dev/null 2>&1; then
dp_error_flag=1
fi

# Check if docker-compose is installed
if [[ "$2" == "--docker" ]] && ! command -v docker-compose >/dev/null 2>&1; then
echo "docker-compose is not installed."
echo "Manual installation instructions: Visit https://docs.docker.com/compose/install/ for more information."
dp_error_flag=1
fi

# Stop script if any of the dependencies have failed
if [[ "$dp_error_flag" -eq 1 ]]; then
echo "Missing dependencies. Please install them and run the script again."
exit 1
fi

function showhelp(){
echo "Usage: cluster {consensus} [{command}] [{flags}]"
echo "Consensus:"
echo " ibft Start Supernets test environment locally with ibft consensus"
echo " polybft Start Supernets test environment locally with polybft consensus"
echo "Commands:"
echo " stop Stop the running environment"
echo " destroy Destroy the running environment"
echo " write-logs Writes STDOUT and STDERR output to log file. Not applicable when using --docker flag."
echo "Flags:"
echo " --docker Run using Docker (requires docker-compose)."
echo " --help Display this help information"
echo "Examples:"
echo " cluster polybft -- Run the script with the polybft consensus"
echo " cluster polybtt --docker -- Run the script with the polybft consensus using docker"
echo " cluster polybft stop -- Stop the running environment"
}

function initIbftConsensus() {
echo "Running with ibft consensus"
./polygon-edge secrets init --insecure --data-dir test-chain- --num 4
Expand Down Expand Up @@ -180,6 +205,12 @@ function stopDockerEnvironment() {

set -e

# Show help if help flag is entered or no arguments are provided
if [[ "$1" == "--help" ]] || [[ $# -eq 0 ]]; then
showhelp
exit 0
fi

# Reset test-dirs
rm -rf test-chain-*
rm -f genesis.json
Expand Down Expand Up @@ -228,7 +259,8 @@ case "$2" in
startServerFromBinary $2
exit 0
else
echo "Unsupported consensus mode. Supported modes are: ibft and polybft "
echo "Unsupported consensus mode. Supported modes are: ibft and polybft."
showhelp
exit 1
fi
;;
Expand Down

0 comments on commit c3e23fa

Please sign in to comment.