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
|
|
@ -12,7 +12,8 @@ module.exports = {
|
|||
randomPass,
|
||||
fetchAndInstall,
|
||||
logger,
|
||||
isInstalledSoftware
|
||||
isInstalledSoftware,
|
||||
writeFile
|
||||
}
|
||||
|
||||
const BINARIES = {
|
||||
|
|
@ -70,7 +71,7 @@ stdout_logfile=/var/log/supervisor/${blockchain}.out.log
|
|||
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) {
|
||||
|
|
@ -80,7 +81,7 @@ function isInstalledSoftware (coinRec) {
|
|||
function fetchAndInstall (coinRec) {
|
||||
if (isInstalledSoftware(coinRec)) return
|
||||
|
||||
const binaries = BINARIES[coinRec.coinRecCode]
|
||||
const binaries = BINARIES[coinRec.cryptoCode]
|
||||
if (!binaries) throw new Error(`No such coin: ${coinRec.code}`)
|
||||
|
||||
const url = binaries.url
|
||||
|
|
@ -91,3 +92,15 @@ function fetchAndInstall (coinRec) {
|
|||
es(`tar -xzf ${downloadFile}`)
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue