diff --git a/routes/home.js b/routes/home.js index 95e79dd..dfe70ab 100644 --- a/routes/home.js +++ b/routes/home.js @@ -3,6 +3,7 @@ const cp = require('child_process'); const router= express.Router(); const detect = require('detect-port'); const oneport = require('oneport'); +const fs = require('fs'); let User = require("../DBcollection/user.js"); @@ -23,11 +24,20 @@ router.get('/', function(req, res) { console.log('port:', port); codeserver = cp.execFile('sudo', [ - 'code-server', - '--user-data-dir=/root/codedata/' + req.session.user.name, - '--auth=none', + 'PASSWORD=' + req.session.user.password, + + 'code-server', + + '--auth=password', + '--bind-addr=0.0.0.0:' + port, - '--extensions-dir=/root/extensionsdata/' + req.session.user.name, + + '--user-data-dir=/root/codeserver/userdata/' + req.session.user.name + '/', + '--extensions-dir=/root/codeserver/extensions/' + req.session.user.name + '/', + '--config=/root/codeserver/config/' + req.session.user.name, + + '-e', + '--home=http://106.75.254.18/logoff' ], function(error, stdout, stderr) { console.log(error + '\n' + stdout + '\n' + stderr); @@ -36,7 +46,9 @@ router.get('/', function(req, res) { user: req.session.user, server: codeserver }); - res.redirect('http://106.75.254.18:' + port); + dirpath = '/root/codeserver/user/' + req.session.user.name + '/'; + fs.mkdirSync(dirpath, { recursive: true }); + res.redirect('http://106.75.254.18:' + port + '/?folder=' + dirpath); }); } else {