From cad2011bcff23eef97d212d906da89ba51f498ac Mon Sep 17 00:00:00 2001 From: Simon Richardson Date: Tue, 7 Jan 2025 20:17:50 +0000 Subject: [PATCH] refactor: removes the old repl This removes the old REPL and instead favours the new one. If there are any missing features, we should port them to the new REPL. > The King is dead, long live the King! --- scripts/dqlite/Makefile | 17 ---------- scripts/dqlite/scripts/repl/install.sh | 7 ---- .../dqlite/scripts/repl/repl-list-models.sh | 18 ---------- scripts/dqlite/scripts/repl/repl-model.sh | 17 ---------- scripts/dqlite/scripts/repl/repl.sh | 34 ------------------- 5 files changed, 93 deletions(-) delete mode 100755 scripts/dqlite/scripts/repl/install.sh delete mode 100755 scripts/dqlite/scripts/repl/repl-list-models.sh delete mode 100755 scripts/dqlite/scripts/repl/repl-model.sh delete mode 100755 scripts/dqlite/scripts/repl/repl.sh diff --git a/scripts/dqlite/Makefile b/scripts/dqlite/Makefile index d51b43da3db..0b95f4580d9 100644 --- a/scripts/dqlite/Makefile +++ b/scripts/dqlite/Makefile @@ -36,20 +36,3 @@ musl-install: musl-install-if-missing: +@./scripts/dqlite/scripts/musl/install-if-missing.sh - -repl-install: - +@./scripts/dqlite/scripts/repl/install.sh - -repl: - +@./scripts/dqlite/scripts/repl/repl.sh - -repl-list-models: - +@./scripts/dqlite/scripts/repl/repl-list-models.sh - -ifeq (repl-model,$(firstword $(MAKECMDGOALS))) - REPL_MODEL_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) - $(eval $(REPL_MODEL_ARGS):;@:) -endif - -repl-model: - +@./scripts/dqlite/scripts/repl/repl-model.sh $(REPL_MODEL_ARGS) diff --git a/scripts/dqlite/scripts/repl/install.sh b/scripts/dqlite/scripts/repl/install.sh deleted file mode 100755 index 3b9a486ae8c..00000000000 --- a/scripts/dqlite/scripts/repl/install.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -set -e - -MACHINE=${MACHINE:-0} - -juju exec -m controller --machine=${MACHINE} 'which dqlite &>/dev/null || sudo DEBIAN_FRONTEND=noninteractive add-apt-repository -y ppa:dqlite/dev && sudo DEBIAN_FRONTEND=noninteractive apt install -y dqlite-tools' diff --git a/scripts/dqlite/scripts/repl/repl-list-models.sh b/scripts/dqlite/scripts/repl/repl-list-models.sh deleted file mode 100755 index 28aadc96e5b..00000000000 --- a/scripts/dqlite/scripts/repl/repl-list-models.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -set -e - -MACHINE=${MACHINE:-0} - -CMDS=$(cat << EOF -sudo awk '/controllercert/ {in_cert_block=1; next} -/:/ {in_cert_block=0} -in_cert_block { print }' /var/lib/juju/agents/machine-$MACHINE/agent.conf | sed 's/ //' > dqlite.cert -sudo awk '/controllerkey/ {in_cert_block=1; next} -/:/ {in_cert_block=0} -in_cert_block { print }' /var/lib/juju/agents/machine-$MACHINE/agent.conf | sed 's/ //' > dqlite.key -sudo dqlite -s file:///var/lib/juju/dqlite/cluster.yaml -c ./dqlite.cert -k ./dqlite.key controller "SELECT uuid, name FROM model" -EOF -) - -juju ssh --pty=false -m controller ${MACHINE} "${CMDS}" diff --git a/scripts/dqlite/scripts/repl/repl-model.sh b/scripts/dqlite/scripts/repl/repl-model.sh deleted file mode 100755 index a18638cd01c..00000000000 --- a/scripts/dqlite/scripts/repl/repl-model.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -set -e - -args=("$@") -DB=${args[0]:-0} - -list_models() { - source "$(dirname $0)/repl-list-models.sh" -} - -if [ "$DB" != "0" ]; then - DB_NAME=$(echo "$(list_models)" | head -n $(($DB+1)) | tail -n 1 | awk '{print $1}') -fi - -source "$(dirname $0)/repl.sh" - diff --git a/scripts/dqlite/scripts/repl/repl.sh b/scripts/dqlite/scripts/repl/repl.sh deleted file mode 100755 index edf6ab79541..00000000000 --- a/scripts/dqlite/scripts/repl/repl.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -set -e - -MACHINE=${MACHINE:-0} -DB_NAME=${DB_NAME:-controller} - -echo "-------------------------------------------------------------------------" -echo "" -echo "DQLITE REPL Mode: ${DB_NAME}" -echo "" -echo "-------------------------------------------------------------------------" -echo "" -echo " WARNING!" -echo "" -echo "You're attached to the live database. There currently is no audit trail" -echo "when running any commands. You could end up corrupting the database." -echo "Ensure you make a backup before running any commands." -echo "" -echo "--------------------------------------------------------------------------" -echo "" - -CMDS=$(cat << EOF -sudo awk '/controllercert/ {in_cert_block=1; next} -/:/ {in_cert_block=0} -in_cert_block { print }' /var/lib/juju/agents/machine-$MACHINE/agent.conf | sed 's/ //' > dqlite.cert -sudo awk '/controllerkey/ {in_cert_block=1; next} -/:/ {in_cert_block=0} -in_cert_block { print }' /var/lib/juju/agents/machine-$MACHINE/agent.conf | sed 's/ //' > dqlite.key -sudo dqlite -s file:///var/lib/juju/dqlite/cluster.yaml -c ./dqlite.cert -k ./dqlite.key $DB_NAME -EOF -) - -juju ssh -m controller ${MACHINE} "${CMDS}"