github.com/badrootd/nibiru-cometbft@v0.37.5-0.20240307173500-2a75559eee9b/networks/local/localnode/wrapper.sh (about)

     1  #!/usr/bin/env sh
     2  
     3  ##
     4  ## Input parameters
     5  ##
     6  BINARY=/cometbft/${BINARY:-cometbft}
     7  ID=${ID:-0}
     8  LOG=${LOG:-cometbft.log}
     9  
    10  ##
    11  ## Assert linux binary
    12  ##
    13  if ! [ -f "${BINARY}" ]; then
    14  	echo "The binary $(basename "${BINARY}") cannot be found. Please add the binary to the shared folder. Please use the BINARY environment variable if the name of the binary is not 'cometbft' E.g.: -e BINARY=my_test_binary"
    15  
    16  	exit 1
    17  fi
    18  BINARY_CHECK="$(file "$BINARY" | grep 'ELF 64-bit LSB executable, x86-64')"
    19  if [ -z "${BINARY_CHECK}" ]; then
    20  	echo "Binary needs to be OS linux, ARCH amd64 (build with 'make build-linux')"
    21  	exit 1
    22  fi
    23  
    24  ##
    25  ## Run binary with all parameters
    26  ##
    27  export CMTHOME="/cometbft/node${ID}"
    28  
    29  if [ -d "`dirname ${CMTHOME}/${LOG}`" ]; then
    30    "$BINARY" "$@" | tee "${CMTHOME}/${LOG}"
    31  else
    32    "$BINARY" "$@"
    33  fi
    34  
    35  chmod 777 -R /cometbft
    36