github.com/cgcardona/r-subnet-evm@v0.1.5/scripts/run.sh (about)

     1  #!/usr/bin/env bash
     2  set -e
     3  
     4  # This script starts N nodes (TODO N instead of 5) and waits for ctrl-c to shutdown the process group of AvalancheGo processes
     5  # Uses data directory to store all AvalancheGo data neatly in one location with minimal config overhead
     6  if ! [[ "$0" =~ scripts/run.sh ]]; then
     7    echo "must be run from repository root, but got $0"
     8    exit 255
     9  fi
    10  
    11  # Load the versions
    12  SUBNET_EVM_PATH=$(
    13    cd "$(dirname "${BASH_SOURCE[0]}")"
    14    cd .. && pwd
    15  )
    16  source "$SUBNET_EVM_PATH"/scripts/versions.sh
    17  
    18  # Load the constants
    19  source "$SUBNET_EVM_PATH"/scripts/constants.sh
    20  
    21  # Set up avalanche binary path and assume build directory is set
    22  AVALANCHEGO_BUILD_PATH=${AVALANCHEGO_BUILD_PATH:-"$GOPATH/src/github.com/ava-labs/avalanchego/build"}
    23  AVALANCHEGO_PATH=${AVALANCHEGO_PATH:-"$AVALANCHEGO_BUILD_PATH/avalanchego"}
    24  AVALANCHEGO_PLUGIN_DIR=${AVALANCHEGO_PLUGIN_DIR:-"$AVALANCHEGO_BUILD_PATH/plugins"}
    25  DATA_DIR=${DATA_DIR:-/tmp/subnet-evm-start-node/$(date "+%Y-%m-%d%:%H:%M:%S")}
    26  
    27  mkdir -p $DATA_DIR
    28  
    29  # Set the config file contents for the path passed in as the first argument
    30  function _set_config(){
    31    cat <<EOF >$1
    32    {
    33      "network-id": "local",
    34      "staking-enabled": false,
    35      "health-check-frequency": "5s",
    36      "plugin-dir": "$AVALANCHEGO_PLUGIN_DIR"
    37    }
    38  EOF
    39  }
    40  
    41  function execute_cmd() {
    42    echo "Executing command: $@"
    43    $@
    44  }
    45  
    46  NODE_NAME="node1"
    47  NODE_DATA_DIR="$DATA_DIR/$NODE_NAME"
    48  echo "Creating data directory: $NODE_DATA_DIR"
    49  mkdir -p $NODE_DATA_DIR
    50  NODE_CONFIG_FILE_PATH="$NODE_DATA_DIR/config.json"
    51  _set_config $NODE_CONFIG_FILE_PATH
    52  
    53  CMD="$AVALANCHEGO_PATH --data-dir=$NODE_DATA_DIR --config-file=$NODE_CONFIG_FILE_PATH"
    54  
    55  execute_cmd $CMD