Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 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",
"version": "0.0.21",
"author": "Ryan Blenis",
"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/fud18/MeshCentral-ScriptTask",
"changelogUrl": "https://raw.githubusercontent.com/fud18/MeshCentral-ScriptTask/master/changelog.md",
"configUrl": "https://raw.githubusercontent.com/fud18/MeshCentral-ScriptTask/master/config.json",
"downloadUrl": "https://github.com/fud18/MeshCentral-ScriptTask/archive/refs/heads/master.zip",
"repository": {
"type": "git",
"url": "https://github.com/ryanblenis/MeshCentral-ScriptTask.git"
"url": "https://github.com/fud18/MeshCentral-ScriptTask.git"
},
"versionHistoryUrl": "https://api.github.com/repos/ryanblenis/MeshCentral-ScriptTask/tags",
"versionHistoryUrl": "https://api.github.com/repos/fud18/MeshCentral-ScriptTask/tags",
"meshCentralCompat": ">=1.1.35"
}
}
6 changes: 6 additions & 0 deletions scripttask.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ module.exports.scripttask = function (parent) {
obj.db.get(job.scriptId)
.then(async (script) => {
script = script[0];

if (!script || typeof script.content !== 'string') {
console.log('PLUGIN: ScriptTask: Skipping job with missing script content. scriptId=' + job.scriptId + ', node=' + job.node);
return;
}

var foundVars = script.content.match(/#(.*?)#/g);
var replaceVars = {};
if (foundVars != null && foundVars.length > 0) {
Expand Down
17 changes: 13 additions & 4 deletions views/scriptedit.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<div id="scriptTaskScriptEdit">
<div id="scriptNameC">Script Name: <input type="text" value="" id="scriptName"/></div>
<div id="controlBar">
<button onclick="goSave();">Save</button>
<button onclick="goClose();">Close</button>
<button onclick="goSave(); return false;">Save</button>
<button onclick="goClose(); return false;">Cancel</button>
</div>
<div id="scriptContentC">
<textarea id="scriptContent"></textarea>
Expand All @@ -57,8 +57,17 @@ function doOnLoad() {
function goSave() {
scriptData.content = Q('scriptContent').value;
scriptData.name = Q('scriptName').value;
window.opener.callback(scriptData);
//goClose();

try {
if (window.opener && typeof window.opener.callback === 'function') {
window.opener.callback(scriptData);
} else {
alert('Unable to save script: parent callback was not found.');
return;
}
} finally {
window.close();
}
}

function goClose() {
Expand Down
Loading