diff --git a/bin/migrate-from-d13-setup b/bin/migrate-from-d13-setup new file mode 100755 index 0000000..7b846f5 --- /dev/null +++ b/bin/migrate-from-d13-setup @@ -0,0 +1,41 @@ +#!/bin/bash +is_root=0 + +execute_sudo() { + if [[ ${is_root} -eq 1 ]]; then + bash -c "$1" + else + sudo bash -c "$1" + fi +} + +container_id=$(docker ps -q -f name=voinetwork_algod) +if [ -z "${container_id}" ]; then + echo "AVM container is not running. Please start it first." + exit 1 +fi + +if [[ $(id -u) -eq 0 ]]; then + is_root=1 +fi + +echo "This script will assist migrating your node from D13 based setups to Voi Swarm, if your node is already running D13 based setup." +echo "If you are running a D13 based setup on another service follow guidance in the documentation to migrate to Voi Swarm: https://voinetwork.github.io/voi-swarm/" +echo "" +if [[ -f /var/lib/algorand/logging.config ]]; then + echo "Migrating telemetry configuration" + execute_sudo "cp /var/lib/algorand/logging.config /var/lib/voi/algod/data/logging.config" + if [[ ${is_root} -eq 0 ]]; then + execute_sudo "chgrp docker /var/lib/voi/algod/data/logging.config" + fi +fi + +echo "Stopping Voi.service if available" +execute_sudo "systemctl stop voi" +execute_sudo "systemctl disable voi" +echo "If you want to revert to D13 based setup on this host, you can start the service again by running 'systemctl start voi && systemctl enable voi'" + +echo "Start Voi Swarm" +bash -c "env VOINETWORK_TELEMETRY_NAME=$VOINETWORK_TELEMETRY_NAME docker stack deploy -c ${HOME}/voi/docker/compose.yml voinetwork" + +echo "Changes has been applied to the network. Please wait a minute for the changes to take effect." diff --git a/bin/set-telemetry-name b/bin/set-telemetry-name index bcc1904..6161c58 100755 --- a/bin/set-telemetry-name +++ b/bin/set-telemetry-name @@ -1,10 +1,13 @@ #!/bin/bash +is_root=0 -container_id=$(docker ps -q -f name=voinetwork_algod) -if [ -z "${container_id}" ]; then - echo "AVM container is not running. Please start it first." - exit 1 -fi +execute_sudo() { + if [[ ${is_root} -eq 1 ]]; then + bash -c "$1" + else + sudo bash -c "$1" + fi +} set_telemetry_name() { if [[ -z ${VOINETWORK_TELEMETRY_NAME} ]]; then @@ -27,8 +30,56 @@ set_telemetry_name() { fi } -set_telemetry_name +get_logging_config() { + execute_sudo "cat /var/lib/voi/algod/data/logging.config" +} + +write_logging_config() { + local config_content="$1" + local temp_file + temp_file=$(mktemp) + + echo "${config_content}" > "$temp_file" + execute_sudo "mv $temp_file /var/lib/voi/algod/data/logging.config" + + if [[ ${is_root} -eq 0 ]]; then + execute_sudo "chgrp docker /var/lib/voi/algod/data/logging.config" + fi +} + +update_guid_in_config() { + local guid="$1" + local logging_config + logging_config=$(get_logging_config) + + echo "${logging_config}" | jq --arg guid "${guid}" '.GUID = $guid' +} + +container_id=$(docker ps -q -f name=voinetwork_algod) +if [ -z "${container_id}" ]; then + echo "AVM container is not running. Please start it first." + exit 1 +fi + +if [[ $(id -u) -eq 0 ]]; then + is_root=1 +fi + +if [[ $1 && $2 ]]; then + telemetry_name="${1//\"}" + guid="${2//\"}" + + new_config=$(update_guid_in_config "${guid}") + write_logging_config "${new_config}" + + VOINETWORK_TELEMETRY_NAME="${telemetry_name}" + + echo "Telemetry name set to: $telemetry_name, GUID set to: $guid" +else + set_telemetry_name +fi -bash -c "env VOINETWORK_TELEMETRY_NAME=$VOINETWORK_TELEMETRY_NAME docker stack deploy -c ${HOME}/voi/docker/compose.yml voinetwork" +echo "${VOINETWORK_TELEMETRY_NAME}" +bash -c "env VOINETWORK_TELEMETRY_NAME=\"${VOINETWORK_TELEMETRY_NAME}\" docker stack deploy -c ${HOME}/voi/docker/compose.yml voinetwork" -echo "Changes has been applied to the network. Please wait a minute for the changes to take effect." +echo "Changes has been applied to the network. Please wait a minute for the changes to take effect. Confirm changes by running 'bin/get-telemetry-status' after a minute." diff --git a/docs/migrating.md b/docs/migrating.md new file mode 100644 index 0000000..11a3629 --- /dev/null +++ b/docs/migrating.md @@ -0,0 +1,33 @@ +# Migrating to Voi Swarm + +## From D13 based setups + +=== "Installing on same server" + + To help migrate from D13 based setups, there's a migration command available. This command will + + 1. Duplicate telemetry settings, including existing telemetry name and GUID, without affecting rewards. + 2. Stop the host-based Voi service + 3. Restart Voi Swarm + + To run this command, you must install Voi Swarm first. Then run the following command: + + ```bash + ~/voi/bin/migrate-from-d13-setup + ``` + +=== "Installing on a new server" + + To migrate to a new server, you must first install Voi Swarm on the new server. + + 1. Run the following command on the old server to get the telemetry name and GUID: + + ```bash + sudo ALGORAND_DATA=/var/lib/algorand diagcfg telemetry status + ``` + 2. Copy the telemetry name and GUID to the new server. + 3. Run the following command on the new server to set the telemetry name and GUID: + + ```bash + ~/voi/bin/set-telemetry-name + ``` diff --git a/mkdocs.yml b/mkdocs.yml index aaaa741..becda9f 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -17,6 +17,7 @@ theme: - navigation.instant.progress - content.action.edit - content.code.copy + - content.tabs.link - search.suggest - search.highlight @@ -69,6 +70,11 @@ markdown_extensions: - pymdownx.details - pymdownx.superfences - footnotes + - pymdownx.tabbed: + alternate_style: true + slugify: !!python/object/apply:pymdownx.slugs.slugify + kwds: + case: lower plugins: - search @@ -100,5 +106,6 @@ nav: - Notification Guides: - Pushbullet: notification-guides/pushbullet.md - Provider Guidance: provider-guidance.md + - Migrating: migrating.md - CLI Tools: cli-tools.md - Troubleshooting: troubleshooting.md