Skip to content

Commit

Permalink
Offer migration automatically if same host has a Voi setup (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsoerensen authored Feb 6, 2024
1 parent 9392f02 commit 52e9981
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
5 changes: 4 additions & 1 deletion docs/installation/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
5 changes: 2 additions & 3 deletions docs/migrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 45 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 52e9981

Please sign in to comment.