Skip to content

Commit 52e9981

Browse files
authored
Offer migration automatically if same host has a Voi setup (#29)
1 parent 9392f02 commit 52e9981

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

docs/installation/installation.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,7 @@ export VOINETWORK_IMPORT_ACCOUNT=1
2626
```
2727

2828
???+ info
29-
Post-installation steps for migrating from a D13 based setup can be [found here](../migrating.md)
29+
While the installation detects existing D13 based setups on the same host
30+
and offers migration automatically,
31+
it is important to familiarize yourself with the [migration steps](../../migrating/) in particular
32+
if you are [migrating from a different host](../../migrating/#installing-on-a-new-server).

docs/migrating.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ export VOINETWORK_IMPORT_ACCOUNT=1
1111

1212
=== "Installing on same server"
1313

14-
To migrate your setup on an existing server you must first install Voi Swarn on your server using the
15-
[installation instructions](../installation/installation/#using-an-existing-accountaddress-with-mnemonic), after this
16-
you can migrate your existing setup by running this command:
14+
During the installation, the setup will detect existing D13 based setups on the same host and offer migration automatically.
1715

16+
If you want to migrate manually after installation run this command:
1817

1918
```bash
2019
~/voi/bin/migrate-from-d13-setup

install.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ voi_home="${HOME}/voi"
66
headless_install=0
77
is_root=0
88
skip_account_setup=0
9+
migrate_host_based_setup=0
910

1011
execute_sudo() {
1112
if [[ ${is_root} -eq 1 ]]; then
@@ -449,6 +450,11 @@ join_as_new_user() {
449450

450451
account_status=$(execute_docker_command "goal account dump -a ${account_addr}" | jq -r .onl)
451452

453+
## This step is late in the process and does require a restart of the service to take effect.
454+
## 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.
455+
## Intentionally not doing this here to avoid confusion.
456+
migrate_host_based_voi_setup
457+
452458
if [[ ${account_status} -eq 1 ]]; then
453459
display_banner "Welcome to Voi! You are now online!"
454460
else
@@ -487,6 +493,12 @@ set_telemetry_name() {
487493
return
488494
fi
489495

496+
detect_existing_host_based_voi_setup
497+
498+
if [[ ${migrate_host_based_setup} -eq 1 ]]; then
499+
return
500+
fi
501+
490502
display_banner "Telemetry"
491503

492504
if [[ -z ${VOINETWORK_TELEMETRY_NAME} && ! -f "/var/lib/voi/algod/data/logging.config" ]]; then
@@ -513,6 +525,35 @@ set_telemetry_name() {
513525
fi
514526
}
515527

528+
detect_existing_host_based_voi_setup() {
529+
if [[ -f /var/lib/algorand/logging.config && ! -f /var/lib/voi/algod/data/logging.config ]]; then
530+
echo "An existing Voi installation has been detected on your system."
531+
echo "We can migrate your existing telemetry configuration to Voi Swarm."
532+
echo "As part of this process, we will also stop the existing service."
533+
echo "This is necessary to prevent conflicts and ensure that your node can join Voi Swarm as a healthy node."
534+
echo ""
535+
echo "Do you want to migrate your existing setup to Voi Swarm? (yes/no)"
536+
# shellcheck disable=SC2162
537+
read -p "Migrate existing setup: " prompt
538+
while [[ ${prompt} != "yes" && ${prompt} != "no" ]]
539+
do
540+
# shellcheck disable=SC2162
541+
read -p "Type either yes or no: " prompt
542+
done
543+
if [[ ${prompt} == "yes" ]]; then
544+
migrate_host_based_setup=1
545+
fi
546+
fi
547+
}
548+
549+
migrate_host_based_voi_setup() {
550+
if [[ ${migrate_host_based_setup} -eq 1 ]]; then
551+
display_banner "Migrating from host based setup"
552+
VOINETWORK_TELEMETRY_NAME=$(execute_sudo "cat /var/lib/algorand/logging.config" | jq -r '.Name')
553+
bash -c "env VOINETWORK_TELEMETRY_NAME=\"${VOINETWORK_TELEMETRY_NAME}\" ${voi_home}/bin/migrate-from-d13-setup"
554+
fi
555+
}
556+
516557
if [ -z "${BASH_VERSION:-}" ]; then
517558
abort "Bash is required to interpret this script."
518559
fi
@@ -548,6 +589,8 @@ if [[ -n ${VOINETWORK_SKIP_WALLET_SETUP} && ${VOINETWORK_SKIP_WALLET_SETUP} -eq
548589
headless_install=1
549590
fi
550591

592+
display_banner "Welcome to Voi Swarm. Let's get started!"
593+
551594
get_telemetry_name
552595

553596
set_telemetry_name
@@ -669,6 +712,8 @@ if [[ ${skip_account_setup} -eq 0 ]]; then
669712
else
670713
generate_participation_key
671714

715+
migrate_host_based_voi_setup
716+
672717
display_banner "Welcome to Voi!"
673718

674719
joined_network_instructions

0 commit comments

Comments
 (0)