This commit is contained in:
Mark Nadal 2023-04-25 03:16:21 -07:00
parent 58f9135f6b
commit c9283d8fa6

View File

@ -215,7 +215,7 @@ function start(root){
try{ (cmd[msg.try]||cmd.any)(msg, peer); }catch(err){ mesh.say({dam: '!', err: "service error: "+err}) }
}
cmd.https = function(msg, peer){ var run, log;
if(!(run = require('child_process').execSync)){ return }
if(!(run = require('child_process').exec)){ return }
if(!msg.email || !msg.domain){
mesh.say({dam: '!', err: 'Domain/email missing, use `location.hostname`!'});
return;
@ -227,11 +227,11 @@ function start(root){
var path = require('path').resolve(__dirname, '../examples');
//log = run("bash "+path+"/https.sh", {env: {'EMAIL': msg.email, 'WEB': path, 'DOMAIN': msg.domain}});//, (err, stdout, stderr) => {
require('fs').writeFileSync(path+'/../email', msg.email);
log = run("bash "+path+"/https.sh", {env:{'EMAIL': msg.email, 'WEB': path, 'DOMAIN': msg.domain}});//, (err, stdout, stderr) => {
//log = JSON.stringify({err, stdout, stderr});
mesh.say({dam: '!', log: ''+log}, peer);
setTimeout(function(){ process.exit() },999);
//});
run("bash "+path+"/https.sh", {env:{'EMAIL': msg.email, 'WEB': path, 'DOMAIN': msg.domain}}, function(e, out, err){
log = JSON.stringify({e: e, out: out, err: err});
mesh.say({dam: '!', log: ''+log}, peer);
setTimeout(function(){ process.exit() },999);
});
return;
// log = run('curl https://get.acme.sh | /bin/sh -s email='+msg.email);
// mesh.say({dam: '!', log: ''+log}, peer);
@ -252,11 +252,13 @@ function start(root){
cmd.update = function(msg, peer){ var run, log, pass;
try{ pass = ''+require('fs').readFileSync(require('os').homedir()+'/pass') }catch(e){}
if(!pass || msg.pass != pass){ return }
if(!(run = require('child_process').execSync)){ return }
if(!(run = require('child_process').exec)){ return }
var path = require('path').resolve(__dirname, '../examples');
log = run("bash "+path+"/install.sh", {env: {VERSION: msg.version||''}});
mesh.say({dam: '!', log: ''+log}, peer);
setTimeout(function(){ process.exit() },999);
run("bash "+path+"/install.sh", {env: {VERSION: msg.version||''}}, function(e, out, err){
log = JSON.stringify({e: e, out: out, err: err});
mesh.say({dam: '!', log: ''+log}, peer);
setTimeout(function(){ process.exit() },999);
});
}
cmd.any = function(){};