support installing with existing volumes and droplets
This commit is contained in:
parent
ab6f23351d
commit
10b635185d
6 changed files with 23 additions and 12 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
const fs = require('fs')
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
const coinUtils = require('../coin-utils')
|
const coinUtils = require('../coin-utils')
|
||||||
|
|
@ -12,7 +11,7 @@ const coinRec = coinUtils.getCryptoCurrency('BTC')
|
||||||
function setup (dataDir) {
|
function setup (dataDir) {
|
||||||
common.firewall([coinRec.defaultPort])
|
common.firewall([coinRec.defaultPort])
|
||||||
const config = buildConfig()
|
const config = buildConfig()
|
||||||
fs.writeFileSync(path.resolve(dataDir, coinRec.configFile), config)
|
common.writeFile(path.resolve(dataDir, coinRec.configFile), config)
|
||||||
const cmd = `/usr/local/bin/${coinRec.daemon} -datadir=${dataDir}`
|
const cmd = `/usr/local/bin/${coinRec.daemon} -datadir=${dataDir}`
|
||||||
common.writeSupervisorConfig(coinRec, cmd)
|
common.writeSupervisorConfig(coinRec, cmd)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@ module.exports = {
|
||||||
randomPass,
|
randomPass,
|
||||||
fetchAndInstall,
|
fetchAndInstall,
|
||||||
logger,
|
logger,
|
||||||
isInstalledSoftware
|
isInstalledSoftware,
|
||||||
|
writeFile
|
||||||
}
|
}
|
||||||
|
|
||||||
const BINARIES = {
|
const BINARIES = {
|
||||||
|
|
@ -70,7 +71,7 @@ stdout_logfile=/var/log/supervisor/${blockchain}.out.log
|
||||||
environment=HOME="/root"
|
environment=HOME="/root"
|
||||||
`
|
`
|
||||||
|
|
||||||
fs.writeFileSync(`/etc/supervisor/conf.d/${coinRec.code}.conf`, supervisorConfig)
|
writeFile(`/etc/supervisor/conf.d/${coinRec.code}.conf`, supervisorConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
function isInstalledSoftware (coinRec) {
|
function isInstalledSoftware (coinRec) {
|
||||||
|
|
@ -80,7 +81,7 @@ function isInstalledSoftware (coinRec) {
|
||||||
function fetchAndInstall (coinRec) {
|
function fetchAndInstall (coinRec) {
|
||||||
if (isInstalledSoftware(coinRec)) return
|
if (isInstalledSoftware(coinRec)) return
|
||||||
|
|
||||||
const binaries = BINARIES[coinRec.coinRecCode]
|
const binaries = BINARIES[coinRec.cryptoCode]
|
||||||
if (!binaries) throw new Error(`No such coin: ${coinRec.code}`)
|
if (!binaries) throw new Error(`No such coin: ${coinRec.code}`)
|
||||||
|
|
||||||
const url = binaries.url
|
const url = binaries.url
|
||||||
|
|
@ -91,3 +92,15 @@ function fetchAndInstall (coinRec) {
|
||||||
es(`tar -xzf ${downloadFile}`)
|
es(`tar -xzf ${downloadFile}`)
|
||||||
es(`sudo cp ${binDir}/* /usr/local/bin`)
|
es(`sudo cp ${binDir}/* /usr/local/bin`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function writeFile (path, content) {
|
||||||
|
try {
|
||||||
|
fs.writeFileSync(path, content)
|
||||||
|
} catch (err) {
|
||||||
|
if (err.code === 'EEXIST') {
|
||||||
|
logger.info(`${path} exists, skipping.`)
|
||||||
|
}
|
||||||
|
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
const fs = require('fs')
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
const coinUtils = require('../coin-utils')
|
const coinUtils = require('../coin-utils')
|
||||||
|
|
@ -12,7 +11,7 @@ const coinRec = coinUtils.getCryptoCurrency('DASH')
|
||||||
function setup (dataDir) {
|
function setup (dataDir) {
|
||||||
common.firewall([coinRec.defaultPort])
|
common.firewall([coinRec.defaultPort])
|
||||||
const config = buildConfig()
|
const config = buildConfig()
|
||||||
fs.writeFileSync(path.resolve(dataDir, coinRec.configFile), config)
|
common.writeFile(path.resolve(dataDir, coinRec.configFile), config)
|
||||||
const cmd = `/usr/local/bin/${coinRec.daemon} -datadir=${dataDir}`
|
const cmd = `/usr/local/bin/${coinRec.daemon} -datadir=${dataDir}`
|
||||||
common.writeSupervisorConfig(coinRec, cmd)
|
common.writeSupervisorConfig(coinRec, cmd)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,10 @@ function setupCrypto (crypto) {
|
||||||
process.chdir(tmpDir)
|
process.chdir(tmpDir)
|
||||||
common.es('rm -rf *')
|
common.es('rm -rf *')
|
||||||
common.fetchAndInstall(crypto)
|
common.fetchAndInstall(crypto)
|
||||||
|
|
||||||
cryptoPlugin.setup(cryptoDir)
|
cryptoPlugin.setup(cryptoDir)
|
||||||
fs.writeFileSync(installedVolumeFilePath(crypto), '')
|
|
||||||
|
common.writeFile(installedVolumeFilePath(crypto), '')
|
||||||
process.chdir(oldDir)
|
process.chdir(oldDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
const fs = require('fs')
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
const coinUtils = require('../coin-utils')
|
const coinUtils = require('../coin-utils')
|
||||||
|
|
@ -12,7 +11,7 @@ const coinRec = coinUtils.getCryptoCurrency('LTC')
|
||||||
function setup (dataDir) {
|
function setup (dataDir) {
|
||||||
common.firewall([coinRec.defaultPort])
|
common.firewall([coinRec.defaultPort])
|
||||||
const config = buildConfig()
|
const config = buildConfig()
|
||||||
fs.writeFileSync(path.resolve(dataDir, coinRec.configFile), config)
|
common.writeFile(path.resolve(dataDir, coinRec.configFile), config)
|
||||||
const cmd = `/usr/local/bin/${coinRec.daemon} -datadir=${dataDir}`
|
const cmd = `/usr/local/bin/${coinRec.daemon} -datadir=${dataDir}`
|
||||||
common.writeSupervisorConfig(coinRec, cmd)
|
common.writeSupervisorConfig(coinRec, cmd)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
const fs = require('fs')
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
const coinUtils = require('../coin-utils')
|
const coinUtils = require('../coin-utils')
|
||||||
|
|
@ -20,7 +19,7 @@ function setup (dataDir) {
|
||||||
es('zcash-fetch-params 2>&1')
|
es('zcash-fetch-params 2>&1')
|
||||||
logger.info('Finished fetching proofs.')
|
logger.info('Finished fetching proofs.')
|
||||||
const config = buildConfig()
|
const config = buildConfig()
|
||||||
fs.writeFileSync(path.resolve(dataDir, 'zcash.conf'), config)
|
common.writeFile(path.resolve(dataDir, coinRec.configFile), config)
|
||||||
const cmd = `/usr/local/bin/${coinRec.daemon} -datadir=${dataDir}`
|
const cmd = `/usr/local/bin/${coinRec.daemon} -datadir=${dataDir}`
|
||||||
common.writeSupervisorConfig(coinRec, cmd)
|
common.writeSupervisorConfig(coinRec, cmd)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue