2018-09-27 11:30:07 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-11-29 12:32:38 +01:00
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
2018-12-19 10:52:44 +01:00
|
|
|
DIR="${DIR/ /\\ }"
|
2018-11-29 12:32:38 +01:00
|
|
|
COMPOSE_DIR="${DIR}/compose-files"
|
2018-12-05 10:46:50 +01:00
|
|
|
|
|
|
|
export PROJECT_NAME="ocean"
|
2018-12-17 10:22:39 +01:00
|
|
|
export forcepull="false"
|
|
|
|
|
2018-12-06 10:58:28 +01:00
|
|
|
# default to latest versions
|
2018-12-11 11:54:06 +01:00
|
|
|
export OCEAN_VERSION=stable
|
2018-12-05 10:46:50 +01:00
|
|
|
|
|
|
|
# keeper options
|
2018-12-06 13:06:02 +01:00
|
|
|
export KEEPER_DEPLOY_CONTRACTS="false"
|
2018-12-19 10:52:44 +01:00
|
|
|
export KEEPER_ARTIFACTS_FOLDER="${HOME}/.ocean/keeper-contracts/artifacts"
|
2018-12-06 10:58:28 +01:00
|
|
|
# Specify which ethereum client to run or connect to: development, kovan, spree or nile
|
|
|
|
export KEEPER_NETWORK_NAME="nile"
|
2018-12-19 10:52:44 +01:00
|
|
|
export NODE_COMPOSE_FILE="${COMPOSE_DIR}/nodes/nile_node.yml"
|
2018-12-05 10:46:50 +01:00
|
|
|
|
2018-09-27 11:30:07 +02:00
|
|
|
# Ganache specific option, these two options have no effect when not running ganache-cli
|
2018-11-29 12:32:38 +01:00
|
|
|
export GANACHE_DATABASE_PATH="${DIR}"
|
2018-12-05 10:46:50 +01:00
|
|
|
export GANACHE_REUSE_DATABASE="false"
|
|
|
|
|
2018-12-10 12:44:29 +01:00
|
|
|
export BRIZO_ENV_FILE="${DIR}/brizo.env"
|
2018-12-05 10:46:50 +01:00
|
|
|
|
2018-11-30 10:36:55 +01:00
|
|
|
# Specify the ethereum default RPC container provider
|
2018-12-05 14:03:41 +01:00
|
|
|
export KEEPER_RPC_HOST='keeper-node'
|
2018-12-05 10:46:50 +01:00
|
|
|
export KEEPER_RPC_PORT='8545'
|
2018-12-05 12:16:18 +01:00
|
|
|
export KEEPER_RPC_URL="http://"${KEEPER_RPC_HOST}:${KEEPER_RPC_PORT}
|
2018-09-27 11:30:07 +02:00
|
|
|
|
2018-12-27 15:14:20 +01:00
|
|
|
# Enable acl-contract validation in Secret-store
|
|
|
|
export CONFIGURE_ACL="false"
|
|
|
|
|
2018-10-10 12:21:56 +02:00
|
|
|
# colors
|
|
|
|
COLOR_R="\033[0;31m" # red
|
|
|
|
COLOR_G="\033[0;32m" # green
|
|
|
|
COLOR_Y="\033[0;33m" # yellow
|
|
|
|
COLOR_B="\033[0;34m" # blue
|
|
|
|
COLOR_M="\033[0;35m" # magenta
|
|
|
|
COLOR_C="\033[0;36m" # cyan
|
2018-10-02 13:38:55 +02:00
|
|
|
|
2018-10-10 12:21:56 +02:00
|
|
|
# reset
|
|
|
|
COLOR_RESET="\033[00m"
|
2018-09-27 13:15:43 +02:00
|
|
|
|
2018-10-10 12:21:56 +02:00
|
|
|
function show_banner {
|
|
|
|
local output=$(cat .banner)
|
|
|
|
echo -e "$COLOR_B$output$COLOR_RESET"
|
|
|
|
echo ""
|
|
|
|
}
|
2018-09-27 13:15:43 +02:00
|
|
|
|
2018-10-10 12:21:56 +02:00
|
|
|
show_banner
|
2018-10-02 13:13:10 +02:00
|
|
|
|
2018-11-29 12:32:38 +01:00
|
|
|
COMPOSE_FILES=""
|
|
|
|
COMPOSE_FILES+=" -f ${COMPOSE_DIR}/network_volumes.yml"
|
|
|
|
COMPOSE_FILES+=" -f ${COMPOSE_DIR}/pleuston.yml"
|
|
|
|
COMPOSE_FILES+=" -f ${COMPOSE_DIR}/aquarius.yml"
|
|
|
|
COMPOSE_FILES+=" -f ${COMPOSE_DIR}/brizo.yml"
|
2018-12-05 10:46:50 +01:00
|
|
|
COMPOSE_FILES+=" -f ${COMPOSE_DIR}/secret_store.yml"
|
2018-09-27 13:15:43 +02:00
|
|
|
|
2018-10-10 12:21:56 +02:00
|
|
|
while :; do
|
|
|
|
case $1 in
|
2018-12-05 10:46:50 +01:00
|
|
|
#################################################
|
|
|
|
# Version switches
|
|
|
|
#################################################
|
2018-10-10 12:21:56 +02:00
|
|
|
--latest)
|
|
|
|
export OCEAN_VERSION=latest
|
|
|
|
printf $COLOR_Y'Switched to latest components...\n\n'$COLOR_RESET
|
2018-12-19 10:52:44 +01:00
|
|
|
export AQUARIUS_VERSION=${AQUARIUS_VERSION:-$OCEAN_VERSION}
|
|
|
|
export BRIZO_VERSION=${BRIZO_VERSION:-$OCEAN_VERSION}
|
|
|
|
export KEEPER_VERSION=${KEEPER_VERSION:-$OCEAN_VERSION}
|
|
|
|
export PLEUSTON_VERSION=${PLEUSTON_VERSION:-$OCEAN_VERSION}
|
2018-10-10 12:21:56 +02:00
|
|
|
;;
|
2018-12-17 10:22:39 +01:00
|
|
|
--force-pull)
|
2018-12-18 10:34:06 +01:00
|
|
|
export forcepull="true"
|
2018-12-17 10:22:39 +01:00
|
|
|
printf $COLOR_Y'Pulling latest components...\n\n'$COLOR_RESET
|
|
|
|
;;
|
2018-12-05 10:46:50 +01:00
|
|
|
#################################################
|
|
|
|
# Exclude switches
|
|
|
|
#################################################
|
2018-10-10 15:49:10 +02:00
|
|
|
--no-pleuston)
|
2018-12-19 10:52:44 +01:00
|
|
|
COMPOSE_FILES="${COMPOSE_FILES/ -f ${COMPOSE_DIR}\/pleuston.yml/}"
|
2018-10-10 12:21:56 +02:00
|
|
|
printf $COLOR_Y'Starting without Pleuston...\n\n'$COLOR_RESET
|
|
|
|
;;
|
2018-12-06 09:16:50 +01:00
|
|
|
--no-brizo)
|
2018-12-19 10:52:44 +01:00
|
|
|
COMPOSE_FILES="${COMPOSE_FILES/ -f ${COMPOSE_DIR}\/brizo.yml/}"
|
2018-12-06 09:16:50 +01:00
|
|
|
printf $COLOR_Y'Starting without Brizo...\n\n'$COLOR_RESET
|
|
|
|
;;
|
|
|
|
--no-aquarius)
|
2018-12-19 10:52:44 +01:00
|
|
|
COMPOSE_FILES="${COMPOSE_FILES/ -f ${COMPOSE_DIR}\/aquarius.yml/}"
|
2018-12-06 09:16:50 +01:00
|
|
|
printf $COLOR_Y'Starting without Aquarius...\n\n'$COLOR_RESET
|
|
|
|
;;
|
|
|
|
--no-secret-store)
|
2018-12-19 10:52:44 +01:00
|
|
|
COMPOSE_FILES="${COMPOSE_FILES/ -f ${COMPOSE_DIR}\/secret_store.yml/}"
|
2018-12-06 09:16:50 +01:00
|
|
|
printf $COLOR_Y'Starting without Secret Store...\n\n'$COLOR_RESET
|
|
|
|
;;
|
2018-12-05 10:46:50 +01:00
|
|
|
#################################################
|
|
|
|
# Contract/Storage switches
|
|
|
|
#################################################
|
|
|
|
--reuse-ganache-database)
|
|
|
|
export GANACHE_REUSE_DATABASE="true"
|
2018-12-27 15:14:20 +01:00
|
|
|
printf $COLOR_Y'Starting and reusing the database...\n\n'$COLOR_RESET
|
|
|
|
;;
|
|
|
|
#################################################
|
|
|
|
# Secret-Store validation switch
|
|
|
|
#################################################
|
|
|
|
--acl-contract)
|
|
|
|
export CONFIGURE_ACL="true"
|
|
|
|
printf $COLOR_Y'Enabling acl validation in secret-store...\n\n'$COLOR_RESET
|
2018-12-05 10:46:50 +01:00
|
|
|
;;
|
|
|
|
#################################################
|
|
|
|
# Node type switches
|
|
|
|
#################################################
|
2018-12-05 14:03:41 +01:00
|
|
|
# connects you to kovan
|
2018-12-05 10:46:50 +01:00
|
|
|
--local-kovan-node)
|
2018-12-19 10:52:44 +01:00
|
|
|
export NODE_COMPOSE_FILE="${COMPOSE_DIR}/nodes/kovan_node.yml"
|
2018-12-05 10:46:50 +01:00
|
|
|
export KEEPER_NETWORK_NAME="kovan"
|
|
|
|
printf $COLOR_Y'Starting with local Kovan node...\n\n'$COLOR_RESET
|
|
|
|
;;
|
|
|
|
# spins up a new ganache blockchain
|
|
|
|
--local-ganache-node)
|
|
|
|
COMPOSE_FILES+=" -f ${COMPOSE_DIR}/keeper_contracts.yml"
|
2018-12-19 10:52:44 +01:00
|
|
|
export NODE_COMPOSE_FILE="${COMPOSE_DIR}/nodes/ganache_node.yml"
|
2018-12-05 10:46:50 +01:00
|
|
|
export KEEPER_NETWORK_NAME="development"
|
|
|
|
export KEEPER_DEPLOY_CONTRACTS="true"
|
2018-12-07 13:37:26 +01:00
|
|
|
#rm -f ${KEEPER_ARTIFACTS_FOLDER}/*.development.json
|
2018-12-05 10:46:50 +01:00
|
|
|
printf $COLOR_Y'Starting with local Ganache node...\n\n'$COLOR_RESET
|
|
|
|
;;
|
2018-12-06 10:58:28 +01:00
|
|
|
# connects you to nile ocean testnet
|
|
|
|
--local-nile-node)
|
2018-12-19 10:52:44 +01:00
|
|
|
export NODE_COMPOSE_FILE="${COMPOSE_DIR}/nodes/nile_node.yml"
|
2018-12-06 10:58:28 +01:00
|
|
|
export KEEPER_NETWORK_NAME="nile"
|
|
|
|
printf $COLOR_Y'Starting with local Nile node...\n\n'$COLOR_RESET
|
2018-12-05 14:03:41 +01:00
|
|
|
;;
|
2018-12-06 10:58:28 +01:00
|
|
|
# spins up spree local testnet
|
|
|
|
--local-spree-node)
|
2018-12-05 10:46:50 +01:00
|
|
|
COMPOSE_FILES+=" -f ${COMPOSE_DIR}/keeper_contracts.yml"
|
2018-12-19 10:52:44 +01:00
|
|
|
export NODE_COMPOSE_FILE="${COMPOSE_DIR}/nodes/spree_node.yml"
|
2018-12-06 10:58:28 +01:00
|
|
|
export KEEPER_NETWORK_NAME="spree"
|
2018-12-05 10:46:50 +01:00
|
|
|
export KEEPER_DEPLOY_CONTRACTS="true"
|
2018-12-07 13:37:26 +01:00
|
|
|
#rm -f ${KEEPER_ARTIFACTS_FOLDER}/*.development.json
|
2018-12-06 10:58:28 +01:00
|
|
|
printf $COLOR_Y'Starting with local Spree node...\n\n'$COLOR_RESET
|
2018-10-10 12:21:56 +02:00
|
|
|
;;
|
2018-12-05 10:46:50 +01:00
|
|
|
#################################################
|
|
|
|
# Cleaning switches
|
|
|
|
#################################################
|
2018-11-30 10:55:15 +01:00
|
|
|
--purge)
|
2018-12-17 10:22:39 +01:00
|
|
|
printf $COLOR_R'Doing a deep clean ...\n\n'$COLOR_RESET
|
|
|
|
docker-compose --project-name=$PROJECT_NAME $COMPOSE_FILES -f ${NODE_COMPOSE_FILE} down
|
2018-12-05 12:16:18 +01:00
|
|
|
docker network rm ${PROJECT_NAME}_default || true
|
2018-12-17 10:22:39 +01:00
|
|
|
docker network rm ${PROJECT_NAME}_backend || true
|
|
|
|
docker network rm ${PROJECT_NAME}_secretstore || true
|
2018-12-05 14:03:41 +01:00
|
|
|
docker volume rm ${PROJECT_NAME}_keeper-node || true
|
2018-12-05 12:16:18 +01:00
|
|
|
docker volume rm ${PROJECT_NAME}_secret-store || true
|
|
|
|
read -p "Are you sure you want to delete $KEEPER_ARTIFACTS_FOLDER? " -n 1 -r
|
2018-11-15 11:02:31 +01:00
|
|
|
echo
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
|
|
then
|
2018-12-19 10:52:44 +01:00
|
|
|
rm -rf "${KEEPER_ARTIFACTS_FOLDER}"
|
2018-11-15 11:02:31 +01:00
|
|
|
fi
|
|
|
|
;;
|
2018-10-10 12:21:56 +02:00
|
|
|
--) # End of all options.
|
2018-11-29 12:32:38 +01:00
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
2018-10-10 12:21:56 +02:00
|
|
|
-?*)
|
2018-11-29 12:32:38 +01:00
|
|
|
printf $COLOR_R'WARN: Unknown option (ignored): %s\n'$COLOR_RESET "$1" >&2
|
|
|
|
break
|
|
|
|
;;
|
2018-10-10 12:21:56 +02:00
|
|
|
*)
|
|
|
|
printf $COLOR_Y'Starting Ocean...\n\n'$COLOR_RESET
|
2018-12-18 10:34:06 +01:00
|
|
|
if [[ $forcepull == "true" ]]
|
2018-12-17 10:22:39 +01:00
|
|
|
then
|
|
|
|
docker-compose --project-name=$PROJECT_NAME $COMPOSE_FILES -f ${NODE_COMPOSE_FILE} pull
|
|
|
|
fi
|
2018-12-11 11:54:06 +01:00
|
|
|
docker-compose --project-name=$PROJECT_NAME $COMPOSE_FILES -f ${NODE_COMPOSE_FILE} up --remove-orphans
|
2018-10-10 12:21:56 +02:00
|
|
|
break
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|