mirror of
https://github.com/logos-storage/logos-storage-installer.git
synced 2026-01-02 13:33:11 +00:00
working example of marketplace client install and start on win
This commit is contained in:
parent
d017b5a733
commit
77a5da5be8
@ -77,8 +77,8 @@ export class ProcessControl {
|
||||
// Open issue: https://github.com/codex-storage/nim-codex/issues/1206
|
||||
// So we're setting them here.
|
||||
"persistence",
|
||||
`--eth-provider=https://rpc.testnet.codex.storage`,
|
||||
`--eth-private-key=eth.key`
|
||||
`--eth-provider=${this.codexGlobals.getEthProvider()}`,
|
||||
`--eth-private-key=eth.key`, // duplicated in configService.
|
||||
];
|
||||
await this.shell.spawnDetachedProcess(executable, workingDir, args);
|
||||
};
|
||||
|
||||
@ -109,7 +109,12 @@ export async function main() {
|
||||
const configService = new ConfigService(fsService, osService);
|
||||
const codexApp = new CodexApp(configService);
|
||||
const pathSelector = new PathSelector(uiService, new MenuLoop(), fsService);
|
||||
const ethersService = new EthersService(fsService, configService);
|
||||
const ethersService = new EthersService(
|
||||
fsService,
|
||||
configService,
|
||||
osService,
|
||||
shellService,
|
||||
);
|
||||
const marketplaceSetup = new MarketplaceSetup(
|
||||
uiService,
|
||||
configService,
|
||||
|
||||
@ -13,5 +13,5 @@ export class CodexGlobals {
|
||||
|
||||
getEthProvider = () => {
|
||||
return "https://rpc.testnet.codex.storage";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -94,22 +94,18 @@ export class ConfigService {
|
||||
this.fs.writeFile(
|
||||
this.getCodexConfigFilePath(),
|
||||
`data-dir="${datadir}"${nl}` +
|
||||
`log-level="TRACE"${nl}` +
|
||||
`log-file="${codexLogFile}"${nl}` +
|
||||
`storage-quota=${this.config.storageQuota}${nl}` +
|
||||
`disc-port=${this.config.ports.discPort}${nl}` +
|
||||
`listen-addrs=["/ip4/0.0.0.0/tcp/${this.config.ports.listenPort}"]${nl}` +
|
||||
`api-port=${this.config.ports.apiPort}${nl}` +
|
||||
`nat="extip:${publicIp}"${nl}` +
|
||||
`api-cors-origin="*"${nl}` +
|
||||
`bootstrap-node=[${bootNodes}]${nl}` +
|
||||
// Marketplace client parameters:
|
||||
// `[persistence]${nl}` +
|
||||
//`eth-provider="${ethProvider}"${nl}` +
|
||||
// `eth-provider="https://rpc.testnet.codex.storage"${nl}` +
|
||||
// //`eth-private-key="${ethKeyFile}"${nl}` +
|
||||
// `eth-private-key="notafile.no"${nl}` +
|
||||
`${nl}`
|
||||
`log-level="TRACE"${nl}` +
|
||||
`log-file="${codexLogFile}"${nl}` +
|
||||
`storage-quota=${this.config.storageQuota}${nl}` +
|
||||
`disc-port=${this.config.ports.discPort}${nl}` +
|
||||
`listen-addrs=["/ip4/0.0.0.0/tcp/${this.config.ports.listenPort}"]${nl}` +
|
||||
`api-port=${this.config.ports.apiPort}${nl}` +
|
||||
`nat="extip:${publicIp}"${nl}` +
|
||||
`api-cors-origin="*"${nl}` +
|
||||
`bootstrap-node=[${bootNodes}]${nl}` +
|
||||
// Marketplace client parameters cannot be set via config file.
|
||||
// Open issue: https://github.com/codex-storage/nim-codex/issues/1206
|
||||
`${nl}`,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import { ethers } from 'ethers';
|
||||
import { ethers } from "ethers";
|
||||
import crypto from "crypto";
|
||||
|
||||
export class EthersService {
|
||||
constructor(fsService, configService) {
|
||||
constructor(fsService, configService, osService, shellService) {
|
||||
this.fs = fsService;
|
||||
this.configService = configService;
|
||||
this.os = osService;
|
||||
this.shell = shellService;
|
||||
}
|
||||
|
||||
getOrCreateEthKey = () => {
|
||||
@ -27,6 +29,14 @@ export class EthersService {
|
||||
const keys = this.generateKey();
|
||||
this.fs.writeFile(paths.key, keys.key);
|
||||
this.fs.writeFile(paths.address, keys.address);
|
||||
|
||||
if (this.os.isWindows()) {
|
||||
const username = this.os.getUsername();
|
||||
this.shell.run(`icacls ${paths.key} /inheritance:r >nul 2>&1`);
|
||||
this.shell.run(`icacls ${paths.key} /grant:r ${username}:F >nul 2>&1`);
|
||||
} else {
|
||||
this.shell.run(`chmod 600 "${paths.key}"`);
|
||||
}
|
||||
};
|
||||
|
||||
generateKey = () => {
|
||||
|
||||
@ -33,4 +33,8 @@ export class OsService {
|
||||
terminateProcess = (pid) => {
|
||||
process.kill(pid, "SIGTERM");
|
||||
};
|
||||
|
||||
getUsername = () => {
|
||||
return os.userInfo().username;
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user