From c4ea21259a9fb128f5c3e0362f940c566e19cb2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Mon, 12 Apr 2021 21:28:58 +0100 Subject: [PATCH] chore: remove obviated l-s scripts --- bin/lamassu-blacklist | 58 ------------------------------- bin/lamassu-nuke-db | 25 ------------- bin/lamassu-remove-from-blacklist | 58 ------------------------------- bin/lamassu-revoke | 20 ----------- bin/lamassu-users | 9 ----- package.json | 6 +--- 6 files changed, 1 insertion(+), 175 deletions(-) delete mode 100644 bin/lamassu-blacklist delete mode 100755 bin/lamassu-nuke-db delete mode 100644 bin/lamassu-remove-from-blacklist delete mode 100644 bin/lamassu-revoke delete mode 100644 bin/lamassu-users diff --git a/bin/lamassu-blacklist b/bin/lamassu-blacklist deleted file mode 100644 index 592fac7f..00000000 --- a/bin/lamassu-blacklist +++ /dev/null @@ -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) -} diff --git a/bin/lamassu-nuke-db b/bin/lamassu-nuke-db deleted file mode 100755 index 24084b84..00000000 --- a/bin/lamassu-nuke-db +++ /dev/null @@ -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 < { - 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) -} diff --git a/bin/lamassu-revoke b/bin/lamassu-revoke deleted file mode 100644 index 6b80b243..00000000 --- a/bin/lamassu-revoke +++ /dev/null @@ -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 ') - 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)) diff --git a/bin/lamassu-users b/bin/lamassu-users deleted file mode 100644 index 804a7fdb..00000000 --- a/bin/lamassu-users +++ /dev/null @@ -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\"" diff --git a/package.json b/package.json index ceeae321..b4b118bb 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,6 @@ "lamassu-backup-pg": "./bin/lamassu-backup-pg", "lamassu-mnemonic": "./bin/lamassu-mnemonic", "lamassu-cancel": "./bin/lamassu-cancel", - "lamassu-nuke-db": "./bin/lamassu-nuke-db", "lamassu-coins": "./bin/lamassu-coins", "lamassu-ofac-update": "./bin/lamassu-ofac-update", "lamassu-send-coins": "./bin/lamassu-send-coins", @@ -110,10 +109,7 @@ "lamassu-ofac-update-sources": "./bin/lamassu-ofac-update-sources", "lamassu-devices": "./bin/lamassu-devices", "lamassu-operator": "./bin/lamassu-operator", - "lamassu-coinatmradar": "./bin/lamassu-coinatmradar", - "lamassu-users": "./bin/lamassu-users", - "lamassu-blacklist": "./bin/lamassu-blacklist", - "lamassu-revoke": "./bin/lamassu-revoke" + "lamassu-coinatmradar": "./bin/lamassu-coinatmradar" }, "scripts": { "start": "node bin/lamassu-server",