feat: backport remote BTC node support
This commit is contained in:
parent
24473de6d5
commit
1b6ba5e6dc
15 changed files with 272 additions and 55 deletions
|
|
@ -3,11 +3,16 @@ const os = require('os')
|
|||
const path = require('path')
|
||||
const cp = require('child_process')
|
||||
const fs = require('fs')
|
||||
const makeDir = require('make-dir')
|
||||
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const logger = require('console-log-level')({level: 'info'})
|
||||
|
||||
const { isDevMode } = require('../environment-helper')
|
||||
|
||||
const BLOCKCHAIN_DIR = process.env.BLOCKCHAIN_DIR
|
||||
|
||||
module.exports = {
|
||||
es,
|
||||
writeSupervisorConfig,
|
||||
|
|
@ -106,6 +111,11 @@ function writeSupervisorConfig (coinRec, cmd, walletCmd = '') {
|
|||
}
|
||||
|
||||
function isInstalledSoftware (coinRec) {
|
||||
if (isDevMode()) {
|
||||
return fs.existsSync(`${BLOCKCHAIN_DIR}/${coinRec.code}/${coinRec.configFile}`)
|
||||
&& fs.existsSync(`${BLOCKCHAIN_DIR}/bin/${coinRec.daemon}`)
|
||||
}
|
||||
|
||||
const nodeInstalled = fs.existsSync(`/etc/supervisor/conf.d/${coinRec.code}.conf`)
|
||||
const walletInstalled = _.isNil(coinRec.wallet)
|
||||
? true
|
||||
|
|
@ -127,13 +137,19 @@ function fetchAndInstall (coinRec) {
|
|||
es(`wget -q ${url}`)
|
||||
es(`tar -xf ${downloadFile}`)
|
||||
|
||||
const usrBinDir = isDevMode() ? path.resolve(BLOCKCHAIN_DIR, 'bin') : '/usr/local/bin'
|
||||
|
||||
if (isDevMode()) {
|
||||
makeDir.sync(usrBinDir)
|
||||
}
|
||||
|
||||
if (_.isEmpty(binaries.files)) {
|
||||
es(`sudo cp ${binDir}/* /usr/local/bin`)
|
||||
es(`sudo cp ${binDir}/* ${usrBinDir}`)
|
||||
return
|
||||
}
|
||||
|
||||
_.forEach(([source, target]) => {
|
||||
es(`sudo cp ${binDir}/${source} /usr/local/bin/${target}`)
|
||||
es(`sudo cp ${binDir}/${source} ${usrBinDir}/${target}`)
|
||||
}, binaries.files)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue