root: Copy tendermint scripts from @iov-one

This commit is contained in:
willclarktech 2020-06-15 16:20:26 +01:00
parent ad8d980af2
commit 8204aa9f8c
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7
4 changed files with 86 additions and 0 deletions

19
scripts/tendermint/all_start.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
command -v shellcheck > /dev/null && shellcheck "$0"
# Find latest patch releases at https://hub.docker.com/r/tendermint/tendermint/tags/
declare -a TM_VERSIONS
TM_VERSIONS[31]=v0.31.8
TM_VERSIONS[32]=v0.32.3
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
for KEY in "${!TM_VERSIONS[@]}"; do
export TENDERMINT_VERSION="${TM_VERSIONS[$KEY]}"
export TENDERMINT_PORT="111$KEY"
export TENDERMINT_NAME="tendermint-$KEY"
echo "Starting $TENDERMINT_NAME ($TENDERMINT_VERSION) on port $TENDERMINT_PORT ..."
"$SCRIPT_DIR/start.sh"
done

16
scripts/tendermint/all_stop.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
command -v shellcheck > /dev/null && shellcheck "$0"
declare -a TM_VERSIONS
TM_VERSIONS[31]=v0.31.8
TM_VERSIONS[32]=v0.32.3
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
for KEY in "${!TM_VERSIONS[@]}"; do
export TENDERMINT_NAME="tendermint-$KEY"
echo "Stopping $TENDERMINT_NAME ..."
"$SCRIPT_DIR/stop.sh"
done

43
scripts/tendermint/start.sh Executable file
View File

@ -0,0 +1,43 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
command -v shellcheck > /dev/null && shellcheck "$0"
# Tendermint settings must be specified
# Choose version from https://hub.docker.com/r/tendermint/tendermint/tags/
for SETTING in "TENDERMINT_VERSION" "TENDERMINT_PORT" "TENDERMINT_NAME"
do
if test -z "$(eval echo "\$$SETTING")"
then
echo "\$$SETTING must be set when running this script"
exit 1
fi
done
TMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/tendermint.XXXXXXXXX")
chmod 777 "${TMP_DIR}"
echo "Using temporary dir $TMP_DIR"
LOGFILE="$TMP_DIR/tendermint.log"
docker run --rm \
--user="$UID" \
-v "${TMP_DIR}:/tendermint" \
"tendermint/tendermint:${TENDERMINT_VERSION}" \
init
# make sure we allow cors origins, only possible by modifying the config file
# https://github.com/tendermint/tendermint/issues/3216
sed -ie 's/cors_allowed_origins.*$/cors_allowed_origins = ["*"]/' "${TMP_DIR}/config/config.toml"
# must enable tx index for search and subscribe
docker run --rm \
--user="$UID" \
--name "$TENDERMINT_NAME" \
-p "${TENDERMINT_PORT}:26657" -v "${TMP_DIR}:/tendermint" \
-e "TM_TX_INDEX_INDEX_ALL_TAGS=true" \
"tendermint/tendermint:${TENDERMINT_VERSION}" node \
--proxy_app=kvstore \
--rpc.laddr=tcp://0.0.0.0:26657 \
--log_level=state:info,rpc:info,*:error \
> "$LOGFILE" &
echo "Tendermint running and logging into $LOGFILE"

8
scripts/tendermint/stop.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
set -o errexit -o nounset -o pipefail
command -v shellcheck > /dev/null && shellcheck "$0"
NAME=${TENDERMINT_NAME:-tendermint-25}
echo "Killing container named '$NAME' ..."
docker container kill "$NAME"