add wallet backup to coin install

This commit is contained in:
Josh Harvey 2017-08-06 23:56:06 +03:00
parent a5592b612f
commit 71e354e9ff
5 changed files with 19 additions and 6 deletions

View file

@ -19,5 +19,6 @@ function setup (dataDir) {
function buildConfig () {
return `rpcuser=lamassuserver
rpcpassword=${common.randomPass()}
dbcache=500`
dbcache=500
keypool=10000`
}

View file

@ -1,6 +1,7 @@
const fs = require('fs')
const path = require('path')
const process = require('process')
const os = require('os')
const makeDir = require('make-dir')
const inquirer = require('inquirer')
@ -55,6 +56,12 @@ function processCryptos (codes) {
const selectedCryptos = _.map(code => _.find(['code', code], cryptos), codes)
_.forEach(setupCrypto, selectedCryptos)
common.es('sudo service supervisor restart')
const blockchainDir = coinUtils.blockchainDir()
const backupDir = path.resolve(os.homedir(), 'backups')
const rsyncCmd = `echo "@daily rsync -r --prune-empty-dirs --include='*/' --include='wallet.dat' --exclude='*' ${blockchainDir} ${backupDir} > /dev/null" | crontab -`
common.es(rsyncCmd)
logger.info('Installation complete.')
}

View file

@ -29,5 +29,6 @@ function buildConfig () {
addnode=mainnet.z.cash
rpcuser=lamassuserver
rpcpassword=${common.randomPass()}
dbcache=500`
dbcache=500
keypool=10000`
}

View file

@ -52,7 +52,7 @@ const CRYPTO_CURRENCIES = [
}
]
module.exports = {buildUrl, cryptoDir, configPath, cryptoCurrencies, getCryptoCurrency}
module.exports = {buildUrl, cryptoDir, blockchainDir, configPath, cryptoCurrencies, getCryptoCurrency}
function getCryptoCurrency (cryptoCode) {
const cryptoCurrency = _.find(['cryptoCode', cryptoCode], CRYPTO_CURRENCIES)
@ -75,10 +75,13 @@ function buildUrl (cryptoCode, address) {
}
}
function blockchainDir () {
return options.blockchainDir
}
function cryptoDir (cryptoRec) {
const code = cryptoRec.code
const blockchainDir = options.blockchainDir
return path.resolve(blockchainDir, code)
return path.resolve(blockchainDir(), code)
}
function configPath (cryptoRec) {

View file

@ -68,7 +68,8 @@
"lamassu-mnemonic": "./bin/lamassu-mnemonic",
"lamassu-cancel": "./bin/lamassu-cancel",
"lamassu-nuke-db": "./bin/lamassu-nuke-db",
"lamassu-coins": "./bin/lamassu-coins"
"lamassu-coins": "./bin/lamassu-coins",
"lamassu-backup-wallet": "./bin/lamassu-backup-wallet"
},
"scripts": {
"start": "node bin/lamassu-server",