Skip to content

Commit c0fc3a5

Browse files
committed
Add script for migrating from local host D13 + allow name and guid overrides for set-telemetry-name (#27)
1 parent f872439 commit c0fc3a5

File tree

4 files changed

+140
-8
lines changed

4 files changed

+140
-8
lines changed

bin/migrate-from-d13-setup

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
is_root=0
3+
4+
execute_sudo() {
5+
if [[ ${is_root} -eq 1 ]]; then
6+
bash -c "$1"
7+
else
8+
sudo bash -c "$1"
9+
fi
10+
}
11+
12+
container_id=$(docker ps -q -f name=voinetwork_algod)
13+
if [ -z "${container_id}" ]; then
14+
echo "AVM container is not running. Please start it first."
15+
exit 1
16+
fi
17+
18+
if [[ $(id -u) -eq 0 ]]; then
19+
is_root=1
20+
fi
21+
22+
echo "This script will assist migrating your node from D13 based setups to Voi Swarm, if your node is already running D13 based setup."
23+
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/"
24+
echo ""
25+
if [[ -f /var/lib/algorand/logging.config ]]; then
26+
echo "Migrating telemetry configuration"
27+
execute_sudo "cp /var/lib/algorand/logging.config /var/lib/voi/algod/data/logging.config"
28+
if [[ ${is_root} -eq 0 ]]; then
29+
execute_sudo "chgrp docker /var/lib/voi/algod/data/logging.config"
30+
fi
31+
fi
32+
33+
echo "Stopping Voi.service if available"
34+
execute_sudo "systemctl stop voi"
35+
execute_sudo "systemctl disable voi"
36+
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'"
37+
38+
echo "Start Voi Swarm"
39+
bash -c "env VOINETWORK_TELEMETRY_NAME=$VOINETWORK_TELEMETRY_NAME docker stack deploy -c ${HOME}/voi/docker/compose.yml voinetwork"
40+
41+
echo "Changes has been applied to the network. Please wait a minute for the changes to take effect."

bin/set-telemetry-name

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#!/bin/bash
2+
is_root=0
23

3-
container_id=$(docker ps -q -f name=voinetwork_algod)
4-
if [ -z "${container_id}" ]; then
5-
echo "AVM container is not running. Please start it first."
6-
exit 1
7-
fi
4+
execute_sudo() {
5+
if [[ ${is_root} -eq 1 ]]; then
6+
bash -c "$1"
7+
else
8+
sudo bash -c "$1"
9+
fi
10+
}
811

912
set_telemetry_name() {
1013
if [[ -z ${VOINETWORK_TELEMETRY_NAME} ]]; then
@@ -27,8 +30,56 @@ set_telemetry_name() {
2730
fi
2831
}
2932

30-
set_telemetry_name
33+
get_logging_config() {
34+
execute_sudo "cat /var/lib/voi/algod/data/logging.config"
35+
}
36+
37+
write_logging_config() {
38+
local config_content="$1"
39+
local temp_file
40+
temp_file=$(mktemp)
41+
42+
echo "${config_content}" > "$temp_file"
43+
execute_sudo "mv $temp_file /var/lib/voi/algod/data/logging.config"
44+
45+
if [[ ${is_root} -eq 0 ]]; then
46+
execute_sudo "chgrp docker /var/lib/voi/algod/data/logging.config"
47+
fi
48+
}
49+
50+
update_guid_in_config() {
51+
local guid="$1"
52+
local logging_config
53+
logging_config=$(get_logging_config)
54+
55+
echo "${logging_config}" | jq --arg guid "${guid}" '.GUID = $guid'
56+
}
57+
58+
container_id=$(docker ps -q -f name=voinetwork_algod)
59+
if [ -z "${container_id}" ]; then
60+
echo "AVM container is not running. Please start it first."
61+
exit 1
62+
fi
63+
64+
if [[ $(id -u) -eq 0 ]]; then
65+
is_root=1
66+
fi
67+
68+
if [[ $1 && $2 ]]; then
69+
telemetry_name="${1//\"}"
70+
guid="${2//\"}"
71+
72+
new_config=$(update_guid_in_config "${guid}")
73+
write_logging_config "${new_config}"
74+
75+
VOINETWORK_TELEMETRY_NAME="${telemetry_name}"
76+
77+
echo "Telemetry name set to: $telemetry_name, GUID set to: $guid"
78+
else
79+
set_telemetry_name
80+
fi
3181

32-
bash -c "env VOINETWORK_TELEMETRY_NAME=$VOINETWORK_TELEMETRY_NAME docker stack deploy -c ${HOME}/voi/docker/compose.yml voinetwork"
82+
echo "${VOINETWORK_TELEMETRY_NAME}"
83+
bash -c "env VOINETWORK_TELEMETRY_NAME=\"${VOINETWORK_TELEMETRY_NAME}\" docker stack deploy -c ${HOME}/voi/docker/compose.yml voinetwork"
3384

34-
echo "Changes has been applied to the network. Please wait a minute for the changes to take effect."
85+
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."

docs/migrating.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Migrating to Voi Swarm
2+
3+
## From D13 based setups
4+
5+
=== "Installing on same server"
6+
7+
To help migrate from D13 based setups, there's a migration command available. This command will
8+
9+
1. Duplicate telemetry settings, including existing telemetry name and GUID, without affecting rewards.
10+
2. Stop the host-based Voi service
11+
3. Restart Voi Swarm
12+
13+
To run this command, you must install Voi Swarm first. Then run the following command:
14+
15+
```bash
16+
~/voi/bin/migrate-from-d13-setup
17+
```
18+
19+
=== "Installing on a new server"
20+
21+
To migrate to a new server, you must first install Voi Swarm on the new server.
22+
23+
1. Run the following command on the old server to get the telemetry name and GUID:
24+
25+
```bash
26+
sudo ALGORAND_DATA=/var/lib/algorand diagcfg telemetry status
27+
```
28+
2. Copy the telemetry name and GUID to the new server.
29+
3. Run the following command on the new server to set the telemetry name and GUID:
30+
31+
```bash
32+
~/voi/bin/set-telemetry-name <telemetry-name> <telemetry-guid>
33+
```

mkdocs.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ theme:
1717
- navigation.instant.progress
1818
- content.action.edit
1919
- content.code.copy
20+
- content.tabs.link
2021
- search.suggest
2122
- search.highlight
2223

@@ -69,6 +70,11 @@ markdown_extensions:
6970
- pymdownx.details
7071
- pymdownx.superfences
7172
- footnotes
73+
- pymdownx.tabbed:
74+
alternate_style: true
75+
slugify: !!python/object/apply:pymdownx.slugs.slugify
76+
kwds:
77+
case: lower
7278

7379
plugins:
7480
- search
@@ -100,5 +106,6 @@ nav:
100106
- Notification Guides:
101107
- Pushbullet: notification-guides/pushbullet.md
102108
- Provider Guidance: provider-guidance.md
109+
- Migrating: migrating.md
103110
- CLI Tools: cli-tools.md
104111
- Troubleshooting: troubleshooting.md

0 commit comments

Comments
 (0)