From 52e998112b442eeba051c4b9aa128143be168d85 Mon Sep 17 00:00:00 2001 From: Henrik Soerensen Date: Tue, 6 Feb 2024 13:18:42 -0500 Subject: [PATCH] Offer migration automatically if same host has a Voi setup (#29) --- docs/installation/installation.md | 5 +++- docs/migrating.md | 5 ++-- install.sh | 45 +++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/docs/installation/installation.md b/docs/installation/installation.md index 8e1fe4d..554c688 100644 --- a/docs/installation/installation.md +++ b/docs/installation/installation.md @@ -26,4 +26,7 @@ export VOINETWORK_IMPORT_ACCOUNT=1 ``` ???+ info - Post-installation steps for migrating from a D13 based setup can be [found here](../migrating.md) + While the installation detects existing D13 based setups on the same host + and offers migration automatically, + it is important to familiarize yourself with the [migration steps](../../migrating/) in particular + if you are [migrating from a different host](../../migrating/#installing-on-a-new-server). diff --git a/docs/migrating.md b/docs/migrating.md index 5d75c96..1f6914e 100644 --- a/docs/migrating.md +++ b/docs/migrating.md @@ -11,10 +11,9 @@ export VOINETWORK_IMPORT_ACCOUNT=1 === "Installing on same server" - To migrate your setup on an existing server you must first install Voi Swarn on your server using the - [installation instructions](../installation/installation/#using-an-existing-accountaddress-with-mnemonic), after this - you can migrate your existing setup by running this command: + During the installation, the setup will detect existing D13 based setups on the same host and offer migration automatically. + If you want to migrate manually after installation run this command: ```bash ~/voi/bin/migrate-from-d13-setup diff --git a/install.sh b/install.sh index 6a4c967..06158ed 100755 --- a/install.sh +++ b/install.sh @@ -6,6 +6,7 @@ voi_home="${HOME}/voi" headless_install=0 is_root=0 skip_account_setup=0 +migrate_host_based_setup=0 execute_sudo() { if [[ ${is_root} -eq 1 ]]; then @@ -449,6 +450,11 @@ join_as_new_user() { account_status=$(execute_docker_command "goal account dump -a ${account_addr}" | jq -r .onl) + ## This step is late in the process and does require a restart of the service to take effect. + ## Container ID from verify_node_running will have to be re-fetched if any use of the node is to be done after this point. + ## Intentionally not doing this here to avoid confusion. + migrate_host_based_voi_setup + if [[ ${account_status} -eq 1 ]]; then display_banner "Welcome to Voi! You are now online!" else @@ -487,6 +493,12 @@ set_telemetry_name() { return fi + detect_existing_host_based_voi_setup + + if [[ ${migrate_host_based_setup} -eq 1 ]]; then + return + fi + display_banner "Telemetry" if [[ -z ${VOINETWORK_TELEMETRY_NAME} && ! -f "/var/lib/voi/algod/data/logging.config" ]]; then @@ -513,6 +525,35 @@ set_telemetry_name() { fi } +detect_existing_host_based_voi_setup() { + if [[ -f /var/lib/algorand/logging.config && ! -f /var/lib/voi/algod/data/logging.config ]]; then + echo "An existing Voi installation has been detected on your system." + echo "We can migrate your existing telemetry configuration to Voi Swarm." + echo "As part of this process, we will also stop the existing service." + echo "This is necessary to prevent conflicts and ensure that your node can join Voi Swarm as a healthy node." + echo "" + echo "Do you want to migrate your existing setup to Voi Swarm? (yes/no)" + # shellcheck disable=SC2162 + read -p "Migrate existing setup: " prompt + while [[ ${prompt} != "yes" && ${prompt} != "no" ]] + do + # shellcheck disable=SC2162 + read -p "Type either yes or no: " prompt + done + if [[ ${prompt} == "yes" ]]; then + migrate_host_based_setup=1 + fi + fi +} + +migrate_host_based_voi_setup() { + if [[ ${migrate_host_based_setup} -eq 1 ]]; then + display_banner "Migrating from host based setup" + VOINETWORK_TELEMETRY_NAME=$(execute_sudo "cat /var/lib/algorand/logging.config" | jq -r '.Name') + bash -c "env VOINETWORK_TELEMETRY_NAME=\"${VOINETWORK_TELEMETRY_NAME}\" ${voi_home}/bin/migrate-from-d13-setup" + fi +} + if [ -z "${BASH_VERSION:-}" ]; then abort "Bash is required to interpret this script." fi @@ -548,6 +589,8 @@ if [[ -n ${VOINETWORK_SKIP_WALLET_SETUP} && ${VOINETWORK_SKIP_WALLET_SETUP} -eq headless_install=1 fi +display_banner "Welcome to Voi Swarm. Let's get started!" + get_telemetry_name set_telemetry_name @@ -669,6 +712,8 @@ if [[ ${skip_account_setup} -eq 0 ]]; then else generate_participation_key + migrate_host_based_voi_setup + display_banner "Welcome to Voi!" joined_network_instructions