feat: backport l-c script to install btcd v20 as default and then update to latest
This commit is contained in:
parent
2e1564c23c
commit
adb9be23d6
3 changed files with 48 additions and 6 deletions
|
|
@ -16,13 +16,17 @@ module.exports = {
|
|||
fetchAndInstall,
|
||||
logger,
|
||||
isInstalledSoftware,
|
||||
writeFile
|
||||
writeFile,
|
||||
getBinaries,
|
||||
isUpdateDependent
|
||||
}
|
||||
|
||||
const BINARIES = {
|
||||
BTC: {
|
||||
url: 'https://bitcoincore.org/bin/bitcoin-core-0.20.1/bitcoin-0.20.1-x86_64-linux-gnu.tar.gz',
|
||||
dir: 'bitcoin-0.20.1/bin'
|
||||
defaultUrl: 'https://bitcoincore.org/bin/bitcoin-core-0.20.0/bitcoin-0.20.0-x86_64-linux-gnu.tar.gz',
|
||||
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: {
|
||||
url: 'https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.9-eae3b194.tar.gz',
|
||||
|
|
@ -47,6 +51,8 @@ const BINARIES = {
|
|||
}
|
||||
}
|
||||
|
||||
const coinsUpdateDependent = ['BTC']
|
||||
|
||||
function firewall (ports) {
|
||||
if (!ports || ports.length === 0) throw new Error('No ports supplied')
|
||||
const portsString = ports.join(',')
|
||||
|
|
@ -87,14 +93,15 @@ function isInstalledSoftware (coinRec) {
|
|||
}
|
||||
|
||||
function fetchAndInstall (coinRec) {
|
||||
const requiresUpdate = isUpdateDependent(coinRec.cryptoCode)
|
||||
if (isInstalledSoftware(coinRec)) return
|
||||
|
||||
const binaries = BINARIES[coinRec.cryptoCode]
|
||||
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 binDir = binaries.dir
|
||||
const binDir = requiresUpdate ? binaries.defaultDir : binaries.dir
|
||||
|
||||
es(`wget -q ${url}`)
|
||||
es(`tar -xzf ${downloadFile}`)
|
||||
|
|
@ -121,3 +128,13 @@ function writeFile (path, content) {
|
|||
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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue