-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.js
More file actions
44 lines (40 loc) · 985 Bytes
/
config.js
File metadata and controls
44 lines (40 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const { Client } = require('ssh2');
const fs = require('fs');
const os = require('os');
const path = require('path');
const sshConfig = {
host: 'ssh.cavingcrew.com',
username: 'bitnami',
agent: process.env.SSH_AUTH_SOCK,
compression: true,
serverAliveInterval: 60,
forwardX11: true
};
async function getDbPassword() {
return new Promise((resolve, reject) => {
const conn = new Client();
conn.on('ready', () => {
conn.exec('cat ~/bitnami_application_password', (err, stream) => {
if (err) reject(err);
let password = '';
stream.on('data', (data) => {
password += data.toString();
}).on('close', () => {
conn.end();
resolve(password.trim());
});
});
}).on('error', (err) => {
reject(err);
}).connect(sshConfig);
});
}
module.exports = {
ssh: sshConfig,
db: {
host: 'localhost',
user: 'root',
database: 'jtl_cavingcrew_com'
},
getDbPassword
};