@constellation-network/node-pilot 0.12.6-devnet → 0.13.0-omegatest.2
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.
- package/README.md +28 -10
- package/dist/checks/check-dependencies.js +7 -7
- package/dist/checks/check-initial-setup.d.ts +2 -0
- package/dist/checks/check-initial-setup.js +46 -0
- package/dist/checks/check-pilot.d.ts +1 -0
- package/dist/checks/check-pilot.js +12 -0
- package/dist/checks/check-project.js +1 -18
- package/dist/commands/config.js +1 -1
- package/dist/commands/status.js +1 -4
- package/dist/commands/uninstall.d.ts +6 -0
- package/dist/commands/uninstall.js +22 -0
- package/dist/helpers/project-helper.js +8 -7
- package/dist/services/migration-service.js +17 -18
- package/dist/services/node-service.d.ts +0 -3
- package/dist/services/node-service.js +14 -12
- package/dist/services/shell-service.js +4 -2
- package/dist/services/systemd-service.d.ts +1 -0
- package/dist/services/systemd-service.js +19 -6
- package/install-dependencies.sh +1 -1
- package/oclif.manifest.json +24 -1
- package/package.json +2 -2
- package/projects/hypergraph/Dockerfile +2 -2
- package/projects/hypergraph/docker-compose.yml +4 -4
- package/scripts/install_services.sh +10 -5
- package/scripts/uninstall_services.sh +37 -0
- package/dist/checks/check-node-ctl.d.ts +0 -5
- package/dist/checks/check-node-ctl.js +0 -88
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ $ npm install -g @constellation-network/node-pilot
|
|
|
21
21
|
$ cpilot COMMAND
|
|
22
22
|
running command...
|
|
23
23
|
$ cpilot (--version|-v)
|
|
24
|
-
@constellation-network/node-pilot/0.
|
|
24
|
+
@constellation-network/node-pilot/0.13.0-omegatest.2 darwin-arm64 node-v22.15.0
|
|
25
25
|
$ cpilot --help [COMMAND]
|
|
26
26
|
USAGE
|
|
27
27
|
$ cpilot COMMAND
|
|
@@ -47,6 +47,7 @@ If no command is entered, node-pilot will automatically perform a series of chec
|
|
|
47
47
|
* [`cpilot restart [LAYER]`](#cpilot-restart-layer)
|
|
48
48
|
* [`cpilot shutdown`](#cpilot-shutdown)
|
|
49
49
|
* [`cpilot status`](#cpilot-status)
|
|
50
|
+
* [`cpilot uninstall`](#cpilot-uninstall)
|
|
50
51
|
|
|
51
52
|
## `cpilot clean [LAYER]`
|
|
52
53
|
|
|
@@ -71,7 +72,7 @@ EXAMPLES
|
|
|
71
72
|
$ cpilot clean
|
|
72
73
|
```
|
|
73
74
|
|
|
74
|
-
_See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.
|
|
75
|
+
_See code: [src/commands/clean.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0-omegatest.2/src/commands/clean.ts)_
|
|
75
76
|
|
|
76
77
|
## `cpilot config`
|
|
77
78
|
|
|
@@ -88,7 +89,7 @@ EXAMPLES
|
|
|
88
89
|
$ cpilot config
|
|
89
90
|
```
|
|
90
91
|
|
|
91
|
-
_See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.
|
|
92
|
+
_See code: [src/commands/config.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0-omegatest.2/src/commands/config.ts)_
|
|
92
93
|
|
|
93
94
|
## `cpilot config get [NAME]`
|
|
94
95
|
|
|
@@ -112,7 +113,7 @@ EXAMPLES
|
|
|
112
113
|
$ cpilot config get gl0:CL_PUBLIC_HTTP_PORT
|
|
113
114
|
```
|
|
114
115
|
|
|
115
|
-
_See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.
|
|
116
|
+
_See code: [src/commands/config/get.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0-omegatest.2/src/commands/config/get.ts)_
|
|
116
117
|
|
|
117
118
|
## `cpilot config set NAME VALUE`
|
|
118
119
|
|
|
@@ -135,7 +136,7 @@ EXAMPLES
|
|
|
135
136
|
$ cpilot config set gl0:CL_PUBLIC_HTTP_PORT 9000
|
|
136
137
|
```
|
|
137
138
|
|
|
138
|
-
_See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.
|
|
139
|
+
_See code: [src/commands/config/set.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0-omegatest.2/src/commands/config/set.ts)_
|
|
139
140
|
|
|
140
141
|
## `cpilot help [COMMAND]`
|
|
141
142
|
|
|
@@ -172,7 +173,7 @@ EXAMPLES
|
|
|
172
173
|
$ cpilot info
|
|
173
174
|
```
|
|
174
175
|
|
|
175
|
-
_See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.
|
|
176
|
+
_See code: [src/commands/info.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0-omegatest.2/src/commands/info.ts)_
|
|
176
177
|
|
|
177
178
|
## `cpilot logs LAYER`
|
|
178
179
|
|
|
@@ -198,7 +199,7 @@ EXAMPLES
|
|
|
198
199
|
$ cpilot logs
|
|
199
200
|
```
|
|
200
201
|
|
|
201
|
-
_See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.
|
|
202
|
+
_See code: [src/commands/logs.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0-omegatest.2/src/commands/logs.ts)_
|
|
202
203
|
|
|
203
204
|
## `cpilot restart [LAYER]`
|
|
204
205
|
|
|
@@ -226,7 +227,7 @@ EXAMPLES
|
|
|
226
227
|
$ cpilot restart
|
|
227
228
|
```
|
|
228
229
|
|
|
229
|
-
_See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.
|
|
230
|
+
_See code: [src/commands/restart.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0-omegatest.2/src/commands/restart.ts)_
|
|
230
231
|
|
|
231
232
|
## `cpilot shutdown`
|
|
232
233
|
|
|
@@ -243,7 +244,7 @@ EXAMPLES
|
|
|
243
244
|
$ cpilot shutdown
|
|
244
245
|
```
|
|
245
246
|
|
|
246
|
-
_See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.
|
|
247
|
+
_See code: [src/commands/shutdown.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0-omegatest.2/src/commands/shutdown.ts)_
|
|
247
248
|
|
|
248
249
|
## `cpilot status`
|
|
249
250
|
|
|
@@ -257,5 +258,22 @@ DESCRIPTION
|
|
|
257
258
|
Display node status and configuration settings
|
|
258
259
|
```
|
|
259
260
|
|
|
260
|
-
_See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.
|
|
261
|
+
_See code: [src/commands/status.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0-omegatest.2/src/commands/status.ts)_
|
|
262
|
+
|
|
263
|
+
## `cpilot uninstall`
|
|
264
|
+
|
|
265
|
+
Uninstall Node Pilot
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
USAGE
|
|
269
|
+
$ cpilot uninstall
|
|
270
|
+
|
|
271
|
+
DESCRIPTION
|
|
272
|
+
Uninstall Node Pilot
|
|
273
|
+
|
|
274
|
+
EXAMPLES
|
|
275
|
+
$ cpilot uninstall
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
_See code: [src/commands/uninstall.ts](https://github.com/Constellation-Labs/node-pilot/blob/v0.13.0-omegatest.2/src/commands/uninstall.ts)_
|
|
261
279
|
<!-- commandsstop -->
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import os from "node:os";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { fileURLToPath } from "node:url";
|
|
5
4
|
import shell from "shelljs";
|
|
@@ -31,12 +30,13 @@ export const checkDependencies = async () => {
|
|
|
31
30
|
clm.echo('');
|
|
32
31
|
process.exit(0);
|
|
33
32
|
}
|
|
34
|
-
const isACLInstalled = await shellService.checkCommandAvailable('setfacl');
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
// const isACLInstalled = await shellService.checkCommandAvailable('setfacl');
|
|
34
|
+
//
|
|
35
|
+
// if (!isACLInstalled && os.platform() === 'linux') {
|
|
36
|
+
// clm.step('ACL is required and needs to be installed.');
|
|
37
|
+
// await promptHelper.doYouWishToContinue();
|
|
38
|
+
// await installDependencies(pilotDir);
|
|
39
|
+
// }
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
async function installDependencies(pilotDir) {
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import { clm } from "../clm.js";
|
|
2
5
|
import { configStore } from "../config-store.js";
|
|
6
|
+
import { shellService } from "../services/shell-service.js";
|
|
3
7
|
import { systemdService } from "../services/systemd-service.js";
|
|
4
8
|
import { checkDependencies } from "./check-dependencies.js";
|
|
5
9
|
import { checkHardware } from "./check-hardware.js";
|
|
10
|
+
import path from "node:path";
|
|
6
11
|
export const checkInitialSetup = {
|
|
12
|
+
async checkExistingUsers() {
|
|
13
|
+
const usersWithPilot = await this.getExistingInstallations();
|
|
14
|
+
if (usersWithPilot.length > 0) {
|
|
15
|
+
clm.warn(`There are other users that have Node Pilot installed.\n ${usersWithPilot.join('\n ')}`);
|
|
16
|
+
clm.warn('To uninstall for another user, login as the user and run "cpilot uninstall".');
|
|
17
|
+
clm.error('Node Pilot can only be installed for one user at a time.\n');
|
|
18
|
+
}
|
|
19
|
+
},
|
|
7
20
|
async firstTimeRun() {
|
|
8
21
|
if (configStore.getSystemInfo() !== null) {
|
|
9
22
|
return;
|
|
10
23
|
}
|
|
11
24
|
await checkDependencies();
|
|
25
|
+
await this.checkExistingUsers();
|
|
12
26
|
console.log(chalk.whiteBright("\n ****************************************"));
|
|
13
27
|
console.log(" " + chalk.whiteBright("CONSTELLATION NETWORK") + " ");
|
|
14
28
|
console.log(" " + chalk.whiteBright("NODE PILOT") + " ");
|
|
@@ -16,4 +30,36 @@ export const checkInitialSetup = {
|
|
|
16
30
|
await checkHardware.systemRequirements();
|
|
17
31
|
await systemdService.install();
|
|
18
32
|
},
|
|
33
|
+
async getExistingInstallations() {
|
|
34
|
+
const platform = os.platform();
|
|
35
|
+
const isLinux = platform === 'linux';
|
|
36
|
+
const homeFolder = isLinux ? '/home' : '/Users';
|
|
37
|
+
if (!fs.existsSync(homeFolder)) {
|
|
38
|
+
clm.warn(`Home folder path does not exist: ${homeFolder}`);
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
const whoami = await shellService.runCommandWithOutput('whoami');
|
|
42
|
+
const userFolders = fs.readdirSync(homeFolder).filter(file => fs.lstatSync(path.join(homeFolder, file)).isDirectory());
|
|
43
|
+
const usersWithPilot = [];
|
|
44
|
+
for (const folder of userFolders) {
|
|
45
|
+
const dirPath = path.join(homeFolder, folder, '.node-pilot');
|
|
46
|
+
// eslint-disable-next-line no-await-in-loop
|
|
47
|
+
const exists = await shellService.runCommandWithOutput(`sudo test -d "${dirPath}" && echo 1 || echo 0`);
|
|
48
|
+
if (exists === '1')
|
|
49
|
+
usersWithPilot.push(folder);
|
|
50
|
+
}
|
|
51
|
+
let rootUserHasPilot = false;
|
|
52
|
+
if (isLinux) {
|
|
53
|
+
const dirPath = path.join('/root', '.node-pilot');
|
|
54
|
+
const exists = await shellService.runCommandWithOutput(`sudo test -d "${dirPath}" && echo 1 || echo 0`);
|
|
55
|
+
if (exists === '1') {
|
|
56
|
+
usersWithPilot.push('root');
|
|
57
|
+
rootUserHasPilot = true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
console.log(`Current user: ${whoami}`);
|
|
61
|
+
console.log(`Users with Node Pilot installed: ${usersWithPilot.join(', ')}`);
|
|
62
|
+
console.log(`Root user has Node Pilot installed: ${rootUserHasPilot}`);
|
|
63
|
+
return usersWithPilot;
|
|
64
|
+
}
|
|
19
65
|
};
|
|
@@ -9,6 +9,7 @@ import { promptHelper } from "../helpers/prompt-helper.js";
|
|
|
9
9
|
import { dockerService } from "../services/docker-service.js";
|
|
10
10
|
import { nodeService } from "../services/node-service.js";
|
|
11
11
|
import { shellService } from "../services/shell-service.js";
|
|
12
|
+
import { checkInitialSetup } from "./check-initial-setup.js";
|
|
12
13
|
const REGISTRY_URL = 'https://registry.npmjs.org/';
|
|
13
14
|
export const checkNodePilot = {
|
|
14
15
|
async checkDiscordRegistration() {
|
|
@@ -18,6 +19,17 @@ export const checkNodePilot = {
|
|
|
18
19
|
await this.promptDiscordRegistration();
|
|
19
20
|
configStore.setProjectFlag('discordChecked', true);
|
|
20
21
|
},
|
|
22
|
+
async checkMultipleUsers() {
|
|
23
|
+
if (configStore.hasProjectFlag('multipleUsersChecked')) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const usersWithPilot = await checkInitialSetup.getExistingInstallations();
|
|
27
|
+
if (usersWithPilot.length > 1) {
|
|
28
|
+
clm.warn(`Multiple users have Node Pilot installed.\n ${usersWithPilot.join('\n ')}`);
|
|
29
|
+
clm.error('Login and run "cpilot uninstall" to remove the extra installation(s).');
|
|
30
|
+
}
|
|
31
|
+
configStore.setProjectFlag('multipleUsersChecked', true);
|
|
32
|
+
},
|
|
21
33
|
async checkVersion() {
|
|
22
34
|
const { currentVer, latestVer } = await this.compareVersions();
|
|
23
35
|
if (!latestVer || !currentVer || latestVer.compare(currentVer) === 0)
|
|
@@ -10,28 +10,11 @@ import { clusterService } from "../services/cluster-service.js";
|
|
|
10
10
|
import { dockerService } from "../services/docker-service.js";
|
|
11
11
|
import { shellService } from "../services/shell-service.js";
|
|
12
12
|
import { checkNetwork } from "./check-network.js";
|
|
13
|
-
/*
|
|
14
|
-
* -Xms12g \
|
|
15
|
-
-Xmx12g \
|
|
16
|
-
-XX:+UseZGC \
|
|
17
|
-
-XX:+ZGenerational \
|
|
18
|
-
-XX:ZAllocationSpikeTolerance=5 \
|
|
19
|
-
-XX:ZCollectionInterval=10 \
|
|
20
|
-
-XX:ConcGCThreads=4 \
|
|
21
|
-
-XX:ParallelGCThreads=8 \
|
|
22
|
-
-XX:+UseStringDeduplication \
|
|
23
|
-
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED \
|
|
24
|
-
--add-opens=java.base/java.util=ALL-UNNAMED \
|
|
25
|
-
--add-opens=java.base/java.security=ALL-UNNAMED \
|
|
26
|
-
-XX:+HeapDumpOnOutOfMemoryError \
|
|
27
|
-
-XX:HeapDumpPath=./heap_dumps/ \
|
|
28
|
-
-XX:+ExitOnOutOfMemoryError
|
|
29
|
-
*/
|
|
30
13
|
function getJavaMemoryOptions(network, mem) {
|
|
31
14
|
if (network === 'testnet') {
|
|
32
15
|
const linuxOpt = (os.platform() === 'linux') ? ' -XX:+UseZGC -XX:+ZGenerational -XX:ZAllocationSpikeTolerance=5 -XX:ZCollectionInterval=10' : '';
|
|
33
16
|
// return `-Xms${mem}g -Xmx${mem}g -XX:+UnlockExperimentalVMOptions${linuxOpt} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./heap_dumps/ -XX:+ExitOnOutOfMemoryError`;
|
|
34
|
-
return `-Xms${mem}g -Xmx${mem}g${linuxOpt} -
|
|
17
|
+
return `-Xms${mem}g -Xmx${mem}g${linuxOpt} -XX:+UseStringDeduplication --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED`;
|
|
35
18
|
}
|
|
36
19
|
return `-Xms1024M -Xmx${mem}g -Xss256K`;
|
|
37
20
|
}
|
package/dist/commands/config.js
CHANGED
|
@@ -25,7 +25,7 @@ export default class Config extends Command {
|
|
|
25
25
|
{ name: 'Java Memory', value: 'javaMemory' },
|
|
26
26
|
{ name: 'Key File', value: 'keyFile' },
|
|
27
27
|
{ name: 'Layers To Run', value: 'layersToRun' },
|
|
28
|
-
{ name: `Network`, value: 'network' },
|
|
28
|
+
{ name: `Hypergraph Network`, value: 'network' },
|
|
29
29
|
],
|
|
30
30
|
message: 'What would you like to change?:',
|
|
31
31
|
});
|
package/dist/commands/status.js
CHANGED
|
@@ -2,15 +2,12 @@ import { Command } from '@oclif/core';
|
|
|
2
2
|
import { checkInitialSetup } from "../checks/check-initial-setup.js";
|
|
3
3
|
import { checkLayers } from "../checks/check-layers.js";
|
|
4
4
|
import { checkNetwork } from "../checks/check-network.js";
|
|
5
|
-
import { checkNodeCtl } from "../checks/check-node-ctl.js";
|
|
6
5
|
import { checkNodePilot } from "../checks/check-pilot.js";
|
|
7
6
|
import { checkProject } from "../checks/check-project.js";
|
|
8
7
|
import { checkWallet } from "../checks/check-wallet.js";
|
|
9
8
|
import { keyFileHelper } from "../helpers/key-file-helper.js";
|
|
10
9
|
import { migrationService } from "../services/migration-service.js";
|
|
11
10
|
export default class Status extends Command {
|
|
12
|
-
// eslint-disable-next-line no-warning-comments
|
|
13
|
-
// TODO add -f flag to continuously monitor status
|
|
14
11
|
static description = 'Display node status and configuration settings';
|
|
15
12
|
async run() {
|
|
16
13
|
await checkInstallationAndConfigurationStatus();
|
|
@@ -19,6 +16,7 @@ export default class Status extends Command {
|
|
|
19
16
|
export async function checkInstallationAndConfigurationStatus() {
|
|
20
17
|
migrationService.runMigrations();
|
|
21
18
|
await checkInitialSetup.firstTimeRun();
|
|
19
|
+
await checkNodePilot.checkMultipleUsers();
|
|
22
20
|
await checkProject.projectInstallation();
|
|
23
21
|
await checkProject.checkJavaMemory();
|
|
24
22
|
await checkNetwork.checkExternalIpAddress();
|
|
@@ -26,7 +24,6 @@ export async function checkInstallationAndConfigurationStatus() {
|
|
|
26
24
|
await checkNodePilot.checkDiscordRegistration();
|
|
27
25
|
await checkNodePilot.checkVersion();
|
|
28
26
|
await checkProject.releaseVersion();
|
|
29
|
-
await checkNodeCtl.check4Migration();
|
|
30
27
|
await keyFileHelper.promptIfNoKeyFile();
|
|
31
28
|
await checkNetwork.checkSeedList();
|
|
32
29
|
await checkNetwork.checkForExistingNodeIdInCluster();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import { clm } from "../clm.js";
|
|
4
|
+
import { promptHelper } from "../helpers/prompt-helper.js";
|
|
5
|
+
import { shellService } from "../services/shell-service.js";
|
|
6
|
+
import { systemdService } from "../services/systemd-service.js";
|
|
7
|
+
export default class Uninstall extends Command {
|
|
8
|
+
static description = 'Uninstall Node Pilot';
|
|
9
|
+
static examples = [
|
|
10
|
+
'<%= config.bin %> <%= command.id %>',
|
|
11
|
+
];
|
|
12
|
+
async run() {
|
|
13
|
+
clm.warn('You are about to uninstall Node Pilot. This will remove all the data and logs from your validator node.');
|
|
14
|
+
await promptHelper.doYouWishToContinue();
|
|
15
|
+
clm.preStep('Uninstalling Node Pilot...');
|
|
16
|
+
await systemdService.uninstall();
|
|
17
|
+
const homeDir = os.homedir();
|
|
18
|
+
const nodePilotDir = `${homeDir}/.node-pilot`;
|
|
19
|
+
await shellService.runCommand(`sudo rm -rf ${nodePilotDir}`);
|
|
20
|
+
console.log("Node Pilot uninstalled successfully.");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -87,14 +87,15 @@ export const projectHelper = {
|
|
|
87
87
|
},
|
|
88
88
|
async installHypergraph() {
|
|
89
89
|
await this.installEmbedded('hypergraph');
|
|
90
|
-
const { projectDir } = configStore.getProjectInfo();
|
|
91
|
-
const { platform } = configStore.getSystemInfo();
|
|
92
90
|
this.prepareDataFolder();
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
// const {projectDir} = configStore.getProjectInfo();
|
|
92
|
+
// const {platform} = configStore.getSystemInfo();
|
|
93
|
+
//
|
|
94
|
+
// if (platform === 'linux') {
|
|
95
|
+
// const layerDir = path.join(projectDir,'gl0');
|
|
96
|
+
// // set permission for group "docker" on the layer folder and any subfolders created later
|
|
97
|
+
// await shellService.runCommand(`sudo setfacl -Rm g:docker:rwX -dm g:docker:rwX ${layerDir}`)
|
|
98
|
+
// }
|
|
98
99
|
this.importEnvFiles();
|
|
99
100
|
},
|
|
100
101
|
async installProject(name, projectFolder) {
|
|
@@ -2,14 +2,10 @@ import semver from "semver";
|
|
|
2
2
|
import packageJson from '../../package.json' with { type: 'json' };
|
|
3
3
|
import { clm } from "../clm.js";
|
|
4
4
|
import { configStore } from "../config-store.js";
|
|
5
|
-
import shell from "shelljs";
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
import { projectHelper } from "../helpers/project-helper.js";
|
|
9
5
|
export const migrationService = {
|
|
10
6
|
runMigrations() {
|
|
11
7
|
const migrations = {
|
|
12
|
-
'0.12.
|
|
8
|
+
'0.12.5': m0125,
|
|
13
9
|
// add more migrations as needed
|
|
14
10
|
};
|
|
15
11
|
const { version = '0.0.0' } = configStore.getProjectInfo();
|
|
@@ -24,6 +20,7 @@ export const migrationService = {
|
|
|
24
20
|
const migrationVersions = Object.keys(migrations)
|
|
25
21
|
.filter(v => semver.gt(v, version) && semver.lte(v, currentVersion.version))
|
|
26
22
|
.sort(semver.compare);
|
|
23
|
+
// TODO shutdown node if migration is in progress
|
|
27
24
|
if (migrationVersions.length > 0) {
|
|
28
25
|
clm.preStep(`Migration versions to run: ${migrationVersions}`);
|
|
29
26
|
for (const version of migrationVersions) {
|
|
@@ -33,18 +30,20 @@ export const migrationService = {
|
|
|
33
30
|
configStore.setProjectInfo({ version: currentVersion.toString() });
|
|
34
31
|
}
|
|
35
32
|
};
|
|
36
|
-
function
|
|
37
|
-
clm.step('Running migration 0.12.
|
|
33
|
+
function m0125() {
|
|
34
|
+
clm.step('Running migration 0.12.5...');
|
|
38
35
|
configStore.setProjectFlag('javaMemoryChecked', false);
|
|
39
|
-
projectHelper.upgradeHypergraph();
|
|
40
|
-
installJava21();
|
|
41
|
-
}
|
|
42
|
-
function installJava21() {
|
|
43
|
-
const pilotDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../..`);
|
|
44
|
-
clm.debug(`Running install-java-21.sh from ${pilotDir}`);
|
|
45
|
-
const result = shell.exec('bash install-java-21.sh', { cwd: pilotDir });
|
|
46
|
-
if (result.code > 0) {
|
|
47
|
-
console.log(result.stderr);
|
|
48
|
-
clm.error(`Failed to install dependencies. Please try again after resolving any errors.`);
|
|
49
|
-
}
|
|
36
|
+
// projectHelper.upgradeHypergraph();
|
|
37
|
+
// installJava21();
|
|
50
38
|
}
|
|
39
|
+
// function installJava21() {
|
|
40
|
+
// const pilotDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../..`);
|
|
41
|
+
// clm.debug(`Running install-java-21.sh from ${pilotDir}`);
|
|
42
|
+
//
|
|
43
|
+
// const result = shell.exec('bash install-java-21.sh', {cwd: pilotDir});
|
|
44
|
+
//
|
|
45
|
+
// if (result.code > 0) {
|
|
46
|
+
// console.log(result.stderr);
|
|
47
|
+
// clm.error(`Failed to install dependencies. Please try again after resolving any errors.`);
|
|
48
|
+
// }
|
|
49
|
+
// }
|
|
@@ -3,9 +3,6 @@ export declare const nodeService: {
|
|
|
3
3
|
getNodeInfo(layer: "first" | TessellationLayer): Promise<NodeInfo>;
|
|
4
4
|
getSnapshotHash(ipAddr: string, ordinal: number): Promise<string>;
|
|
5
5
|
getStatusInfo(layer: TessellationLayer): Promise<TessellationLayer>;
|
|
6
|
-
isPortExposed(port: number): Promise<boolean>;
|
|
7
|
-
isPortInUse(port: number): Promise<boolean>;
|
|
8
|
-
isPortOpen(port: number): Promise<boolean>;
|
|
9
6
|
joinCluster(layer: TessellationLayer): Promise<void>;
|
|
10
7
|
leaveCluster(layer: TessellationLayer): Promise<boolean>;
|
|
11
8
|
leaveClusterAllLayers(): Promise<boolean>;
|
|
@@ -31,18 +31,20 @@ export const nodeService = {
|
|
|
31
31
|
async getStatusInfo(layer) {
|
|
32
32
|
return layer;
|
|
33
33
|
},
|
|
34
|
-
async isPortExposed(port) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
34
|
+
// async isPortExposed(port: number) {
|
|
35
|
+
// const command = configStore.getSystemInfo().platform === 'linux' ? `ss -tuln | grep 0.0.0.0:${port}` : `netstat -an | grep '*.${port}'`;
|
|
36
|
+
// return shellService.runCommandWithOutput(command).then(o => o.length > 0);
|
|
37
|
+
// },
|
|
38
|
+
//
|
|
39
|
+
// async isPortInUse(port: number) {
|
|
40
|
+
// clm.preStep('Making a sudo call to check if a port is in use...');
|
|
41
|
+
// return shellService.runCommandWithOutput(`sudo lsof -i :${port}`).then(Boolean).catch(() => false);
|
|
42
|
+
// },
|
|
43
|
+
//
|
|
44
|
+
// async isPortOpen(port: number) {
|
|
45
|
+
// const command = configStore.getSystemInfo().platform === 'linux' ? `ss -tuln | grep :${port}` : `netstat -an | grep '.${port}'`;
|
|
46
|
+
// return shellService.runCommandWithOutput(command).then(o => o.length > 0);
|
|
47
|
+
// },
|
|
46
48
|
async joinCluster(layer) {
|
|
47
49
|
const { state } = await this.getNodeInfo(layer);
|
|
48
50
|
if (state !== "ReadyToJoin") {
|
|
@@ -46,13 +46,15 @@ export const shellService = {
|
|
|
46
46
|
const result = shell.exec(command, { env: nodeEnv, silent });
|
|
47
47
|
clm.debug(`END ${command}. Exit code: ${result.code}`);
|
|
48
48
|
if (result.code > 0) {
|
|
49
|
-
throw new Error(`Failed running command
|
|
49
|
+
throw new Error(`Failed running command. Exited with error message:\n${result.stderr}`);
|
|
50
50
|
}
|
|
51
51
|
return result;
|
|
52
52
|
},
|
|
53
53
|
async runCommandWithOutput(command, env) {
|
|
54
54
|
const result = await this.runCommand(command, env, true);
|
|
55
|
-
|
|
55
|
+
const output = result.stdout.trim();
|
|
56
|
+
clm.debug(`Command Output: "${output}"`);
|
|
57
|
+
return output;
|
|
56
58
|
},
|
|
57
59
|
async runProjectCommand(command, env, silent = false) {
|
|
58
60
|
const { projectDir } = configStore.getProjectInfo();
|
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
import { clm } from "../clm.js";
|
|
5
|
-
import { configStore } from "../config-store.js";
|
|
6
6
|
import { shellService } from "./shell-service.js";
|
|
7
7
|
export const systemdService = {
|
|
8
8
|
async install() {
|
|
9
|
-
const
|
|
9
|
+
const platform = os.platform();
|
|
10
10
|
if (platform !== 'linux') {
|
|
11
11
|
clm.warn('Node Pilot services can only be installed on Linux systems. Skipping systemd service installation.\n');
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
const
|
|
15
|
-
if (!fs.existsSync(
|
|
16
|
-
clm.error(`Node Pilot install system services script not found: ${
|
|
14
|
+
const scriptFile = path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../scripts/install_services.sh`);
|
|
15
|
+
if (!fs.existsSync(scriptFile)) {
|
|
16
|
+
clm.error(`Node Pilot install system services script not found: ${scriptFile}`);
|
|
17
17
|
}
|
|
18
18
|
clm.preStep('Installing Node Pilot system services...');
|
|
19
|
-
await shellService.runCommand(
|
|
19
|
+
await shellService.runCommand(scriptFile);
|
|
20
20
|
clm.postStep('\nNode Pilot system service started successfully.');
|
|
21
|
+
},
|
|
22
|
+
async uninstall() {
|
|
23
|
+
const platform = os.platform();
|
|
24
|
+
if (platform !== 'linux') {
|
|
25
|
+
clm.warn('Node Pilot services can only be installed on Linux systems. Skipping systemd service uninstallation.\n');
|
|
26
|
+
}
|
|
27
|
+
const scriptFile = path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../scripts/uninstall_services.sh`);
|
|
28
|
+
if (!fs.existsSync(scriptFile)) {
|
|
29
|
+
clm.error(`Node Pilot uninstall system services script not found: ${scriptFile}`);
|
|
30
|
+
}
|
|
31
|
+
clm.preStep('Uninstalling Node Pilot system services...');
|
|
32
|
+
await shellService.runCommand(scriptFile);
|
|
33
|
+
clm.postStep('\nNode Pilot system service uninstalled successfully.');
|
|
21
34
|
}
|
|
22
35
|
};
|
package/install-dependencies.sh
CHANGED
package/oclif.manifest.json
CHANGED
|
@@ -272,6 +272,29 @@
|
|
|
272
272
|
"test.js"
|
|
273
273
|
]
|
|
274
274
|
},
|
|
275
|
+
"uninstall": {
|
|
276
|
+
"aliases": [],
|
|
277
|
+
"args": {},
|
|
278
|
+
"description": "Uninstall Node Pilot",
|
|
279
|
+
"examples": [
|
|
280
|
+
"<%= config.bin %> <%= command.id %>"
|
|
281
|
+
],
|
|
282
|
+
"flags": {},
|
|
283
|
+
"hasDynamicHelp": false,
|
|
284
|
+
"hiddenAliases": [],
|
|
285
|
+
"id": "uninstall",
|
|
286
|
+
"pluginAlias": "@constellation-network/node-pilot",
|
|
287
|
+
"pluginName": "@constellation-network/node-pilot",
|
|
288
|
+
"pluginType": "core",
|
|
289
|
+
"strict": true,
|
|
290
|
+
"enableJsonFlag": false,
|
|
291
|
+
"isESM": true,
|
|
292
|
+
"relativePath": [
|
|
293
|
+
"dist",
|
|
294
|
+
"commands",
|
|
295
|
+
"uninstall.js"
|
|
296
|
+
]
|
|
297
|
+
},
|
|
275
298
|
"config:get": {
|
|
276
299
|
"aliases": [],
|
|
277
300
|
"args": {
|
|
@@ -340,5 +363,5 @@
|
|
|
340
363
|
]
|
|
341
364
|
}
|
|
342
365
|
},
|
|
343
|
-
"version": "0.
|
|
366
|
+
"version": "0.13.0-omegatest.2"
|
|
344
367
|
}
|
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.
|
|
4
|
+
"version": "0.13.0-omegatest.2",
|
|
5
5
|
"author": "Frank Fox",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cpilot": "bin/run.js"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"version": "oclif readme && git add README.md",
|
|
22
22
|
"start": "./bin/dev.js",
|
|
23
23
|
"debug": "DEBUG=true ./bin/dev.js",
|
|
24
|
-
"pub": "npm publish --access public --tag
|
|
24
|
+
"pub": "npm publish --access public --tag omegatest"
|
|
25
25
|
},
|
|
26
26
|
"types": "dist/index.d.ts",
|
|
27
27
|
"engines": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
FROM ubuntu:22.04
|
|
2
2
|
|
|
3
|
-
RUN apt update && apt install -y openjdk-
|
|
3
|
+
RUN apt update && apt install -y openjdk-21-jre
|
|
4
4
|
|
|
5
5
|
RUN apt install -y curl jq wget
|
|
6
6
|
|
|
@@ -39,7 +39,7 @@ COPY dist/gl0.jar /app/jars/gl0.jar
|
|
|
39
39
|
#COPY ./health-check /health-check
|
|
40
40
|
#RUN chmod +x /health-check/bin/run.sh
|
|
41
41
|
#RUN chmod +x /health-check/bin/hydrate.sh
|
|
42
|
-
RUN npm install -g "@constellation-network/node-pilot-health-check@0.0.
|
|
42
|
+
RUN npm install -g "@constellation-network/node-pilot-health-check@0.0.27"
|
|
43
43
|
|
|
44
44
|
# Add entrypoint
|
|
45
45
|
COPY ./entrypoint.sh /app/entrypoint.sh
|
|
@@ -8,7 +8,7 @@ services:
|
|
|
8
8
|
# volumes:
|
|
9
9
|
# - /var/run/docker.sock:/var/run/docker.sock
|
|
10
10
|
gl0:
|
|
11
|
-
image: constellationnetwork/tessellation${CL_DOCKER_CORE_REPO:-}:${DOCKER_IMAGE_VERSION:-
|
|
11
|
+
image: constellationnetwork/tessellation${CL_DOCKER_CORE_REPO:-}:${DOCKER_IMAGE_VERSION:-test}
|
|
12
12
|
networks:
|
|
13
13
|
- tessellation-network
|
|
14
14
|
restart: unless-stopped
|
|
@@ -26,14 +26,14 @@ services:
|
|
|
26
26
|
test: ["CMD", "cpilotHC"]
|
|
27
27
|
# test: ["CMD", "/health-check/bin/run.sh"]
|
|
28
28
|
interval: 15s
|
|
29
|
-
retries:
|
|
29
|
+
retries: 3
|
|
30
30
|
timeout: 15s
|
|
31
31
|
start_period: 60s
|
|
32
32
|
profiles: ["gl0"]
|
|
33
33
|
# labels:
|
|
34
34
|
# autoheal: "true"
|
|
35
35
|
gl1:
|
|
36
|
-
image: constellationnetwork/tessellation${CL_DOCKER_CORE_REPO:-}:${DOCKER_IMAGE_VERSION:-
|
|
36
|
+
image: constellationnetwork/tessellation${CL_DOCKER_CORE_REPO:-}:${DOCKER_IMAGE_VERSION:-test}
|
|
37
37
|
restart: unless-stopped
|
|
38
38
|
networks:
|
|
39
39
|
- tessellation-network
|
|
@@ -50,7 +50,7 @@ services:
|
|
|
50
50
|
test: ["CMD", "cpilotHC"]
|
|
51
51
|
# test: ["CMD", "/health-check/bin/run.sh"]
|
|
52
52
|
interval: 15s
|
|
53
|
-
retries:
|
|
53
|
+
retries: 3
|
|
54
54
|
timeout: 15s
|
|
55
55
|
start_period: 60s
|
|
56
56
|
profiles: ["gl1"]
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
+
set -Eeuo pipefail
|
|
3
|
+
IFS=$'\n\t'
|
|
2
4
|
|
|
3
5
|
# Find cpilot in PATH
|
|
4
6
|
CPILOT=$(command -v cpilot)
|
|
@@ -16,7 +18,7 @@ if [ "$CURRENT_USER" = "root" ]; then
|
|
|
16
18
|
UNIT_TARGET="multi-user.target"
|
|
17
19
|
else
|
|
18
20
|
IS_ROOT=false
|
|
19
|
-
HOME_DIR=$(eval echo
|
|
21
|
+
HOME_DIR=$(eval echo ~"$CURRENT_USER")
|
|
20
22
|
WORKING_DIR="$HOME_DIR/.config/systemd/user"
|
|
21
23
|
UNIT_TARGET="default.target"
|
|
22
24
|
fi
|
|
@@ -24,10 +26,14 @@ fi
|
|
|
24
26
|
BIN_DIRECTORY="$HOME_DIR/.node-pilot/scripts"
|
|
25
27
|
|
|
26
28
|
mkdir -p "$BIN_DIRECTORY"
|
|
27
|
-
|
|
28
|
-
# Create working directory if it doesn't exist
|
|
29
29
|
mkdir -p "$WORKING_DIR"
|
|
30
30
|
|
|
31
|
+
# Only check the first service file for existence
|
|
32
|
+
if [ -f "$WORKING_DIR/restart-unhealthy.service" ]; then
|
|
33
|
+
echo "restart-unhealthy.service already exists in $WORKING_DIR. Skipping installation."
|
|
34
|
+
exit 0
|
|
35
|
+
fi
|
|
36
|
+
|
|
31
37
|
# Create restart-unhealthy.service
|
|
32
38
|
cat << EOF > "$WORKING_DIR/restart-unhealthy.service"
|
|
33
39
|
[Unit]
|
|
@@ -61,7 +67,6 @@ cat << EOF > "$BIN_DIRECTORY/restart-unhealthy.sh"
|
|
|
61
67
|
#!/usr/bin/env bash
|
|
62
68
|
docker ps -q -f health=unhealthy | xargs --no-run-if-empty docker restart
|
|
63
69
|
EOF
|
|
64
|
-
|
|
65
70
|
chmod +x "$BIN_DIRECTORY/restart-unhealthy.sh"
|
|
66
71
|
|
|
67
72
|
# Create node-pilot-autostart.service
|
|
@@ -116,4 +121,4 @@ else
|
|
|
116
121
|
loginctl enable-linger "$CURRENT_USER"
|
|
117
122
|
fi
|
|
118
123
|
#systemctl --user status node-pilot-update.service
|
|
119
|
-
# systemctl --user status restart-unhealthy
|
|
124
|
+
# systemctl --user status restart-unhealthy
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Uninstall Node Pilot systemctl services and timers
|
|
4
|
+
|
|
5
|
+
CURRENT_USER=$(id -un)
|
|
6
|
+
if [ "$CURRENT_USER" = "root" ]; then
|
|
7
|
+
IS_ROOT=true
|
|
8
|
+
WORKING_DIR="/etc/systemd/system"
|
|
9
|
+
else
|
|
10
|
+
IS_ROOT=false
|
|
11
|
+
HOME_DIR=$(eval echo ~$CURRENT_USER)
|
|
12
|
+
WORKING_DIR="$HOME_DIR/.config/systemd/user"
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
SERVICES=(restart-unhealthy.timer restart-unhealthy.service node-pilot-autostart.service node-pilot-update.service)
|
|
16
|
+
|
|
17
|
+
if [ "$IS_ROOT" = true ]; then
|
|
18
|
+
for SERVICE in "${SERVICES[@]}"; do
|
|
19
|
+
systemctl stop "$SERVICE" 2>/dev/null
|
|
20
|
+
systemctl disable "$SERVICE" 2>/dev/null
|
|
21
|
+
rm -f "$WORKING_DIR/$SERVICE"
|
|
22
|
+
echo "$SERVICE uninstalled."
|
|
23
|
+
done
|
|
24
|
+
systemctl daemon-reload
|
|
25
|
+
else
|
|
26
|
+
for SERVICE in "${SERVICES[@]}"; do
|
|
27
|
+
systemctl --user stop "$SERVICE" 2>/dev/null
|
|
28
|
+
systemctl --user disable "$SERVICE" 2>/dev/null
|
|
29
|
+
rm -f "$WORKING_DIR/$SERVICE"
|
|
30
|
+
echo "$SERVICE uninstalled ($CURRENT_USER)."
|
|
31
|
+
done
|
|
32
|
+
systemctl --user daemon-reload
|
|
33
|
+
# Optionally disable linger (uncomment if needed)
|
|
34
|
+
loginctl disable-linger "$CURRENT_USER"
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
echo "Node Pilot services and timers have been uninstalled."
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { input, password } from "@inquirer/prompts";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import fs from "node:fs";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import yaml from "yaml";
|
|
6
|
-
import { clm } from "../clm.js";
|
|
7
|
-
import { configStore } from "../config-store.js";
|
|
8
|
-
import { keyFileHelper } from "../helpers/key-file-helper.js";
|
|
9
|
-
import { promptHelper } from "../helpers/prompt-helper.js";
|
|
10
|
-
import { dockerService } from "../services/docker-service.js";
|
|
11
|
-
import { nodeService } from "../services/node-service.js";
|
|
12
|
-
import { shellService } from "../services/shell-service.js";
|
|
13
|
-
export const checkNodeCtl = {
|
|
14
|
-
async check4Migration() {
|
|
15
|
-
if (configStore.hasProjectFlag('nodeCtlChecked')) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const { name } = configStore.getProjectInfo();
|
|
19
|
-
if (name.toLowerCase() !== 'hypergraph') {
|
|
20
|
-
configStore.setProjectFlag('nodeCtlChecked', true);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const hasNodeAdminUser = fs.existsSync('/home/nodeadmin');
|
|
24
|
-
if (hasNodeAdminUser) {
|
|
25
|
-
const isDockerRunning = await dockerService.isRunning();
|
|
26
|
-
const isPortOpen = await nodeService.isPortInUse(9000);
|
|
27
|
-
clm.step(chalk.bold('NODECTL has been detected.'));
|
|
28
|
-
if (!isDockerRunning && isPortOpen) {
|
|
29
|
-
clm.error('Please shutdown any Nodes being managed by NODECTL before proceeding.');
|
|
30
|
-
}
|
|
31
|
-
const cnPath = path.resolve('/var/tessellation/nodectl/cn-config.yaml');
|
|
32
|
-
if (fs.existsSync(cnPath)) {
|
|
33
|
-
const answer = await input({
|
|
34
|
-
default: 'y',
|
|
35
|
-
message: 'Would you like to import key file from nodectl? (y/n): '
|
|
36
|
-
});
|
|
37
|
-
if (answer.toLowerCase() === 'y') {
|
|
38
|
-
await this.importKeyInfo(cnPath);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
configStore.setProjectFlag('nodeCtlChecked', true);
|
|
43
|
-
},
|
|
44
|
-
async importKeyInfo(cnPath) {
|
|
45
|
-
clm.step('Importing key file from nodectl...');
|
|
46
|
-
try {
|
|
47
|
-
clm.preStep('Making a sudo call to read the nodectl config file...');
|
|
48
|
-
await shellService.runCommand(`sudo chmod +r ${cnPath}`);
|
|
49
|
-
const doc = yaml.parse(fs.readFileSync(cnPath, 'utf8'));
|
|
50
|
-
// console.log(JSON.stringify(doc,null,2));
|
|
51
|
-
// eslint-disable-next-line camelcase
|
|
52
|
-
const { key_location, key_name } = doc.nodectl.global_p12;
|
|
53
|
-
const nodeCtlKeyPath = path.resolve(key_location, key_name);
|
|
54
|
-
clm.debug(`Found key file path in nodectl config file: ${nodeCtlKeyPath}`);
|
|
55
|
-
clm.step('Key file found at ' + chalk.cyan(nodeCtlKeyPath));
|
|
56
|
-
clm.preStep('Importing key file...');
|
|
57
|
-
const { projectDir } = configStore.getProjectInfo();
|
|
58
|
-
const pilotKeyPath = path.join(projectDir, 'key.p12');
|
|
59
|
-
// copy file to home directory, change owner to current user, and make it readable by all
|
|
60
|
-
clm.preStep('Making a sudo call to copy the key file...');
|
|
61
|
-
await shellService.runCommand(`sudo cp ${nodeCtlKeyPath} ${pilotKeyPath}; sudo chown $(whoami) ${pilotKeyPath}; chmod +r ${pilotKeyPath}`);
|
|
62
|
-
await this.promptForKeyFile(pilotKeyPath);
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
console.error(error);
|
|
66
|
-
clm.warn('Failed to import key information from nodectl. You will need to import it manually.');
|
|
67
|
-
await promptHelper.doYouWishToContinue();
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
async promptForKeyFile(pilotKeyPath) {
|
|
71
|
-
// prompt for password
|
|
72
|
-
const keyPassword = await password({ message: 'Enter the key file password:' });
|
|
73
|
-
const keyAlias = await input({ message: 'Enter the key file alias:' });
|
|
74
|
-
configStore.setEnvInfo({ CL_KEYALIAS: keyAlias, CL_KEYSTORE: pilotKeyPath, CL_PASSWORD: keyPassword });
|
|
75
|
-
try {
|
|
76
|
-
const dagAddress = await keyFileHelper.getAddress();
|
|
77
|
-
const nodeId = await keyFileHelper.getId();
|
|
78
|
-
configStore.setProjectInfo({ dagAddress, nodeId });
|
|
79
|
-
}
|
|
80
|
-
catch {
|
|
81
|
-
clm.warn('Failed to unlock the key file. Please check your key file information and try again.');
|
|
82
|
-
fs.rmSync(pilotKeyPath);
|
|
83
|
-
await this.promptForKeyFile(pilotKeyPath);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
clm.postStep('Key file imported successfully.\n');
|
|
87
|
-
}
|
|
88
|
-
};
|