Merge pull request #915 from josepfo/feat/taproot-readiness
feat: backport l-c script to install btcd v20 as default and then upd…
This commit is contained in:
commit
2eabac693b
3 changed files with 48 additions and 6 deletions
|
|
@ -4,7 +4,7 @@ const coinUtils = require('../coin-utils')
|
||||||
|
|
||||||
const common = require('./common')
|
const common = require('./common')
|
||||||
|
|
||||||
module.exports = {setup}
|
module.exports = { setup, updateCore }
|
||||||
|
|
||||||
const coinRec = coinUtils.getCryptoCurrency('BTC')
|
const coinRec = coinUtils.getCryptoCurrency('BTC')
|
||||||
|
|
||||||
|
|
@ -16,6 +16,23 @@ function setup (dataDir) {
|
||||||
common.writeSupervisorConfig(coinRec, cmd)
|
common.writeSupervisorConfig(coinRec, cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateCore (coinRec) {
|
||||||
|
common.logger.info('Updating Bitcoin Core. This may take a minute.')
|
||||||
|
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/`)
|
||||||
|
|
||||||
|
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/bitcoin.tar.gz`)
|
||||||
|
|
||||||
|
common.logger.info('Starting wallet...')
|
||||||
|
common.es(`sudo supervisorctl start bitcoin`)
|
||||||
|
|
||||||
|
common.logger.info('Bitcoin Core is updated!')
|
||||||
|
}
|
||||||
|
|
||||||
function buildConfig () {
|
function buildConfig () {
|
||||||
return `rpcuser=lamassuserver
|
return `rpcuser=lamassuserver
|
||||||
rpcpassword=${common.randomPass()}
|
rpcpassword=${common.randomPass()}
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,17 @@ module.exports = {
|
||||||
fetchAndInstall,
|
fetchAndInstall,
|
||||||
logger,
|
logger,
|
||||||
isInstalledSoftware,
|
isInstalledSoftware,
|
||||||
writeFile
|
writeFile,
|
||||||
|
getBinaries,
|
||||||
|
isUpdateDependent
|
||||||
}
|
}
|
||||||
|
|
||||||
const BINARIES = {
|
const BINARIES = {
|
||||||
BTC: {
|
BTC: {
|
||||||
url: 'https://bitcoincore.org/bin/bitcoin-core-0.20.1/bitcoin-0.20.1-x86_64-linux-gnu.tar.gz',
|
defaultUrl: 'https://bitcoincore.org/bin/bitcoin-core-0.20.0/bitcoin-0.20.0-x86_64-linux-gnu.tar.gz',
|
||||||
dir: 'bitcoin-0.20.1/bin'
|
defaultDir: 'bitcoin-0.20.0/bin',
|
||||||
|
url: 'https://bitcoincore.org/bin/bitcoin-core-22.0/bitcoin-22.0-x86_64-linux-gnu.tar.gz',
|
||||||
|
dir: 'bitcoin-22.0/bin'
|
||||||
},
|
},
|
||||||
ETH: {
|
ETH: {
|
||||||
url: 'https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.11-7231b3ef.tar.gz',
|
url: 'https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.11-7231b3ef.tar.gz',
|
||||||
|
|
@ -47,6 +51,8 @@ const BINARIES = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const coinsUpdateDependent = ['BTC']
|
||||||
|
|
||||||
function firewall (ports) {
|
function firewall (ports) {
|
||||||
if (!ports || ports.length === 0) throw new Error('No ports supplied')
|
if (!ports || ports.length === 0) throw new Error('No ports supplied')
|
||||||
const portsString = ports.join(',')
|
const portsString = ports.join(',')
|
||||||
|
|
@ -89,14 +95,15 @@ function isInstalledSoftware (coinRec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchAndInstall (coinRec) {
|
function fetchAndInstall (coinRec) {
|
||||||
|
const requiresUpdate = isUpdateDependent(coinRec.cryptoCode)
|
||||||
if (isInstalledSoftware(coinRec)) return
|
if (isInstalledSoftware(coinRec)) return
|
||||||
|
|
||||||
const binaries = BINARIES[coinRec.cryptoCode]
|
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 = requiresUpdate ? binaries.defaultUrl : binaries.url
|
||||||
const downloadFile = path.basename(url)
|
const downloadFile = path.basename(url)
|
||||||
const binDir = binaries.dir
|
const binDir = requiresUpdate ? binaries.defaultDir : binaries.dir
|
||||||
|
|
||||||
es(`wget -q ${url}`)
|
es(`wget -q ${url}`)
|
||||||
es(`tar -xzf ${downloadFile}`)
|
es(`tar -xzf ${downloadFile}`)
|
||||||
|
|
@ -123,3 +130,13 @@ function writeFile (path, content) {
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getBinaries (coinCode) {
|
||||||
|
const binaries = BINARIES[coinCode]
|
||||||
|
if (!binaries) throw new Error(`No such coin: ${coinCode}`)
|
||||||
|
return binaries
|
||||||
|
}
|
||||||
|
|
||||||
|
function isUpdateDependent (coinCode) {
|
||||||
|
return _.includes(coinCode, coinsUpdateDependent)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,8 @@ function processCryptos (codes) {
|
||||||
) | crontab -`
|
) | crontab -`
|
||||||
common.es(rsyncCmd)
|
common.es(rsyncCmd)
|
||||||
|
|
||||||
|
_.forEach(updateCrypto, selectedCryptos)
|
||||||
|
|
||||||
logger.info('Installation complete.')
|
logger.info('Installation complete.')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,6 +93,12 @@ function setupCrypto (crypto) {
|
||||||
process.chdir(oldDir)
|
process.chdir(oldDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateCrypto (crypto) {
|
||||||
|
if (!common.isUpdateDependent(crypto.cryptoCode)) return
|
||||||
|
const cryptoPlugin = plugin(crypto)
|
||||||
|
cryptoPlugin.updateCore(common.getBinaries(crypto.cryptoCode))
|
||||||
|
}
|
||||||
|
|
||||||
function plugin (crypto) {
|
function plugin (crypto) {
|
||||||
const plugin = PLUGINS[crypto.cryptoCode]
|
const plugin = PLUGINS[crypto.cryptoCode]
|
||||||
if (!plugin) throw new Error(`No such plugin: ${crypto.cryptoCode}`)
|
if (!plugin) throw new Error(`No such plugin: ${crypto.cryptoCode}`)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue