#! /bin/bash ifExit(){ if [[ $? != 0 ]]; then echo "ifExit" echo "$1" for var in "$@" do echo "$var" done exit 1 fi } if0Exit(){ if [[ $? == 0 ]]; then echo "if0Exit" echo "$1" for var in "$@" do echo "$var" done exit 1 fi } export -f ifExit export -f if0Exit #----------------------------------------------------------------------- # set and export directories if [ "$CHAIN_ID" = "" ]; then echo "Eris-db container requires environment variable CHAIN_ID to be set. Please run docker container with \`-e CHAIN_ID=\"<chainId>\"\`" exit 1 fi if [ "$ERIS_DB_WORKDIR" = "" ]; then ERIS_DB_WORKDIR="$ERIS/chains/$CHAIN_ID" fi if [ ! -d "$ERIS_DB_WORKDIR" ]; then mkdir -p $ERIS_DB_WORKDIR ifExit "Error making working directory $ERIS_DB_WORKDIR" fi export ERIS_DB_WORKDIR export ERIS_DB_DATADIR=$ERIS_DB_WORKDIR/data echo "env CHAIN_ID is set to $CHAIN_ID" echo "env ERIS_DB_WORKDIR is set to $ERIS_DB_WORKDIR" echo "env ERIS_DB_DATADIR is set to $ERIS_DB_DATADIR" #----------------------------------------------------------------------- # [2016-07-13 ben] we preserve the existing contact commands "new", "run", # but this functionality is absorbed in eris-db, eris-cm, eris-cli # and the mapping is preserved here to catch deployed use-cases. # NOTE: eris-db serve picks up following environment variables which are relevant to interaction with eris-cli # - CHAIN_ID, set by eris-cli # - ERIS_DB_WORKDIR, set in this script # - ERIS_DB_DATADIR, set in this script # - ERISDB_API (to be deprecated in favor of explicit --disable-rpc) # - CONFIG_OPTS, for arbitrary flags to be passed to `eris-db serve` CMD=$1 case $CMD in "install" ) echo "Install is under review to be deprecated; please contact support@erisindustries.com if you encounter this error." exit 1 ;; "new" ) echo "passed new" ;; "run" ) echo "passed run" ;; "register" ) echo "Register is under review to be deprecated; please contact support@erisindustries.com if you encounter this error." exit 1 ;; # we append $@ to eris-db to expose the same flags on the docker container, # eg `docker run -it quay.io/eris/erisdb --chain-id=<chain_id>`, will overwrite $CHAIN_ID *) echo "no known command given: $CMD" ;; esac echo "running eris-db serve --debug $CONFIG_OPTS \"$@\"" eris-db serve --debug $CONFIG_OPTS "$@"