chore: remove obviated l-s scripts

This commit is contained in:
José Oliveira 2021-04-12 21:28:58 +01:00 committed by Josh Harvey
parent c581a56bad
commit c4ea21259a
6 changed files with 1 additions and 175 deletions

View file

@ -1,58 +0,0 @@
#!/usr/bin/env node
const os = require('os')
const readline = require('readline')
const coinUtils = require('../lib/coin-utils')
const db = require('../lib/db')
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
const sql = `select regexp_replace(crypto_code, '$', ' ') as code,regexp_replace(address, '^', ' ') as address from blacklist`
const insertSql = `insert into blacklist(crypto_code, address, created_by_operator) values ($1, $2, 't')`
const makeDimAndReset = '\x1b[2m%s\x1b[0m'
db.query(sql)
.then(many => {
console.log(os.EOL, 'Here is your current list of prohibited addresses:', os.EOL)
console.log(many.map(it => `${it.code} | ${it.address}`).join(os.EOL), os.EOL)
console.log('What address would you like to add to the list?', os.EOL)
console.log(makeDimAndReset, 'Example:', 'bc1q8pu2zlfxg8jf4cyuf844rl3uxmmw8sj9yaa393', os.EOL)
rl.question('Address: ', (address) => {
var aphaNumericRegex = /^([0-9]|[a-z])+([0-9a-z]+)$/i
if (!address.match(aphaNumericRegex)) {
return errorHandler(new Error('Invalid address'))
}
console.log(os.EOL, 'What is the ticker symbol of the coin that this address belongs to?', os.EOL)
console.log(makeDimAndReset, 'Example:', 'BTC', os.EOL)
rl.question('Ticker symbol: ', (cryptoCode) => {
try {
coinUtils.getCryptoCurrency(cryptoCode)
} catch (err) {
errorHandler(err)
}
db.none(insertSql, [cryptoCode, address])
.then(() => db.query(sql))
.then(many2 => {
console.log(os.EOL, `Address added. Here's the new list of prohibited addresses:`, os.EOL)
console.log(many2.map(it => `${it.code} | ${it.address}`).join(os.EOL))
rl.close()
process.exit(0)
})
.catch(errorHandler)
})
})
}).catch(errorHandler)
function errorHandler (err) {
rl.close()
console.log(err)
process.exit(1)
}

View file

@ -1,25 +0,0 @@
#!/usr/bin/env bash
set -e
if [ "$(whoami)" != "root" ]; then
echo -e "This script has to be run as \033[1mroot\033[0m user"
exit 3
fi
read -p "This will DELETE ALL YOUR DATA! Sure? (y/n) " answer
case ${answer:0:1} in
y|Y )
echo "Deleting database..."
su -l postgres <<EOF
dropdb lamassu
createdb lamassu
EOF
rm -f "/etc/lamassu/.migrate"
lamassu-migrate
echo "Done."
;;
* )
echo "No harm done."
;;
esac

View file

@ -1,58 +0,0 @@
#!/usr/bin/env node
const os = require('os')
const readline = require('readline')
const coinUtils = require('../lib/coin-utils')
const db = require('../lib/db')
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
const sql = `select regexp_replace(crypto_code, '$', ' ') as code,regexp_replace(address, '^', ' ') as address from blacklist`
const deleteSql = `delete from blacklist where crypto_code = $1 and address = $2`
const makeDimAndReset = '\x1b[2m%s\x1b[0m'
db.query(sql)
.then(many => {
console.log(os.EOL, 'Here is your current list of prohibited addresses:', os.EOL)
console.log(many.map(it => `${it.code} | ${it.address}`).join(os.EOL), os.EOL)
console.log('What address would you like to remove from the list?', os.EOL)
console.log(makeDimAndReset, 'Example:', 'bc1q8pu2zlfxg8jf4cyuf844rl3uxmmw8sj9yaa393', os.EOL)
rl.question('Address: ', (address) => {
var aphaNumericRegex = /^([0-9]|[a-z])+([0-9a-z]+)$/i
if (!address.match(aphaNumericRegex)) {
return errorHandler(new Error('Invalid address'))
}
console.log(os.EOL, 'What is the ticker symbol of the coin that this address belongs to?', os.EOL)
console.log(makeDimAndReset, 'Example:', 'BTC', os.EOL)
rl.question('Ticker symbol: ', (cryptoCode) => {
try {
coinUtils.getCryptoCurrency(cryptoCode)
} catch (err) {
errorHandler(err)
}
db.none(deleteSql, [cryptoCode, address])
.then(() => db.query(sql))
.then(many2 => {
console.log(os.EOL, `Address removed. Here's the new list of prohibited addresses:`, os.EOL)
console.log(many2.map(it => `${it.code} | ${it.address}`).join(os.EOL))
rl.close()
process.exit(0)
})
.catch(errorHandler)
})
})
}).catch(errorHandler)
function errorHandler (err) {
rl.close()
console.log(err)
process.exit(1)
}

View file

@ -1,20 +0,0 @@
#!/usr/bin/env node
const db = require('../lib/db')
const argv = process.argv.slice(2)
if (argv.length !== 1) {
console.log('Usage: lamassu-revoke <user>')
console.log('Revokes admin panel access from a specific user.')
process.exit(1)
}
const name = argv[0]
const sql = `delete from user_tokens where name = $1 RETURNING *;`
return db.result(sql, [name], r => r.rowCount)
.then(r => {if(r==0){console.log('could not find user.')}
else{console.log(name + ' removed successfully.')}})
.then(() => process.exit(0))

View file

@ -1,9 +0,0 @@
#!/usr/bin/env bash
set -e
if [ "$(whoami)" != "root" ]; then
echo -e "This script has to be run as \033[1mroot\033[0m user"
exit 3
fi
su - postgres -c "psql \"lamassu\" -Atc \"select * from user_tokens\""

View file

@ -101,7 +101,6 @@
"lamassu-backup-pg": "./bin/lamassu-backup-pg", "lamassu-backup-pg": "./bin/lamassu-backup-pg",
"lamassu-mnemonic": "./bin/lamassu-mnemonic", "lamassu-mnemonic": "./bin/lamassu-mnemonic",
"lamassu-cancel": "./bin/lamassu-cancel", "lamassu-cancel": "./bin/lamassu-cancel",
"lamassu-nuke-db": "./bin/lamassu-nuke-db",
"lamassu-coins": "./bin/lamassu-coins", "lamassu-coins": "./bin/lamassu-coins",
"lamassu-ofac-update": "./bin/lamassu-ofac-update", "lamassu-ofac-update": "./bin/lamassu-ofac-update",
"lamassu-send-coins": "./bin/lamassu-send-coins", "lamassu-send-coins": "./bin/lamassu-send-coins",
@ -110,10 +109,7 @@
"lamassu-ofac-update-sources": "./bin/lamassu-ofac-update-sources", "lamassu-ofac-update-sources": "./bin/lamassu-ofac-update-sources",
"lamassu-devices": "./bin/lamassu-devices", "lamassu-devices": "./bin/lamassu-devices",
"lamassu-operator": "./bin/lamassu-operator", "lamassu-operator": "./bin/lamassu-operator",
"lamassu-coinatmradar": "./bin/lamassu-coinatmradar", "lamassu-coinatmradar": "./bin/lamassu-coinatmradar"
"lamassu-users": "./bin/lamassu-users",
"lamassu-blacklist": "./bin/lamassu-blacklist",
"lamassu-revoke": "./bin/lamassu-revoke"
}, },
"scripts": { "scripts": {
"start": "node bin/lamassu-server", "start": "node bin/lamassu-server",