Merge pull request #506 from lamassu/dev

merge dev into 7.5.0
This commit is contained in:
Rafael Taranto 2020-11-09 16:11:20 +00:00 committed by GitHub
commit 1ac6f6348d
14 changed files with 59 additions and 132 deletions

View file

@ -1,110 +0,0 @@
#!/usr/bin/env bash
set -e
export LOG_FILE=/tmp/update.$(date +"%Y%m%d").log
export NPM_BIN=$(npm -g bin)
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
rm -f ${LOG_FILE}
decho () {
echo `date +"%H:%M:%S"` $1
echo `date +"%H:%M:%S"` $1 >> ${LOG_FILE}
}
cat <<'FIG'
_
| | __ _ _ __ ___ __ _ ___ ___ _ _ ___ ___ _ ____ _____ _ __
| |/ _` | '_ ` _ \ / _` / __/ __| | | |_____/ __|/ _ \ '__\ \ / / _ \ '__|
| | (_| | | | | | | (_| \__ \__ \ |_| |_____\__ \ __/ | \ V / __/ |
|_|\__,_|_| |_| |_|\__,_|___/___/\__,_| |___/\___|_| \_/ \___|_|
FIG
echo -e "\nStarting \033[1mlamassu-server\033[0m update. This will take a few minutes...\n"
if [ "$(whoami)" != "root" ]; then
echo -e "This script has to be run as \033[1mroot\033[0m user"
exit 3
fi
# Use a lock file so failed scripts cannot be imediately retried
# If not the backup created on this script would be replaced
if ! mkdir /var/lock/lamassu-update; then
echo "Script is locked because of a failure." >&2
exit 1
fi
decho "stopping lamassu-server"
supervisorctl stop lamassu-server >> ${LOG_FILE} 2>&1
supervisorctl stop lamassu-admin-server >> ${LOG_FILE} 2>&1
decho "unlinking ${NPM_BIN}/lamassu* old executables"
find ${NPM_BIN} -type l \( -name "lamassu-*" -or -name "hkdf" \) -exec rm -fv {} \; >> ${LOG_FILE} 2>&1
if [ -d "/usr/lib/node_modules/lamassu-server" ]; then
BKP_NAME=lamassu-server-$(date +%s)
decho "renaming old lamassu-server instance to ${BKP_NAME}"
mv -v "/usr/lib/node_modules/lamassu-server" "/usr/lib/node_modules/${BKP_NAME}" >> ${LOG_FILE} 2>&1
fi
decho "updating node"
npm install n -g >> ${LOG_FILE} 2>&1
n 8 >> ${LOG_FILE} 2>&1
decho "version installed $(node -v)"
export NPM_BIN=$(npm -g bin)
decho "updating lamassu-server#dev"
npm -g install lamassu/lamassu-server#dev --unsafe-perm >> ${LOG_FILE} 2>&1
decho "rebuilding npm deps"
cd $(npm root -g)/lamassu-server/ >> ${LOG_FILE} 2>&1
npm rebuild >> ${LOG_FILE} 2>&1
{
decho "running migration"
lamassu-migrate >> ${LOG_FILE} 2>&1
} || { echo "Failure running migrations" ; exit 1 ; }
lamassu-migrate-config >> ${LOG_FILE} 2>&1
decho "update to mnemonic"
lamassu-update-to-mnemonic --prod >> ${LOG_FILE} 2>&1
decho "update configure frontcamera"
lamassu-configure-frontcamera >> ${LOG_FILE} 2>&1
decho "update ofac sources"
lamassu-ofac-update-sources >> ${LOG_FILE} 2>&1
decho "updating supervisor conf"
perl -i -pe 's/command=.*/command=$ENV{NPM_BIN}\/lamassu-server/g' /etc/supervisor/conf.d/lamassu-server.conf >> ${LOG_FILE} 2>&1
perl -i -pe 's/command=.*/command=$ENV{NPM_BIN}\/lamassu-admin-server/g' /etc/supervisor/conf.d/lamassu-admin-server.conf >> ${LOG_FILE} 2>&1
decho "updating lamassu-server"
supervisorctl update lamassu-server >> ${LOG_FILE} 2>&1
supervisorctl update lamassu-admin-server >> ${LOG_FILE} 2>&1
supervisorctl start lamassu-server >> ${LOG_FILE} 2>&1
supervisorctl start lamassu-admin-server >> ${LOG_FILE} 2>&1
decho "updating backups conf"
BACKUP_CMD=${NPM_BIN}/lamassu-backup-pg
BACKUP_CRON="@daily $BACKUP_CMD > /dev/null"
( (crontab -l 2>/dev/null || echo -n "") | grep -v '@daily.*lamassu-backup-pg'; echo $BACKUP_CRON ) | crontab - >> $LOG_FILE 2>&1
$BACKUP_CMD >> $LOG_FILE 2>&1
decho "updating motd scripts"
set +e
chmod -x /etc/update-motd.d/*-release-upgrade
chmod -x /etc/update-motd.d/*-updates-available
chmod -x /etc/update-motd.d/*-reboot-required
chmod -x /etc/update-motd.d/*-help-text
chmod -x /etc/update-motd.d/*-cloudguest
set -e
# reset terminal to link new executables
hash -r
rm -r /var/lock/lamassu-update
decho "Update complete!"

View file

@ -24,5 +24,6 @@ server=1
connections=40 connections=40
keypool=10000 keypool=10000
prune=4000 prune=4000
daemon=0` daemon=0
addresstype=p2sh-segwit`
} }

View file

@ -24,5 +24,6 @@ server=1
connections=40 connections=40
keypool=10000 keypool=10000
prune=4000 prune=4000
daemon=0` daemon=0
addresstype=p2sh-segwit`
} }

View file

@ -1,5 +1,5 @@
const { gql } = require('apollo-server-express') const { gql } = require('apollo-server-express')
const converter = require('json-2-csv') const { parseAsync } = require('json2csv')
const { GraphQLDateTime } = require('graphql-iso-date') const { GraphQLDateTime } = require('graphql-iso-date')
const { GraphQLJSON, GraphQLJSONObject } = require('graphql-type-json') const { GraphQLJSON, GraphQLJSONObject } = require('graphql-type-json')
const got = require('got') const got = require('got')
@ -261,17 +261,17 @@ const resolvers = {
machineLogs: (...[, { deviceId, from, until, limit, offset }]) => machineLogs: (...[, { deviceId, from, until, limit, offset }]) =>
logs.simpleGetMachineLogs(deviceId, from, until, limit, offset), logs.simpleGetMachineLogs(deviceId, from, until, limit, offset),
machineLogsCsv: (...[, { deviceId, from, until, limit, offset }]) => machineLogsCsv: (...[, { deviceId, from, until, limit, offset }]) =>
logs.simpleGetMachineLogs(deviceId, from, until, limit, offset).then(converter.json2csvAsync), logs.simpleGetMachineLogs(deviceId, from, until, limit, offset).then(parseAsync),
serverVersion: () => serverVersion, serverVersion: () => serverVersion,
uptime: () => supervisor.getAllProcessInfo(), uptime: () => supervisor.getAllProcessInfo(),
serverLogs: (...[, { from, until, limit, offset }]) => serverLogs: (...[, { from, until, limit, offset }]) =>
serverLogs.getServerLogs(from, until, limit, offset), serverLogs.getServerLogs(from, until, limit, offset),
serverLogsCsv: (...[, { from, until, limit, offset }]) => serverLogsCsv: (...[, { from, until, limit, offset }]) =>
serverLogs.getServerLogs(from, until, limit, offset).then(converter.json2csvAsync), serverLogs.getServerLogs(from, until, limit, offset).then(parseAsync),
transactions: (...[, { from, until, limit, offset }]) => transactions: (...[, { from, until, limit, offset }]) =>
transactions.batch(from, until, limit, offset), transactions.batch(from, until, limit, offset),
transactionsCsv: (...[, { from, until, limit, offset }]) => transactionsCsv: (...[, { from, until, limit, offset }]) =>
transactions.batch(from, until, limit, offset).then(converter.json2csvAsync), transactions.batch(from, until, limit, offset).then(parseAsync),
config: () => settingsLoader.loadLatestConfigOrNone(), config: () => settingsLoader.loadLatestConfigOrNone(),
accounts: () => settingsLoader.loadAccounts() accounts: () => settingsLoader.loadAccounts()
}, },

View file

@ -192,8 +192,10 @@ const LogsDownloaderPopover = ({ name, query, args, title, getLogs }) => {
FileSaver.saveAs( FileSaver.saveAs(
blob, blob,
selectedRadio === ALL selectedRadio === ALL
? `${formatDateFile(new Date())}_${name}` ? `${formatDateFile(new Date())}_${name}.csv`
: `${formatDateFile(range.from)}_${formatDateFile(range.until)}_${name}` : `${formatDateFile(range.from)}_${formatDateFile(
range.until
)}_${name}.csv`
) )
} }

View file

@ -70,6 +70,8 @@ function Locales({ isActive, doContinue }) {
data?.cryptoCurrencies || [] data?.cryptoCurrencies || []
) )
const onChangeCoin = (prev, curr, setValue) => setValue(curr)
return ( return (
<div className={classes.wrapper}> <div className={classes.wrapper}>
<TitleSection title="Locales" /> <TitleSection title="Locales" />
@ -85,7 +87,10 @@ function Locales({ isActive, doContinue }) {
save={save} save={save}
validationSchema={schema} validationSchema={schema}
data={[]} data={[]}
elements={mainFields(R.merge(data, { cryptoCurrencies }), () => {})} elements={mainFields(
R.merge(data, { cryptoCurrencies }),
onChangeCoin
)}
/> />
</Section> </Section>
</div> </div>

View file

@ -29,11 +29,11 @@ function Welcome({ doContinue }) {
return ( return (
<div className={classes.welcome}> <div className={classes.welcome}>
<H1 className={classes.title}>Welcome to Lamassu Admin</H1> <H1 className={classes.title}>Welcome to the Lamassu Admin</H1>
<P className={classes.getStarted}> <P className={classes.getStarted}>
To get started, weve put together wizard that will To get you started, weve put together a wizard that will
<br /> <br />
help set up you need before start adding machines. help set up what you need before pairing your machines.
</P> </P>
<Button size="xl" onClick={doContinue}> <Button size="xl" onClick={doContinue}>
Get started Get started

27
package-lock.json generated
View file

@ -6110,6 +6110,23 @@
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
}, },
"json2csv": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/json2csv/-/json2csv-5.0.3.tgz",
"integrity": "sha512-e3gEZU/4fp8CVQMHlwT77RayAR7nylCzCYN7jTIbPTEqk0oTaE8GTcBudLgXrHt4ltOs9SAsbveMJT0YK/QUSg==",
"requires": {
"commander": "^6.1.0",
"jsonparse": "^1.3.1",
"lodash.get": "^4.4.2"
},
"dependencies": {
"commander": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-6.2.0.tgz",
"integrity": "sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q=="
}
}
},
"jsonfile": { "jsonfile": {
"version": "2.4.0", "version": "2.4.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
@ -6118,6 +6135,11 @@
"graceful-fs": "^4.1.6" "graceful-fs": "^4.1.6"
} }
}, },
"jsonparse": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz",
"integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA="
},
"jsonschema": { "jsonschema": {
"version": "1.2.2", "version": "1.2.2",
"resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.2.2.tgz", "resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.2.2.tgz",
@ -6357,6 +6379,11 @@
"integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=",
"dev": true "dev": true
}, },
"lodash.get": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
},
"lodash.includes": { "lodash.includes": {
"version": "4.3.0", "version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",

View file

@ -36,7 +36,7 @@
"graphql-type-json": "^0.3.1", "graphql-type-json": "^0.3.1",
"helmet": "^3.8.1", "helmet": "^3.8.1",
"inquirer": "^5.2.0", "inquirer": "^5.2.0",
"json-2-csv": "^3.7.8", "json2csv": "^5.0.3",
"kraken-api": "github:DeX3/npm-kraken-api", "kraken-api": "github:DeX3/npm-kraken-api",
"libphonenumber-js": "^1.7.38", "libphonenumber-js": "^1.7.38",
"lnd-async": "^1.8.0", "lnd-async": "^1.8.0",
@ -92,7 +92,6 @@
"lamassu-cancel": "./bin/lamassu-cancel", "lamassu-cancel": "./bin/lamassu-cancel",
"lamassu-nuke-db": "./bin/lamassu-nuke-db", "lamassu-nuke-db": "./bin/lamassu-nuke-db",
"lamassu-coins": "./bin/lamassu-coins", "lamassu-coins": "./bin/lamassu-coins",
"lamassu-update": "./bin/lamassu-update",
"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",
"lamassu-update-to-mnemonic": "./bin/lamassu-update-to-mnemonic", "lamassu-update-to-mnemonic": "./bin/lamassu-update-to-mnemonic",
@ -115,7 +114,9 @@
"watch": "concurrently \"npm:server\" \"npm:admin-server\" \"npm:graphql-server\"" "watch": "concurrently \"npm:server\" \"npm:admin-server\" \"npm:graphql-server\""
}, },
"nodemonConfig": { "nodemonConfig": {
"ignore": ["new-lamassu-admin/*"] "ignore": [
"new-lamassu-admin/*"
]
}, },
"devDependencies": { "devDependencies": {
"ava": "3.8.2", "ava": "3.8.2",

View file

@ -1,7 +1,7 @@
{ {
"files": { "files": {
"main.js": "/static/js/main.7f48381f.chunk.js", "main.js": "/static/js/main.d0c68b02.chunk.js",
"main.js.map": "/static/js/main.7f48381f.chunk.js.map", "main.js.map": "/static/js/main.d0c68b02.chunk.js.map",
"runtime-main.js": "/static/js/runtime-main.f0000622.js", "runtime-main.js": "/static/js/runtime-main.f0000622.js",
"runtime-main.js.map": "/static/js/runtime-main.f0000622.js.map", "runtime-main.js.map": "/static/js/runtime-main.f0000622.js.map",
"static/js/2.e506a40f.chunk.js": "/static/js/2.e506a40f.chunk.js", "static/js/2.e506a40f.chunk.js": "/static/js/2.e506a40f.chunk.js",
@ -81,6 +81,6 @@
"entrypoints": [ "entrypoints": [
"static/js/runtime-main.f0000622.js", "static/js/runtime-main.f0000622.js",
"static/js/2.e506a40f.chunk.js", "static/js/2.e506a40f.chunk.js",
"static/js/main.7f48381f.chunk.js" "static/js/main.d0c68b02.chunk.js"
] ]
} }

View file

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Lamassu Admin</title></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root" class="root"></div><script>!function(e){function r(r){for(var n,a,l=r[0],i=r[1],f=r[2],c=0,s=[];c<l.length;c++)a=l[c],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,f||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var i=t[l];0!==o[i]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="/";var l=this["webpackJsonplamassu-admin"]=this["webpackJsonplamassu-admin"]||[],i=l.push.bind(l);l.push=r,l=l.slice();for(var f=0;f<l.length;f++)r(l[f]);var p=i;t()}([])</script><script src="/static/js/2.e506a40f.chunk.js"></script><script src="/static/js/main.7f48381f.chunk.js"></script></body></html> <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Lamassu Admin</title></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root" class="root"></div><script>!function(e){function r(r){for(var n,a,l=r[0],i=r[1],f=r[2],c=0,s=[];c<l.length;c++)a=l[c],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,f||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var i=t[l];0!==o[i]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="/";var l=this["webpackJsonplamassu-admin"]=this["webpackJsonplamassu-admin"]||[],i=l.push.bind(l);l.push=r,l=l.slice();for(var f=0;f<l.length;f++)r(l[f]);var p=i;t()}([])</script><script src="/static/js/2.e506a40f.chunk.js"></script><script src="/static/js/main.d0c68b02.chunk.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long