Make initial sftp connection work

This commit is contained in:
Johannes Zellner
2019-03-18 21:15:50 -07:00
parent 4942a2480b
commit 044b27967e
8 changed files with 141 additions and 43 deletions
+20 -2
View File
@@ -12,13 +12,12 @@ var addons = require('./addons.js'),
apps = require('./apps.js'),
assert = require('assert'),
async = require('async'),
config = require('./config.js'),
debug = require('debug')('box:platform'),
ejs = require('ejs'),
fs = require('fs'),
graphs = require('./graphs.js'),
infra = require('./infra_version.js'),
locker = require('./locker.js'),
mail = require('./mail.js'),
paths = require('./paths.js'),
reverseProxy = require('./reverseproxy.js'),
safe = require('safetydance'),
@@ -29,6 +28,8 @@ var addons = require('./addons.js'),
var NOOP_CALLBACK = function (error) { if (error) debug(error); };
var PROFTPD_CONFIG_EJS = fs.readFileSync(__dirname + '/proftpd.ejs', { encoding: 'utf8' });
function start(callback) {
assert.strictEqual(typeof callback, 'function');
@@ -62,6 +63,7 @@ function start(callback) {
startApps.bind(null, existingInfra),
graphs.startGraphite.bind(null, existingInfra),
addons.startServices.bind(null, existingInfra),
configureProftpd.bind(null, existingInfra),
fs.writeFile.bind(fs, paths.INFRA_VERSION_FILE, JSON.stringify(infra, null, 4))
], function (error) {
if (error) return callback(error);
@@ -165,3 +167,19 @@ function startApps(existingInfra, callback) {
callback();
}
}
function configureProftpd(existingInfra, callback) {
var data = {
sftpPort: 222,
ldapUrl: 'ldap://172.18.0.1:3002',
ldapUsersBaseDn: 'ou=proftpd,dc=cloudron',
ldapBindUsername: 'cn=admin@cloudron,ou=proftpd,dc=cloudron',
ldapBindPassword: 'password'
};
console.log('------ configure proftpd', data, paths.PROFTPD_CONFIG_FILE);
if (!safe.fs.writeFileSync(paths.PROFTPD_CONFIG_FILE, ejs.render(PROFTPD_CONFIG_EJS, data))) return callback(safe.error);
callback(null);
}