feat: add script to update nodes

This commit is contained in:
José Oliveira 2021-09-07 23:21:25 +01:00
parent 8128f05ffb
commit 84256bce6c
8 changed files with 171 additions and 10 deletions

View file

@ -16,9 +16,9 @@ function setup (dataDir) {
common.writeSupervisorConfig(coinRec, cmd)
}
function updateCore (coinRec) {
common.logger.info('Updating Bitcoin Core. This may take a minute.')
common.es(`sudo supervisorctl stop bitcoin`)
function updateCore (coinRec, isCurrentlyRunning) {
common.logger.info('Updating Bitcoin Core. This may take a minute...')
if (isCurrentlyRunning) common.es(`sudo supervisorctl stop bitcoin`)
common.es(`curl -#o /tmp/bitcoin.tar.gz ${coinRec.url}`)
common.es(`tar -xzf /tmp/bitcoin.tar.gz -C /tmp/`)
@ -27,8 +27,10 @@ function updateCore (coinRec) {
common.es(`rm -r /tmp/${coinRec.dir.replace('/bin', '')}`)
common.es(`rm /tmp/bitcoin.tar.gz`)
common.logger.info('Starting wallet...')
common.es(`sudo supervisorctl start bitcoin`)
if (isCurrentlyRunning) {
common.logger.info('Starting wallet...')
common.es(`sudo supervisorctl start bitcoin`)
}
common.logger.info('Bitcoin Core is updated!')
}

View file

@ -4,7 +4,7 @@ const { utils: coinUtils } = require('lamassu-coins')
const common = require('./common')
module.exports = {setup}
module.exports = { setup, updateCore }
const coinRec = coinUtils.getCryptoCurrency('BCH')
@ -16,6 +16,26 @@ function setup (dataDir) {
common.writeSupervisorConfig(coinRec, cmd)
}
function updateCore (coinRec, isCurrentlyRunning) {
common.logger.info('Updating Bitcoin Cash. This may take a minute...')
if (isCurrentlyRunning) common.es(`sudo supervisorctl stop bitcoincash`)
common.es(`curl -#Lo /tmp/bitcoincash.tar.gz ${coinRec.url}`)
common.es(`tar -xzf /tmp/bitcoincash.tar.gz -C /tmp/`)
common.logger.info('Updating wallet...')
common.es(`cp /tmp/${coinRec.dir}/bitcoind /usr/local/bin/bitcoincashd`)
common.es(`cp /tmp/${coinRec.dir}/bitcoin-cli /usr/local/bin/bitcoincash-cli`)
common.es(`rm -r /tmp/${coinRec.dir.replace('/bin', '')}`)
common.es(`rm /tmp/bitcoincash.tar.gz`)
if (isCurrentlyRunning) {
common.logger.info('Starting wallet...')
common.es(`sudo supervisorctl start bitcoincash`)
}
common.logger.info('Bitcoin Cash is updated!')
}
function buildConfig () {
return `rpcuser=lamassuserver
rpcpassword=${common.randomPass()}

View file

@ -4,7 +4,7 @@ const { utils: coinUtils } = require('lamassu-coins')
const common = require('./common')
module.exports = {setup}
module.exports = { setup, updateCore }
const coinRec = coinUtils.getCryptoCurrency('DASH')
@ -16,6 +16,52 @@ function setup (dataDir) {
common.writeSupervisorConfig(coinRec, cmd)
}
function updateCore (coinRec, isCurrentlyRunning) {
common.logger.info('Updating Dash Core. This may take a minute...')
if (isCurrentlyRunning) common.es(`sudo supervisorctl stop dash`)
common.es(`curl -#Lo /tmp/dash.tar.gz ${coinRec.url}`)
common.es(`tar -xzf /tmp/dash.tar.gz -C /tmp/`)
common.logger.info('Updating wallet...')
common.es(`cp /tmp/${coinRec.dir}/bin/* /usr/local/bin/`)
common.es(`rm -r /tmp/${coinRec.dir.replace('/bin', '')}`)
common.es(`rm /tmp/dash.tar.gz`)
if (common.es(`grep -x "enableprivatesend=." /mnt/blockchains/dash/dash.conf`)) {
common.logger.info(`Switching from 'PrivateSend' to 'CoinJoin'...`)
common.es(`sed -i 's/enableprivatesend/enablecoinjoin/g' /mnt/blockchains/dash/dash.conf`)
} else if (common.es(`grep -x "enablecoinjoin=." /mnt/blockchains/dash/dash.conf`)) {
common.logger.info(`enablecoinjoin already defined, skipping...`)
} else {
common.logger.info(`Enabling CoinJoin in config file...`)
common.es(`echo -e "enablecoinjoin=1" >> /mnt/blockchains/dash/dash.conf`)
}
if (common.es(`grep -x "privatesendautostart=." /mnt/blockchains/dash/dash.conf`)) {
common.logger.info(`Switching from 'PrivateSend' to 'CoinJoin'...`)
common.es(`sed -i 's/privatesendautostart/coinjoinautostart/g' /mnt/blockchains/dash/dash.conf`)
} else if (common.es(`grep -x "coinjoinautostart=." /mnt/blockchains/dash/dash.conf`)) {
common.logger.info(`coinjoinautostart already defined, skipping...`)
} else {
common.logger.info(`Enabling CoinJoin AutoStart in config file...`)
common.es(`echo -e "coinjoinautostart=1" >> /mnt/blockchains/dash/dash.conf`)
}
if (common.es(`grep -x "litemode=." /mnt/blockchains/dash/dash.conf`)) {
common.logger.info(`Switching from 'LiteMode' to 'DisableGovernance'...`)
common.es(`sed -i 's/litemode/disablegovernance/g' /mnt/blockchains/dash/dash.conf`)
} else {
common.es(`echo "disablegovernance already defined, skipping..."`)
}
if (isCurrentlyRunning) {
common.logger.info('Starting wallet...')
common.es(`sudo supervisorctl start dash`)
}
common.logger.info('Dash Core is updated!')
}
function buildConfig () {
return `rpcuser=lamassuserver
rpcpassword=${common.randomPass()}

View file

@ -2,7 +2,26 @@ const { utils: coinUtils } = require('lamassu-coins')
const common = require('./common')
module.exports = {setup}
module.exports = { setup, updateCore }
function updateCore (coinRec, isCurrentlyRunning) {
common.logger.info('Updating the Geth Ethereum wallet. This may take a minute...')
if (isCurrentlyRunning) common.es(`sudo supervisorctl stop ethereum`)
common.es(`curl -#o /tmp/ethereum.tar.gz ${coinRec.url}`)
common.es(`tar -xzf /tmp/ethereum.tar.gz -C /tmp/`)
common.logger.info('Updating wallet...')
common.es(`cp /tmp/${coinRec.dir}/geth /usr/local/bin/geth`)
common.es(`rm -r /tmp/${coinRec.dir}`)
common.es(`rm /tmp/ethereum.tar.gz`)
if (isCurrentlyRunning) {
common.logger.info('Starting wallet...')
common.es(`sudo supervisorctl start ethereum`)
}
common.logger.info('Geth is updated!')
}
function setup (dataDir) {
const coinRec = coinUtils.getCryptoCurrency('ETH')

View file

@ -4,7 +4,7 @@ const { utils: coinUtils } = require('lamassu-coins')
const common = require('./common')
module.exports = {setup}
module.exports = { setup, updateCore }
const coinRec = coinUtils.getCryptoCurrency('LTC')
@ -16,6 +16,25 @@ function setup (dataDir) {
common.writeSupervisorConfig(coinRec, cmd)
}
function updateCore (coinRec, isCurrentlyRunning) {
common.logger.info('Updating Litecoin Core. This may take a minute...')
if (isCurrentlyRunning) common.es(`sudo supervisorctl stop litecoin`)
common.es(`curl -#o /tmp/litecoin.tar.gz ${coinRec.url}`)
common.es(`tar -xzf /tmp/litecoin.tar.gz -C /tmp/`)
common.logger.info('Updating wallet...')
common.es(`cp /tmp/${coinRec.dir}/bin/* /usr/local/bin/`)
common.es(`rm -r /tmp/${coinRec.dir.replace('/bin', '')}`)
common.es(`rm /tmp/litecoin.tar.gz`)
if (isCurrentlyRunning) {
common.logger.info('Starting wallet...')
common.es(`sudo supervisorctl start litecoin`)
}
common.logger.info('Litecoin Core is updated!')
}
function buildConfig () {
return `rpcuser=lamassuserver
rpcpassword=${common.randomPass()}

View file

@ -4,11 +4,30 @@ const { utils: coinUtils } = require('lamassu-coins')
const common = require('./common')
module.exports = {setup}
module.exports = { setup, updateCore }
const es = common.es
const logger = common.logger
function updateCore (coinRec, isCurrentlyRunning) {
common.logger.info('Updating your Zcash wallet. This may take a minute...')
if (isCurrentlyRunning) common.es(`sudo supervisorctl stop zcash`)
common.es(`curl -#Lo /tmp/zcash.tar.gz ${coinRec.url}`)
common.es(`tar -xzf /tmp/zcash.tar.gz -C /tmp/`)
common.logger.info('Updating wallet...')
common.es(`cp /tmp/${coinRec.dir}/* /usr/local/bin/`)
common.es(`rm -r /tmp/${coinRec.dir.replace('/bin', '')}`)
common.es(`rm /tmp/zcash.tar.gz`)
if (isCurrentlyRunning) {
common.logger.info('Starting wallet...')
common.es(`sudo supervisorctl start zcash`)
}
common.logger.info('Zcash is updated!')
}
function setup (dataDir) {
es('sudo apt-get update')
es('sudo apt-get install libgomp1 -y')