diff --git a/scripts/cosm/README.md b/scripts/cosm/README.md index a7248f5d..13c16ea5 100644 --- a/scripts/cosm/README.md +++ b/scripts/cosm/README.md @@ -10,7 +10,7 @@ Run the following: ## CLI -Docker-friendly access to `gaiacli` is provided. Just use the `./cli.sh` script. +Docker-friendly access to `wasmcli` is provided. Just use the `./cli.sh` script. For example: ``` diff --git a/scripts/cosm/cli.sh b/scripts/cosm/cli.sh index 5487cfa2..f7131106 100755 --- a/scripts/cosm/cli.sh +++ b/scripts/cosm/cli.sh @@ -2,10 +2,12 @@ set -o errexit -o nounset -o pipefail command -v shellcheck > /dev/null && shellcheck "$0" -# Choose from https://hub.docker.com/r/tendermint/gaia/tags -VERSION="v2.0.0" +# Choose from https://hub.docker.com/r/cosmwasm/wasmd/tags +REPOSITORY="cosmwasm/wasmd" +VERSION="manual" + CURRENT_DIR="$(realpath "$(dirname "$0")")" -GAIAD_CONTAINER_NAME="gaiad" +BLOCKCHAIN_CONTAINER_NAME="wasmd" HOME_DIR="/home" docker run \ @@ -16,6 +18,6 @@ docker run \ -v "$CURRENT_DIR/.gaiacli:$HOME_DIR/.gaiacli" \ -w "$HOME_DIR" \ --env "HOME=$HOME_DIR" \ - --net "container:$GAIAD_CONTAINER_NAME" \ - "tendermint/gaia:${VERSION}" \ - gaiacli "$@" + --net "container:$BLOCKCHAIN_CONTAINER_NAME" \ + "$REPOSITORY:$VERSION" \ + wasmcli "$@" diff --git a/scripts/cosm/generate_template.sh b/scripts/cosm/generate_template.sh index 3f31d3f1..b9550409 100755 --- a/scripts/cosm/generate_template.sh +++ b/scripts/cosm/generate_template.sh @@ -1,22 +1,23 @@ #!/bin/bash - set -o errexit -o nounset -o pipefail command -v shellcheck > /dev/null && shellcheck "$0" # Choose from https://hub.docker.com/r/cosmwasm/wasmd/tags +REPOSITORY="cosmwasm/wasmd" VERSION="manual" -CONTAINER_NAME="wasmd" -rm -rf ./template -mkdir ./template +SCRIPT_DIR="$(realpath "$(dirname "$0")")" + +rm -rf "$SCRIPT_DIR/template" +mkdir "$SCRIPT_DIR/template" # any any more addresses you want to fund in genesis below docker run --rm \ - -e PASSWORD=my-secret-password \ - --mount type=bind,source="$(pwd)/template",target=/root \ - "$CONTAINER_NAME:$VERSION" \ - ./setup.sh \ - cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6 + -e PASSWORD=my-secret-password \ + --mount type=bind,source="$SCRIPT_DIR/template",target=/root \ + "$REPOSITORY:$VERSION" \ + ./setup.sh \ + cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6 # this is created as root, let's make it ours -sudo chown -R "$(id -u):$(id -g)" ./template +sudo chown -R "$(id -u):$(id -g)" "$SCRIPT_DIR/template" diff --git a/scripts/cosm/start.sh b/scripts/cosm/start.sh index 189dfe15..383403d3 100755 --- a/scripts/cosm/start.sh +++ b/scripts/cosm/start.sh @@ -3,32 +3,41 @@ set -o errexit -o nounset -o pipefail command -v shellcheck > /dev/null && shellcheck "$0" # Choose from https://hub.docker.com/r/cosmwasm/wasmd/tags +REPOSITORY="cosmwasm/wasmd" VERSION="manual" -CONTAINER_NAME="wasmd" TMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/gaia.XXXXXXXXX") chmod 777 "$TMP_DIR" echo "Using temporary dir $TMP_DIR" WASMD_LOGFILE="$TMP_DIR/wasmd.log" REST_SERVER_LOGFILE="$TMP_DIR/rest-server.log" +SCRIPT_DIR="$(realpath "$(dirname "$0")")" +CONTAINER_NAME="wasmd" # This starts up wasmd docker volume rm -f wasmd_data docker run --rm \ - --name "$CONTAINER_NAME" \ - -p 1317:1317 \ - -p 26657:26657 \ - -p 26656:26656 \ - --mount type=bind,source="$(pwd)/template",target=/template \ - --mount type=volume,source=wasmd_data,target=/root \ - "cosmwasm/$CONTAINER_NAME:$VERSION" \ - ./run_wasmd.sh /template \ - > "$WASMD_LOGFILE" & + --name "$CONTAINER_NAME" \ + -p 1317:1317 \ + -p 26657:26657 \ + -p 26656:26656 \ + --mount type=bind,source="$SCRIPT_DIR/template",target=/template \ + --mount type=volume,source=wasmd_data,target=/root \ + "$REPOSITORY:$VERSION" \ + ./run_wasmd.sh /template \ + > "$WASMD_LOGFILE" & echo "wasmd running and logging into $WASMD_LOGFILE" sleep 10 +if [ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME")" != "true" ]; then + echo "Container named '$CONTAINER_NAME' not running. We cannot continue." \ + "This can happen when 'docker run' needs too long to download and start." \ + "It might be worth retrying this step once the image is in the local docker cache." + exit 1 +fi + docker exec "$CONTAINER_NAME" \ wasmcli rest-server \ --node tcp://localhost:26657 \