From b7109c0fd21d0110c1e3d6dc22ca2f067421f5b4 Mon Sep 17 00:00:00 2001 From: Tamo Date: Tue, 12 Sep 2023 11:34:59 +0200 Subject: [PATCH] start a script to run everything --- ha_test/run.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 ha_test/run.sh diff --git a/ha_test/run.sh b/ha_test/run.sh new file mode 100644 index 000000000..54000e30e --- /dev/null +++ b/ha_test/run.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +function is_everything_installed { + everything_ok=yes + + if hash zkli 2>/dev/null; then + echo "✅ zkli installed" + else + everything_ok=no + echo "🥺 zkli is missing, please run \`cargo install zkli\`" + fi + + if hash s3cmd 2>/dev/null; then + echo "✅ s3cmd installed" + else + everything_ok=no + echo "🥺 s3cmd is missing, see how to install it here https://s3tools.org/s3cmd" + fi + + if [ $everything_ok = "no" ]; then + echo "Exiting..." + exit 1 + fi +} + +# param: addr of zookeeper +function connect_to_zookeeper { + if ! zkli -a "$1" ls > /dev/null; then + echo "zkli can't connect" + return 1 + fi +} + +# param: addr of the s3 bucket +function connect_to_s3 { + # S3_SECRET_KEY + # S3_ACCESS_KEY + # S3_HOST + # S3_BUCKET + + s3cmd --host="$S3_HOST" --host-bucket="$S3_BUCKET" --access_key="$ACCESS_KEY" --secret_key="$S3_SECRET_KEY" ls + + if $?; then + echo "s3cmd can't connect" + return 1 + fi +} + +is_everything_installed + +ZOOKEEPER_ADDR="localhost:2181" +if ! connect_to_zookeeper $ZOOKEEPER_ADDR; then + ZOOKEEPER_ADDR="localhost:21811" + if ! connect_to_zookeeper $ZOOKEEPER_ADDR; then + echo "Can't connect to zkli" + exit 1 + fi +fi + + +connect_to_s3