From 71e354e9ff6fde5971ec4d514db513b77a832f6b Mon Sep 17 00:00:00 2001 From: Josh Harvey Date: Sun, 6 Aug 2017 23:56:06 +0300 Subject: [PATCH] add wallet backup to coin install --- lib/blockchain/dash.js | 3 ++- lib/blockchain/install.js | 7 +++++++ lib/blockchain/zcash.js | 3 ++- lib/coin-utils.js | 9 ++++++--- package.json | 3 ++- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/blockchain/dash.js b/lib/blockchain/dash.js index 0093540c..6335d71d 100644 --- a/lib/blockchain/dash.js +++ b/lib/blockchain/dash.js @@ -19,5 +19,6 @@ function setup (dataDir) { function buildConfig () { return `rpcuser=lamassuserver rpcpassword=${common.randomPass()} -dbcache=500` +dbcache=500 +keypool=10000` } diff --git a/lib/blockchain/install.js b/lib/blockchain/install.js index 15eff08a..783be5a4 100644 --- a/lib/blockchain/install.js +++ b/lib/blockchain/install.js @@ -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.') } diff --git a/lib/blockchain/zcash.js b/lib/blockchain/zcash.js index 1497f443..60a5a086 100644 --- a/lib/blockchain/zcash.js +++ b/lib/blockchain/zcash.js @@ -29,5 +29,6 @@ function buildConfig () { addnode=mainnet.z.cash rpcuser=lamassuserver rpcpassword=${common.randomPass()} -dbcache=500` +dbcache=500 +keypool=10000` } diff --git a/lib/coin-utils.js b/lib/coin-utils.js index 0364ed88..85cbda75 100644 --- a/lib/coin-utils.js +++ b/lib/coin-utils.js @@ -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) { diff --git a/package.json b/package.json index 89819f22..43834dd6 100644 --- a/package.json +++ b/package.json @@ -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",