@constellation-network/node-pilot 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +26 -15
  2. package/bin/dev.js +1 -6
  3. package/bin/run.js +1 -1
  4. package/dist/base-command.d.ts +9 -0
  5. package/dist/base-command.js +20 -0
  6. package/dist/checks/check-hardware.js +3 -3
  7. package/dist/checks/check-initial-setup.js +2 -0
  8. package/dist/checks/check-layers.js +7 -7
  9. package/dist/checks/check-network.d.ts +2 -0
  10. package/dist/checks/check-network.js +46 -11
  11. package/dist/checks/check-node-ctl.js +4 -4
  12. package/dist/checks/check-project.d.ts +1 -0
  13. package/dist/checks/check-project.js +15 -4
  14. package/dist/checks/check-wallet.d.ts +3 -0
  15. package/dist/checks/check-wallet.js +37 -0
  16. package/dist/clm.d.ts +1 -0
  17. package/dist/clm.js +3 -0
  18. package/dist/commands/config/get.d.ts +6 -0
  19. package/dist/commands/config/get.js +57 -11
  20. package/dist/commands/config/set.d.ts +0 -1
  21. package/dist/commands/config/set.js +13 -11
  22. package/dist/commands/config.js +17 -22
  23. package/dist/commands/info.js +3 -2
  24. package/dist/commands/logs.d.ts +1 -1
  25. package/dist/commands/logs.js +7 -3
  26. package/dist/commands/restart.d.ts +10 -2
  27. package/dist/commands/restart.js +65 -9
  28. package/dist/commands/shutdown.js +3 -3
  29. package/dist/commands/status.js +4 -0
  30. package/dist/commands/test.js +10 -3
  31. package/dist/config-store.d.ts +47 -31
  32. package/dist/config-store.js +98 -42
  33. package/dist/helpers/config-helper.js +2 -2
  34. package/dist/helpers/env-templates.d.ts +4 -3
  35. package/dist/helpers/env-templates.js +28 -20
  36. package/dist/helpers/key-file-helper.d.ts +2 -0
  37. package/dist/helpers/key-file-helper.js +51 -16
  38. package/dist/helpers/project-helper.d.ts +2 -2
  39. package/dist/helpers/project-helper.js +37 -38
  40. package/dist/helpers/prompt-helper.d.ts +0 -1
  41. package/dist/helpers/prompt-helper.js +15 -15
  42. package/dist/services/archiver-service.d.ts +17 -0
  43. package/dist/services/archiver-service.js +104 -0
  44. package/dist/services/cluster-service.d.ts +10 -6
  45. package/dist/services/cluster-service.js +45 -45
  46. package/dist/services/docker-service.d.ts +9 -0
  47. package/dist/{helpers/docker-helper.js → services/docker-service.js} +11 -9
  48. package/dist/services/fastforward-service.js +3 -3
  49. package/dist/services/get-random-node.js +1 -1
  50. package/dist/{helpers/github-helper.d.ts → services/github-service.d.ts} +1 -1
  51. package/dist/{helpers/github-helper.js → services/github-service.js} +1 -1
  52. package/dist/services/node-service.js +14 -14
  53. package/dist/services/notify-service.d.ts +1 -0
  54. package/dist/services/notify-service.js +1 -0
  55. package/dist/services/systemd-service.d.ts +3 -0
  56. package/dist/services/systemd-service.js +45 -0
  57. package/dist/test.d.ts +1 -0
  58. package/dist/test.js +50 -0
  59. package/dist/types.d.ts +6 -0
  60. package/install-dependencies.sh +0 -2
  61. package/oclif.manifest.json +33 -4
  62. package/package.json +9 -8
  63. package/projects/custom/pilot.json +9 -0
  64. package/projects/hypergraph/Dockerfile +24 -18
  65. package/projects/hypergraph/docker-compose.yml +14 -14
  66. package/projects/hypergraph/networks/integrationnet/gl0.env +4 -0
  67. package/projects/hypergraph/networks/integrationnet/gl1.env +4 -0
  68. package/projects/hypergraph/networks/integrationnet/network.env +8 -0
  69. package/projects/hypergraph/networks/{integrationnet.env → integrationnet/source-nodes.env} +1 -9
  70. package/projects/hypergraph/networks/mainnet/gl0.env +4 -0
  71. package/projects/hypergraph/networks/mainnet/gl1.env +4 -0
  72. package/projects/hypergraph/networks/mainnet/network.env +8 -0
  73. package/projects/hypergraph/networks/{mainnet.env → mainnet/source-nodes.env} +0 -8
  74. package/projects/hypergraph/networks/testnet/gl0.env +5 -0
  75. package/projects/hypergraph/networks/testnet/gl1.env +4 -0
  76. package/projects/hypergraph/networks/testnet/network.env +8 -0
  77. package/projects/hypergraph/networks/{testnet.env → testnet/source-nodes.env} +0 -8
  78. package/projects/hypergraph/scripts/check-version.sh +31 -0
  79. package/projects/hypergraph/scripts/install.sh +30 -25
  80. package/projects/hypergraph/seedlist +268 -0
  81. package/scripts/autoheal.sh +8 -0
  82. package/scripts/restart_logger.sh +3 -0
  83. package/scripts/services/io.constellationnetwork.nodepilot.Updater.plist +16 -0
  84. package/scripts/services/node-pilot-autoheal.service +12 -0
  85. package/scripts/services/node-pilot-restarter.service +11 -0
  86. package/scripts/services/node-pilot-updater.service +13 -0
  87. package/scripts/update_logger.sh +3 -0
  88. package/dist/helpers/docker-helper.d.ts +0 -7
  89. package/projects/hypergraph/layers/gl1.env +0 -3
  90. package/projects/scripts/docker-cleanup.sh +0 -64
@@ -51,7 +51,8 @@
51
51
  "args": {
52
52
  "layer": {
53
53
  "description": "network layer to view. e.g. gl0",
54
- "name": "layer"
54
+ "name": "layer",
55
+ "required": true
55
56
  }
56
57
  },
57
58
  "description": "view validator node runtime logs",
@@ -92,12 +93,40 @@
92
93
  },
93
94
  "restart": {
94
95
  "aliases": [],
95
- "args": {},
96
+ "args": {
97
+ "layer": {
98
+ "description": "network layer to restart. e.g. gl0",
99
+ "name": "layer"
100
+ }
101
+ },
96
102
  "description": "A full shutdown of the validator node, then restart",
97
103
  "examples": [
98
104
  "<%= config.bin %> <%= command.id %>"
99
105
  ],
100
- "flags": {},
106
+ "flags": {
107
+ "project": {
108
+ "char": "p",
109
+ "description": "Specify the project name to use",
110
+ "helpGroup": "GLOBAL",
111
+ "name": "project",
112
+ "hasDynamicHelp": false,
113
+ "multiple": false,
114
+ "options": [],
115
+ "type": "option"
116
+ },
117
+ "autostart": {
118
+ "description": "restart each running project if it has been stopped",
119
+ "name": "autostart",
120
+ "allowNo": false,
121
+ "type": "boolean"
122
+ },
123
+ "update": {
124
+ "description": "update each project if a new version is available",
125
+ "name": "update",
126
+ "allowNo": false,
127
+ "type": "boolean"
128
+ }
129
+ },
101
130
  "hasDynamicHelp": false,
102
131
  "hiddenAliases": [],
103
132
  "id": "restart",
@@ -245,5 +274,5 @@
245
274
  ]
246
275
  }
247
276
  },
248
- "version": "0.0.8"
277
+ "version": "0.0.10"
249
278
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@constellation-network/node-pilot",
3
3
  "description": "An easy deployment and monitoring tool for Constellation nodes.",
4
- "version": "0.0.8",
4
+ "version": "0.0.10",
5
5
  "author": "Frank Fox",
6
6
  "bin": {
7
7
  "cpilot": "bin/run.js"
@@ -63,13 +63,14 @@
63
63
  "typescript": "^5"
64
64
  },
65
65
  "files": [
66
- "./bin",
67
- "./dist",
68
- "./oclif.manifest.json",
69
- "./install-dependencies.sh",
70
- "./projects",
71
- "./README.md",
72
- "./LICENSE"
66
+ "bin",
67
+ "dist",
68
+ "oclif.manifest.json",
69
+ "install-dependencies.sh",
70
+ "projects",
71
+ "scripts",
72
+ "README.md",
73
+ "LICENSE"
73
74
  ],
74
75
  "homepage": "https://github.com/Constellation-Labs/node-pilot",
75
76
  "keywords": [
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "custom",
3
+ "projects": [
4
+ { "name": "hg-intnet-1", "network": "intnet", "key": "key1.p12", "layers": "gl0" },
5
+ { "name": "hg-intnet-2", "network": "intnet", "key": "key2.p12", "layers": "gl0" },
6
+ { "name": "hg-intnet-3", "network": "intnet", "key": "key3.p12", "layers": "gl0" }
7
+ ]
8
+ }
9
+
@@ -5,23 +5,28 @@ RUN apt update && apt install -y openjdk-11-jre
5
5
  RUN apt install -y curl jq wget
6
6
 
7
7
  # Install necessary dependencies for adding NodeSource repository
8
- #RUN apt-get update && apt-get install -y gnupg ca-certificates
9
- #
10
- ## Import the NodeSource GPG key
11
- #RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
12
- #
13
- ## Add the NodeSource repository for Node.js 22
14
- #ENV NODE_MAJOR=22
15
- #RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
16
- #
17
- ## Update package lists and install Node.js and npm
18
- #RUN apt-get update && apt-get install -y nodejs
19
- #
20
- ## Verify the installation
21
- #RUN node -v
22
- #RUN npm -v
8
+ RUN apt-get update && apt-get install -y gnupg ca-certificates
23
9
 
10
+ # Import the NodeSource GPG key
11
+ RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
24
12
 
13
+ # Add the NodeSource repository for Node.js 22
14
+ ENV NODE_MAJOR=22
15
+ RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
16
+
17
+ # Update package lists and install Node.js and npm
18
+ RUN apt-get update && apt-get install -y nodejs
19
+
20
+ # Verify the installation
21
+ RUN node -v
22
+ RUN npm -v
23
+
24
+ # Create a directory for global npm packages
25
+ RUN mkdir -p /home/node/.npm-global
26
+ ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
27
+ ENV PATH=$PATH:/home/node/.npm-global/bin
28
+
29
+ # Add app JARS
25
30
  RUN mkdir -p /app/jars
26
31
 
27
32
  COPY dist/keytool.jar /app/jars/keytool.jar
@@ -30,10 +35,11 @@ COPY dist/wallet.jar /app/jars/wallet.jar
30
35
  COPY dist/gl1.jar /app/jars/gl1.jar
31
36
  COPY dist/gl0.jar /app/jars/gl0.jar
32
37
 
33
- COPY ./entrypoint.sh /app/entrypoint.sh
34
-
35
- #COPY ../apps/health-check /health-check
38
+ # Add health-check
39
+ RUN npm install -g "@constellation-network/node-pilot-health-check"
36
40
 
41
+ # Add entrypoint
42
+ COPY ./entrypoint.sh /app/entrypoint.sh
37
43
  RUN chmod +x /app/entrypoint.sh
38
44
 
39
45
  WORKDIR /app
@@ -3,12 +3,15 @@ networks:
3
3
  driver: bridge
4
4
 
5
5
  services:
6
+ autoheal:
7
+ image: willfarrell/autoheal
8
+ volumes:
9
+ - /var/run/docker.sock:/var/run/docker.sock
6
10
  gl0:
7
11
  image: constellationnetwork/tessellation${CL_DOCKER_CORE_REPO:-}:${DOCKER_IMAGE_VERSION:-latest}
8
- container_name: gl0
9
12
  networks:
10
13
  - tessellation-network
11
- # restart: unless-stopped
14
+ restart: unless-stopped
12
15
  env_file:
13
16
  - gl0.env
14
17
  ports:
@@ -19,18 +22,18 @@ services:
19
22
  - ./seedlist:/app/seedlist:ro
20
23
  - ./app-data/gl0-logs:/app/logs
21
24
  - ./app-data/gl0-data:/app/data
22
- - ${CL_DOCKER_PRIORITY_SEEDLIST:-/dev/null}:/app/priority-seedlist:ro
23
- # healthcheck:
24
- # test: ["CMD", "/app/internal-health-check.sh"]
25
- # interval: 15s
26
- # timeout: 5s
27
- # start_period: 30s
25
+ healthcheck:
26
+ test: ["CMD", "cpilotHC"]
27
+ interval: 15s
28
+ retries: 1
29
+ timeout: 15s
30
+ start_period: 30s
28
31
  profiles: ["gl0"]
29
- # user: ${DOCKER_USER_ID:-}
32
+ labels:
33
+ autoheal: "true"
30
34
  gl1:
31
35
  image: constellationnetwork/tessellation${CL_DOCKER_CORE_REPO:-}:${DOCKER_IMAGE_VERSION:-latest}
32
- container_name: gl1
33
- # restart: unless-stopped
36
+ restart: unless-stopped
34
37
  networks:
35
38
  - tessellation-network
36
39
  env_file:
@@ -40,10 +43,8 @@ services:
40
43
  - "9011:9011" # P2P HTTP
41
44
  volumes:
42
45
  - ./key.p12:/app/key.p12:ro
43
- - ./seedlist:/app/seedlist:ro
44
46
  - ./app-data/gl1-logs:/app/logs
45
47
  - ./app-data/gl1-data:/app/data
46
- - ${CL_DOCKER_PRIORITY_SEEDLIST:-/dev/null}:/app/priority-seedlist:ro
47
48
  # healthcheck:
48
49
  # test: ["CMD", "/app/internal-health-check.sh"]
49
50
  # interval: 3s
@@ -51,4 +52,3 @@ services:
51
52
  # retries: 5
52
53
  # start_period: 10s
53
54
  profiles: ["gl1"]
54
- # user: ${DOCKER_USER_ID:-}
@@ -0,0 +1,4 @@
1
+ CL_LB=https://l0-lb-integrationnet.constellationnetwork.io
2
+ CL_PUBLIC_HTTP_PORT=9000
3
+ CL_P2P_HTTP_PORT=9001
4
+ CL_CLI_HTTP_PORT=9002
@@ -0,0 +1,4 @@
1
+ CL_LB=https://l1-lb-integrationnet.constellationnetwork.io
2
+ CL_PUBLIC_HTTP_PORT=9010
3
+ CL_P2P_HTTP_PORT=9011
4
+ CL_CLI_HTTP_PORT=9012
@@ -0,0 +1,8 @@
1
+ CL_APP_ENV=integrationnet
2
+ CL_COLLATERAL=0
3
+ CL_L0_PEER_HTTP_HOST=13.52.205.240
4
+ CL_L0_PEER_ID=e2f4496e5872682d7a55aa06e507a58e96b5d48a5286bfdff7ed780fa464d9e789b2760ecd840f4cb3ee6e1c1d81b2ee844c88dbebf149b1084b7313eb680714
5
+ CL_L0_PEER_HTTP_PORT=9000
6
+ CL_GLOBAL_L0_PEER_HOST=13.52.205.240
7
+ CL_GLOBAL_L0_PEER_ID=e2f4496e5872682d7a55aa06e507a58e96b5d48a5286bfdff7ed780fa464d9e789b2760ecd840f4cb3ee6e1c1d81b2ee844c88dbebf149b1084b7313eb680714
8
+ CL_GLOBAL_L0_PEER_HTTP_PORT=9000
@@ -1,11 +1,3 @@
1
- CL_APP_ENV=integrationnet
2
- CL_COLLATERAL=0
3
- CL_L0_PEER_HTTP_PORT=9000
4
- CL_L0_PEER_HTTP_HOST=13.52.205.240
5
- CL_L0_PEER_ID=e2f4496e5872682d7a55aa06e507a58e96b5d48a5286bfdff7ed780fa464d9e789b2760ecd840f4cb3ee6e1c1d81b2ee844c88dbebf149b1084b7313eb680714
6
- CL_GLOBAL_L0_PEER_HTTP_PORT=9000
7
- CL_GLOBAL_L0_PEER_HOST=13.52.205.240
8
- CL_GLOBAL_L0_PEER_ID=e2f4496e5872682d7a55aa06e507a58e96b5d48a5286bfdff7ed780fa464d9e789b2760ecd840f4cb3ee6e1c1d81b2ee844c88dbebf149b1084b7313eb680714
9
1
  SOURCE_NODE_1_PORT=9000
10
2
  SOURCE_NODE_1_HOST=13.52.205.240
11
3
  SOURCE_NODE_1_ID=e2f4496e5872682d7a55aa06e507a58e96b5d48a5286bfdff7ed780fa464d9e789b2760ecd840f4cb3ee6e1c1d81b2ee844c88dbebf149b1084b7313eb680714
@@ -14,4 +6,4 @@ SOURCE_NODE_2_HOST=50.18.155.22
14
6
  SOURCE_NODE_2_ID=3458a688925a4bd89f2ac2c695362e44d2e0c2903bdbb41b341a4d39283b22d8c85b487bd33cc5d36dbe5e31b5b00a10a6eab802718ead4ed7192ade5a5d1941
15
7
  SOURCE_NODE_3_PORT=9000
16
8
  SOURCE_NODE_3_HOST=52.9.216.57
17
- SOURCE_NODE_3_ID=46daea11ca239cb8c0c8cdeb27db9dbe9c03744908a8a389a60d14df2ddde409260a93334d74957331eec1af323f458b12b3a6c3b8e05885608aae7e3a77eac7
9
+ SOURCE_NODE_3_ID=46daea11ca239cb8c0c8cdeb27db9dbe9c03744908a8a389a60d14df2ddde409260a93334d74957331eec1af323f458b12b3a6c3b8e05885608aae7e3a77eac7
@@ -0,0 +1,4 @@
1
+ CL_LB=https://l0-lb-mainnet.constellationnetwork.io
2
+ CL_PUBLIC_HTTP_PORT=9000
3
+ CL_P2P_HTTP_PORT=9001
4
+ CL_CLI_HTTP_PORT=9002
@@ -0,0 +1,4 @@
1
+ CL_LB=https://l1-lb-mainnet.constellationnetwork.io
2
+ CL_PUBLIC_HTTP_PORT=9010
3
+ CL_P2P_HTTP_PORT=9011
4
+ CL_CLI_HTTP_PORT=9012
@@ -0,0 +1,8 @@
1
+ CL_APP_ENV=mainnet
2
+ CL_COLLATERAL=25000000000000
3
+ CL_L0_PEER_HTTP_PORT=9000
4
+ CL_L0_PEER_HTTP_HOST=52.53.46.33
5
+ CL_L0_PEER_ID=e0c1ee6ec43510f0e16d2969a7a7c074a5c8cdb477c074fe9c32a9aad8cbc8ff1dff60bb81923e0db437d2686a9b65b86c403e6a21fa32b6acc4e61be4d70925
6
+ #CL_GLOBAL_L0_PEER_HTTP_PORT=9000
7
+ #CL_GLOBAL_L0_PEER_HOST=52.53.46.33
8
+ #CL_GLOBAL_L0_PEER_ID=e0c1ee6ec43510f0e16d2969a7a7c074a5c8cdb477c074fe9c32a9aad8cbc8ff1dff60bb81923e0db437d2686a9b65b86c403e6a21fa32b6acc4e61be4d70925
@@ -1,11 +1,3 @@
1
- CL_APP_ENV=mainnet
2
- CL_COLLATERAL=25000000000000
3
- CL_L0_PEER_HTTP_PORT=9000
4
- CL_L0_PEER_HTTP_HOST=52.53.46.33
5
- CL_L0_PEER_ID=e0c1ee6ec43510f0e16d2969a7a7c074a5c8cdb477c074fe9c32a9aad8cbc8ff1dff60bb81923e0db437d2686a9b65b86c403e6a21fa32b6acc4e61be4d70925
6
- CL_GLOBAL_L0_PEER_HTTP_PORT=9000
7
- CL_GLOBAL_L0_PEER_HOST=52.53.46.33
8
- CL_GLOBAL_L0_PEER_ID=e0c1ee6ec43510f0e16d2969a7a7c074a5c8cdb477c074fe9c32a9aad8cbc8ff1dff60bb81923e0db437d2686a9b65b86c403e6a21fa32b6acc4e61be4d70925
9
1
  SOURCE_NODE_1_PORT=9000
10
2
  SOURCE_NODE_1_HOST=52.53.46.33
11
3
  SOURCE_NODE_1_ID=e0c1ee6ec43510f0e16d2969a7a7c074a5c8cdb477c074fe9c32a9aad8cbc8ff1dff60bb81923e0db437d2686a9b65b86c403e6a21fa32b6acc4e61be4d70925
@@ -0,0 +1,5 @@
1
+ CL_LB=https://l0-lb-testnet.constellationnetwork.io
2
+ CL_PUBLIC_HTTP_PORT=9000
3
+ CL_P2P_HTTP_PORT=9001
4
+ CL_CLI_HTTP_PORT=9002
5
+
@@ -0,0 +1,4 @@
1
+ CL_LB=https://l1-lb-testnet.constellationnetwork.io
2
+ CL_PUBLIC_HTTP_PORT=9010
3
+ CL_P2P_HTTP_PORT=9011
4
+ CL_CLI_HTTP_PORT=9012
@@ -0,0 +1,8 @@
1
+ CL_APP_ENV=testnet
2
+ CL_COLLATERAL=0
3
+ CL_L0_PEER_HTTP_PORT=9000
4
+ CL_L0_PEER_HTTP_HOST=52.8.132.193
5
+ CL_L0_PEER_ID=e2f4496e5872682d7a55aa06e507a58e96b5d48a5286bfdff7ed780fa464d9e789b2760ecd840f4cb3ee6e1c1d81b2ee844c88dbebf149b1084b7313eb680714
6
+ #CL_GLOBAL_L0_PEER_HTTP_PORT=9000
7
+ #CL_GLOBAL_L0_PEER_HOST=52.8.132.193
8
+ #CL_GLOBAL_L0_PEER_ID=e2f4496e5872682d7a55aa06e507a58e96b5d48a5286bfdff7ed780fa464d9e789b2760ecd840f4cb3ee6e1c1d81b2ee844c88dbebf149b1084b7313eb680714
@@ -1,11 +1,3 @@
1
- CL_APP_ENV=testnet
2
- CL_COLLATERAL=0
3
- CL_L0_PEER_HTTP_PORT=9000
4
- CL_L0_PEER_HTTP_HOST=52.8.132.193
5
- CL_L0_PEER_ID=e2f4496e5872682d7a55aa06e507a58e96b5d48a5286bfdff7ed780fa464d9e789b2760ecd840f4cb3ee6e1c1d81b2ee844c88dbebf149b1084b7313eb680714
6
- CL_GLOBAL_L0_PEER_HTTP_PORT=9000
7
- CL_GLOBAL_L0_PEER_HOST=52.8.132.193
8
- CL_GLOBAL_L0_PEER_ID=e2f4496e5872682d7a55aa06e507a58e96b5d48a5286bfdff7ed780fa464d9e789b2760ecd840f4cb3ee6e1c1d81b2ee844c88dbebf149b1084b7313eb680714
9
1
  SOURCE_NODE_1_PORT=9000
10
2
  SOURCE_NODE_1_HOST=52.8.132.193
11
3
  SOURCE_NODE_1_ID=e2f4496e5872682d7a55aa06e507a58e96b5d48a5286bfdff7ed780fa464d9e789b2760ecd840f4cb3ee6e1c1d81b2ee844c88dbebf149b1084b7313eb680714
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env bash
2
+
3
+ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4
+ OUTPUT_DIR="$SCRIPT_DIR/../dist" # Directory to save the downloaded assets
5
+
6
+ # load the version from the version file
7
+ if [ -f "$OUTPUT_DIR/version.sh" ]; then
8
+ source "$OUTPUT_DIR/version.sh"
9
+ else
10
+ echo "No version file found."
11
+ exit 1;
12
+ fi
13
+
14
+ if [ -n "${NODE_URL:-}" ]; then
15
+ LB_HTTP="$NODE_URL"
16
+ else
17
+ LB_HTTP="https://l0-lb-$INSTALLED_NETWORK_TYPE.constellationnetwork.io"
18
+ fi
19
+
20
+ echo "Checking version at $LB_HTTP"
21
+ # Check network version
22
+ # Resolve the load balancer URL based on the network and get the release tag
23
+ CLUSTER_NETWORK_VERSION=$(curl -s $LB_HTTP/node/info | jq -r '.version')
24
+
25
+ if [ "$INSTALLED_NETWORK_VERSION" != "$CLUSTER_NETWORK_VERSION" ]; then
26
+ echo "Installed version: $INSTALLED_NETWORK_VERSION"
27
+ echo "Cluster version: $CLUSTER_NETWORK_VERSION"
28
+ exit 1
29
+ fi
30
+
31
+ echo "Version: $INSTALLED_NETWORK_VERSION"
@@ -14,13 +14,14 @@ require() {
14
14
  }
15
15
 
16
16
  NETWORK="${1:-}"
17
- [[ -z "${NETWORK}" ]] && { echo "No network specified."; usage; }
18
17
 
19
- case "$NETWORK" in
20
- mainnet|testnet|integrationnet) ;;
21
- intnet) NETWORK="integrationnet" ;;
22
- *) echo "Invalid network: $NETWORK"; usage ;;
23
- esac
18
+ if [ -n "$NETWORK" ]; then
19
+ case "$NETWORK" in
20
+ mainnet|testnet|integrationnet) ;;
21
+ intnet) NETWORK="integrationnet" ;;
22
+ *) echo "Invalid network: $NETWORK"; usage ;;
23
+ esac
24
+ fi
24
25
 
25
26
  SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
26
27
 
@@ -33,31 +34,35 @@ OUTPUT_DIR="$SCRIPT_DIR/../dist" # Directory to save the downloaded assets
33
34
  # load the version from the version file
34
35
  if [ -f "$OUTPUT_DIR/version.sh" ]; then
35
36
  source "$OUTPUT_DIR/version.sh"
36
- # if argument NETWORK is different from current RELEASE_NETWORK, force download of latest release
37
- if [ -n "$NETWORK" ] && [ "$NETWORK" != "$RELEASE_NETWORK_TYPE" ]; then
38
- echo "Changing network from $RELEASE_NETWORK_TYPE to $NETWORK"
39
- RELEASE_NETWORK_TYPE=""
37
+ # if argument NETWORK is different from current INSTALLED_NETWORK, force download of latest release
38
+ if [ -n "$NETWORK" ] && [ "$NETWORK" != "$INSTALLED_NETWORK_TYPE" ]; then
39
+ echo "Changing network from $INSTALLED_NETWORK_TYPE to $NETWORK"
40
+ INSTALLED_NETWORK_TYPE=""
40
41
  rm -rf $OUTPUT_DIR
41
42
  else
42
- NETWORK="$RELEASE_NETWORK_TYPE"
43
+ NETWORK="$INSTALLED_NETWORK_TYPE"
43
44
  fi
44
45
  else
46
+ [[ -z "${NETWORK}" ]] && { echo "No network specified."; usage; }
45
47
  bash "$SCRIPT_DIR/install-dependencies.sh"
46
- RELEASE_NETWORK_TYPE=""
48
+ INSTALLED_NETWORK_TYPE=""
47
49
  fi
48
50
 
49
51
  require curl
50
52
  require jq
51
53
 
54
+ if [ -n "${NODE_URL:-}" ]; then
55
+ LB_HTTP="$NODE_URL"
56
+ else
57
+ LB_HTTP="https://l0-lb-$NETWORK.constellationnetwork.io"
58
+ fi
52
59
  # Check network version
53
60
  # Resolve the load balancer URL based on the network and get the release tag
54
- LB_HTTP="https://l0-lb-$NETWORK.constellationnetwork.io"
55
- RELEASE=$(curl -s $LB_HTTP/node/info | jq -r '.version')
56
- RELEASE_TAG="v$RELEASE"
61
+ CLUSTER_NETWORK_VERSION=$(curl -s $LB_HTTP/node/info | jq -r '.version')
57
62
 
58
- if [ -n "$RELEASE_NETWORK_TYPE" ] && [ "$RELEASE" != "$RELEASE_NETWORK_VERSION" ]; then
59
- echo "Current release version ($RELEASE) is different from the version in the version file ($RELEASE_NETWORK_VERSION)."
60
- RELEASE_NETWORK_TYPE=""
63
+ if [ -n "$INSTALLED_NETWORK_TYPE" ] && [ "$CLUSTER_NETWORK_VERSION" != "$INSTALLED_NETWORK_VERSION" ]; then
64
+ echo "Current release version ($CLUSTER_NETWORK_VERSION) is different from the version in the version file ($INSTALLED_NETWORK_VERSION)."
65
+ INSTALLED_NETWORK_TYPE=""
61
66
  rm -rf $OUTPUT_DIR
62
67
  fi
63
68
 
@@ -66,19 +71,19 @@ mkdir -p "$OUTPUT_DIR"
66
71
 
67
72
  NETWORK_UC=$(echo "$NETWORK" | tr '[:lower:]' '[:upper:]')
68
73
 
69
- if [ -n "$RELEASE_NETWORK_TYPE" ]; then
70
- echo "Already using the latest release $NETWORK_UC :: $RELEASE"
74
+ if [ -n "$INSTALLED_NETWORK_TYPE" ]; then
75
+ echo "Already using the latest release $NETWORK_UC :: $CLUSTER_NETWORK_VERSION"
71
76
  exit 0
72
77
  fi
73
78
 
74
- echo "Installing latest release: $NETWORK_UC :: $RELEASE"
79
+ echo "Installing latest release: $NETWORK_UC :: $CLUSTER_NETWORK_VERSION"
75
80
 
76
81
 
77
82
  # Resolve the tessellation release download URL based on the network
78
83
  if [ "$NETWORK" == "testnet" ]; then
79
- DOWNLOAD_URL_PREFIX="https://constellationlabs-dag.s3.us-west-1.amazonaws.com/testnet/tessellation/$RELEASE"
84
+ DOWNLOAD_URL_PREFIX="https://constellationlabs-dag.s3.us-west-1.amazonaws.com/testnet/tessellation/$CLUSTER_NETWORK_VERSION"
80
85
  else
81
- DOWNLOAD_URL_PREFIX="https://github.com/Constellation-Labs/tessellation/releases/download/$RELEASE_TAG"
86
+ DOWNLOAD_URL_PREFIX="https://github.com/Constellation-Labs/tessellation/releases/download/v$CLUSTER_NETWORK_VERSION"
82
87
  fi
83
88
 
84
89
  DOWNLOAD_URL="$DOWNLOAD_URL_PREFIX/${ASSETS[0]}"
@@ -137,8 +142,8 @@ write_version_file() {
137
142
  local tmp
138
143
  tmp="$(mktemp "${OUTPUT_DIR}/version.sh.XXXX")"
139
144
  {
140
- echo "RELEASE_NETWORK_TYPE=\"${NETWORK}\""
141
- echo "RELEASE_NETWORK_VERSION=\"${RELEASE}\""
145
+ echo "INSTALLED_NETWORK_TYPE=\"${NETWORK}\""
146
+ echo "INSTALLED_NETWORK_VERSION=\"${CLUSTER_NETWORK_VERSION}\""
142
147
  } > "$tmp"
143
148
  chmod 0644 "$tmp"
144
149
  mv "$tmp" "${OUTPUT_DIR}/version.sh"