default backup path fix

default backup path fix
pull/209/head v0.4.4
ShahanaFarooqui 5 years ago
parent d1d0a2ba75
commit 81699ede37

@ -12,6 +12,7 @@ var logger = require('./controllers/logger');
var connect = {}; var connect = {};
var errMsg = ''; var errMsg = '';
var request = require('request'); var request = require('request');
common.path_separator = (platform === 'win32') ? '\\' : '/';
connect.setDefaultConfig = () => { connect.setDefaultConfig = () => {
var homeDir = os.userInfo().homedir; var homeDir = os.userInfo().homedir;
@ -49,7 +50,7 @@ connect.setDefaultConfig = () => {
menuType: 'Regular', menuType: 'Regular',
theme: 'dark-blue', theme: 'dark-blue',
satsToBTC: false, satsToBTC: false,
channelBackupPath: homeDir + '/backup/node-0', channelBackupPath: homeDir + common.path_separator + 'backup' + common.path_separator + 'node-0',
lndServerUrl: 'https://localhost:8080/v1', lndServerUrl: 'https://localhost:8080/v1',
enableLogging: false, enableLogging: false,
port: 3000 port: 3000
@ -179,14 +180,14 @@ connect.validateSingleNodeConfig = (config) => {
if(config.Settings.channelBackupPath !== '' && undefined !== config.Settings.channelBackupPath) { if(config.Settings.channelBackupPath !== '' && undefined !== config.Settings.channelBackupPath) {
common.nodes[0].channel_backup_path = config.Settings.channelBackupPath; common.nodes[0].channel_backup_path = config.Settings.channelBackupPath;
} else { } else {
common.nodes[0].channel_backup_path = common.rtl_conf_file_path + '/backup'; common.nodes[0].channel_backup_path = common.rtl_conf_file_path + common.path_separator + 'backup';
} }
try { try {
connect.createDirectory(common.nodes[0].channel_backup_path); connect.createDirectory(common.nodes[0].channel_backup_path);
let exists = fs.existsSync(common.nodes[0].channel_backup_path + '/channel-all.bak'); let exists = fs.existsSync(common.nodes[0].channel_backup_path + common.path_separator + 'channel-all.bak');
if (!exists) { if (!exists) {
try { try {
var createStream = fs.createWriteStream(common.nodes[0].channel_backup_path + '/channel-all.bak'); var createStream = fs.createWriteStream(common.nodes[0].channel_backup_path + common.path_separator + 'channel-all.bak');
createStream.end(); createStream.end();
} catch (err) { } catch (err) {
console.error('Something went wrong while creating backup file: \n' + err); console.error('Something went wrong while creating backup file: \n' + err);
@ -279,13 +280,13 @@ connect.validateMultiNodeConfig = (config) => {
common.nodes[idx].lnd_config_path = (undefined !== node.Authentication.lndConfigPath) ? node.Authentication.lndConfigPath : ''; common.nodes[idx].lnd_config_path = (undefined !== node.Authentication.lndConfigPath) ? node.Authentication.lndConfigPath : '';
common.nodes[idx].bitcoind_config_path = (undefined !== node.Settings.bitcoindConfigPath) ? node.Settings.bitcoindConfigPath : ''; common.nodes[idx].bitcoind_config_path = (undefined !== node.Settings.bitcoindConfigPath) ? node.Settings.bitcoindConfigPath : '';
common.nodes[idx].enable_logging = (undefined !== node.Settings.enableLogging) ? node.Settings.enableLogging : false; common.nodes[idx].enable_logging = (undefined !== node.Settings.enableLogging) ? node.Settings.enableLogging : false;
common.nodes[idx].channel_backup_path = (undefined !== node.Settings.channelBackupPath) ? node.Settings.channelBackupPath : common.rtl_conf_file_path + '/backup/node-' + node.index; common.nodes[idx].channel_backup_path = (undefined !== node.Settings.channelBackupPath) ? node.Settings.channelBackupPath : common.rtl_conf_file_path + common.path_separator + 'backup' + common.path_separator + 'node-' + node.index;
try { try {
connect.createDirectory(common.nodes[idx].channel_backup_path); connect.createDirectory(common.nodes[idx].channel_backup_path);
let exists = fs.existsSync(common.nodes[idx].channel_backup_path + '/channel-all.bak'); let exists = fs.existsSync(common.nodes[idx].channel_backup_path + common.path_separator + 'channel-all.bak');
if (!exists) { if (!exists) {
try { try {
var createStream = fs.createWriteStream(common.nodes[idx].channel_backup_path + '/channel-all.bak'); var createStream = fs.createWriteStream(common.nodes[idx].channel_backup_path + common.path_separator + 'channel-all.bak');
createStream.end(); createStream.end();
} catch (err) { } catch (err) {
console.error('Something went wrong while creating backup file: \n' + err); console.error('Something went wrong while creating backup file: \n' + err);
@ -431,7 +432,7 @@ connect.logEnvVariables = () => {
} }
connect.getAllNodeAllChannelBackup = (node) => { connect.getAllNodeAllChannelBackup = (node) => {
let channel_backup_file = node.channel_backup_path + '/channel-all.bak'; let channel_backup_file = node.channel_backup_path + common.path_separator + 'channel-all.bak';
let options = { let options = {
url: node.lnd_server_url + '/channels/backup', url: node.lnd_server_url + '/channels/backup',
rejectUnauthorized: false, rejectUnauthorized: false,

@ -29,6 +29,7 @@ exports.getRTLConfig = (req, res, next) => {
lndConfigPath: common.nodes[0].lnd_config_path, lndConfigPath: common.nodes[0].lnd_config_path,
bitcoindConfigPath: common.nodes[0].bitcoind_config_path bitcoindConfigPath: common.nodes[0].bitcoind_config_path
}; };
jsonConfig.Settings.channelBackupPath = (undefined !== jsonConfig.Settings.channelBackupPath) ? jsonConfig.Settings.channelBackupPath : common.nodes[0].channel_backup_path;
res.status(200).json({ selectedNodeIndex: common.selectedNode.index, sso: sso, nodes: [{ res.status(200).json({ selectedNodeIndex: common.selectedNode.index, sso: sso, nodes: [{
index: common.nodes[0].index, index: common.nodes[0].index,
lnNode: 'SingleNode', lnNode: 'SingleNode',
@ -56,7 +57,7 @@ exports.getRTLConfig = (req, res, next) => {
const multiNodeConfig = JSON.parse(data); const multiNodeConfig = JSON.parse(data);
const sso = { rtlSSO: common.rtl_sso, logoutRedirectLink: common.logout_redirect_link }; const sso = { rtlSSO: common.rtl_sso, logoutRedirectLink: common.logout_redirect_link };
var nodesArr = []; var nodesArr = [];
multiNodeConfig.nodes.forEach(node => { multiNodeConfig.nodes.forEach((node, i) => {
const authentication = {}; const authentication = {};
authentication.nodeAuthType = 'CUSTOM'; authentication.nodeAuthType = 'CUSTOM';
if(node.Authentication.lndConfigPath) { if(node.Authentication.lndConfigPath) {
@ -65,6 +66,7 @@ exports.getRTLConfig = (req, res, next) => {
if(node.Settings.bitcoindConfigPath) { if(node.Settings.bitcoindConfigPath) {
authentication.bitcoindConfigPath = node.Settings.bitcoindConfigPath; authentication.bitcoindConfigPath = node.Settings.bitcoindConfigPath;
} }
node.Settings.channelBackupPath = (undefined !== node.Settings.channelBackupPath) ? node.Settings.channelBackupPath : common.nodes[i].channel_backup_path;
nodesArr.push({ nodesArr.push({
index: node.index, index: node.index,
lnNode: node.lnNode, lnNode: node.lnNode,

@ -9,11 +9,11 @@ exports.getBackup = (req, res, next) => {
let channel_backup_file = ''; let channel_backup_file = '';
let message = ''; let message = '';
if (req.params.channelPoint === 'ALL') { if (req.params.channelPoint === 'ALL') {
channel_backup_file = common.selectedNode.channel_backup_path + '\\channel-all.bak'; channel_backup_file = common.selectedNode.channel_backup_path + common.path_separator + 'channel-all.bak';
message = 'All Channels Backup Successful at: ' + channel_backup_file + ' !'; message = 'All Channels Backup Successful at: ' + channel_backup_file + ' !';
options.url = common.getSelLNDServerUrl() + '/channels/backup'; options.url = common.getSelLNDServerUrl() + '/channels/backup';
} else { } else {
channel_backup_file = common.selectedNode.channel_backup_path + '\\channel-' + req.params.channelPoint.replace(':', '-') + '.bak'; channel_backup_file = common.selectedNode.channel_backup_path + common.path_separator + 'channel-' + req.params.channelPoint.replace(':', '-') + '.bak';
message = 'Channel Backup Successful at: ' + channel_backup_file + ' !'; message = 'Channel Backup Successful at: ' + channel_backup_file + ' !';
let channelpoint = req.params.channelPoint.replace(':', '/'); let channelpoint = req.params.channelPoint.replace(':', '/');
options.url = common.getSelLNDServerUrl() + '/channels/backup/' + channelpoint; options.url = common.getSelLNDServerUrl() + '/channels/backup/' + channelpoint;
@ -57,7 +57,7 @@ exports.postBackupVerify = (req, res, next) => {
let verify_backup = ''; let verify_backup = '';
if (req.params.channelPoint === 'ALL') { if (req.params.channelPoint === 'ALL') {
message = 'All Channels Verify Successful!'; message = 'All Channels Verify Successful!';
channel_verify_file = common.selectedNode.channel_backup_path + '/channel-all.bak'; channel_verify_file = common.selectedNode.channel_backup_path + common.path_separator + 'channel-all.bak';
let exists = fs.existsSync(channel_verify_file); let exists = fs.existsSync(channel_verify_file);
if (exists) { if (exists) {
verify_backup = fs.readFileSync(channel_verify_file, 'utf-8'); verify_backup = fs.readFileSync(channel_verify_file, 'utf-8');
@ -74,7 +74,7 @@ exports.postBackupVerify = (req, res, next) => {
} }
} else { } else {
message = 'Channel ' + req.params.channelPoint + ' Verify Successful!'; message = 'Channel ' + req.params.channelPoint + ' Verify Successful!';
channel_verify_file = common.selectedNode.channel_backup_path + '/channel-' + req.params.channelPoint.replace(':', '-') + '.bak'; channel_verify_file = common.selectedNode.channel_backup_path + common.path_separator + 'channel-' + req.params.channelPoint.replace(':', '-') + '.bak';
let exists = fs.existsSync(channel_verify_file); let exists = fs.existsSync(channel_verify_file);
if (exists) { if (exists) {
verify_backup = fs.readFileSync(channel_verify_file, 'utf-8'); verify_backup = fs.readFileSync(channel_verify_file, 'utf-8');

@ -5,7 +5,7 @@
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"start": "ng serve --base-href /rtl/ --open --aot", "start": "ng serve --base-href /rtl/ --open --aot",
"build": "ng build --prod --base-href /rtl/ --aot", "build": "ng analytics off && ng build --prod --base-href /rtl/ --aot",
"serve": "ng serve", "serve": "ng serve",
"prebuild": "node ./prebuild", "prebuild": "node ./prebuild",
"test": "ng test", "test": "ng test",

Loading…
Cancel
Save