Skip to content
18 changes: 9 additions & 9 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "ScriptTask",
"shortName": "scripttask",
"version": "0.0.20",
"author": "Ryan Blenis",
"version": "0.0.21",
"author": "Ryan Blenis / Pablo Navarro",
"description": "Script (PowerShell, BAT, Bash) runner for endpoints",
"hasAdminPanel": false,
"homepage": "https://github.com/ryanblenis/MeshCentral-ScriptTask",
"changelogUrl": "https://raw.githubusercontent.com/ryanblenis/MeshCentral-ScriptTask/master/changelog.md",
"configUrl": "https://raw.githubusercontent.com/ryanblenis/MeshCentral-ScriptTask/master/config.json",
"downloadUrl": "https://github.com/ryanblenis/MeshCentral-ScriptTask/archive/master.zip",
"homepage": "https://github.com/panreyes/MeshCentral-ScriptTask",
"changelogUrl": "https://raw.githubusercontent.com/panreyes/MeshCentral-ScriptTask/master/changelog.md",
"configUrl": "https://raw.githubusercontent.com/panreyes/MeshCentral-ScriptTask/master/config.json",
"downloadUrl": "https://github.com/panreyes/MeshCentral-ScriptTask/archive/master.zip",
"repository": {
"type": "git",
"url": "https://github.com/ryanblenis/MeshCentral-ScriptTask.git"
"url": "https://github.com/panreyes/MeshCentral-ScriptTask.git"
},
"versionHistoryUrl": "https://api.github.com/repos/ryanblenis/MeshCentral-ScriptTask/tags",
"versionHistoryUrl": "https://api.github.com/repos/panreyes/MeshCentral-ScriptTask/tags",
"meshCentralCompat": ">=1.1.35"
}
}
20 changes: 20 additions & 0 deletions db.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,26 @@ module.exports.CreateDB = function(meshserver) {
}
obj.initFunctions();
});
} else if (meshserver.args.mariadb) { // use MariaDB
var mariadb = null;
try { mariadb = require('mariadb'); } catch (e) { console.log('PLUGIN: ScriptTask: mariadb module is required but not found.'); }
if (mariadb != null) {
var NEMariaDB = require(__dirname + '/nemariadb.js');
var m_options = meshserver.args.mariadb;
if (typeof m_options === 'string') {
try {
const urlToConfig = require('mariadb/lib/misc/url-to-config.js');
m_options = urlToConfig(m_options);
} catch (e) {
// Fallback to letting createPool parse it directly if supported
}
}
if (meshserver.args.mariadbname && typeof m_options === 'object') m_options.database = meshserver.args.mariadbname;
var pool = mariadb.createPool(m_options);
obj.scriptFile = new NEMariaDB(pool);
formatId = function(id) { return id; };
obj.initFunctions();
}
} else { // use NeDb
try { Datastore = require('@seald-io/nedb'); } catch (ex) { } // This is the NeDB with Node 23 support.
if (Datastore == null) {
Expand Down
16 changes: 8 additions & 8 deletions modules_meshcore/scripttask.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ function runPowerShell(sObj, jObj) {
const fs = require('fs');
var rand = Math.random().toString(32).replace('0.', '');

var oName = 'st' + rand + '.txt';
var pName = 'st' + rand + '.ps1';
var oName = 'tmp_st_' + rand + '.txt';
var pName = 'tmp_st_' + rand + '.ps1';
var pwshout = '', pwsherr = '', cancontinue = false;
try {
fs.writeFileSync(pName, sObj.content);
Expand Down Expand Up @@ -221,8 +221,8 @@ function runPowerShellNonWin(sObj, jObj) {
dbg('Path chosen is: ' + path);
path = path + '/';

var oName = 'st' + rand + '.txt';
var pName = 'st' + rand + '.ps1';
var oName = 'tmp_st_' + rand + '.txt';
var pName = 'tmp_st_' + rand + '.ps1';
var pwshout = '', pwsherr = '', cancontinue = false;
try {
var childp = require('child_process').execFile('/bin/sh', ['sh']);
Expand Down Expand Up @@ -298,8 +298,8 @@ function runBat(sObj, jObj) {
}
const fs = require('fs');
var rand = Math.random().toString(32).replace('0.', '');
var oName = 'st' + rand + '.txt';
var pName = 'st' + rand + '.bat';
var oName = 'tmp_st_' + rand + '.txt';
var pName = 'tmp_st_' + rand + '.bat';
try {
fs.writeFileSync(pName, sObj.content);
var outstr = '', errstr = '';
Expand Down Expand Up @@ -372,8 +372,8 @@ function runBash(sObj, jObj) {
//child.execFile(process.env['windir'] + '\\system32\\cmd.exe', ['/c', 'RunDll32.exe user32.dll,LockWorkStation'], { type: 1 });

var rand = Math.random().toString(32).replace('0.', '');
var oName = 'st' + rand + '.txt';
var pName = 'st' + rand + '.sh';
var oName = 'tmp_st_' + rand + '.txt';
var pName = 'tmp_st_' + rand + '.sh';
try {
fs.writeFileSync(path + pName, sObj.content);
var outstr = '', errstr = '';
Expand Down
Loading