add installflags to agentdownload in meshctrl.js #6133
Signed-off-by: si458 <simonsmith5521@gmail.com>
si458 committed
May 28, 2024 at 18:24 UTC
17cf36edd9eb51d9d08fcb4e3690cde474b795cd
1 file changed
+15
-4
meshctrl.js
+15
-4
@@ -238,10 +238,9 @@ if (args['_'].length == 0) {
238
}
239
case 'agentdownload': {
240
if (args.type == null) { console.log(winRemoveSingleQuotes("Missing device type, use --type [agenttype]")); }
241
- var at = parseInt(args.type);
242
- if ((at == null) || isNaN(at) || (at < 1) || (at > 11000)) { console.log(winRemoveSingleQuotes("Invalid agent type, must be a number.")); }
243
- if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[meshid]'")); }
244
- if ((typeof args.id != 'string') || (args.id.length != 64)) { console.log(winRemoveSingleQuotes("Invalid meshid.")); }
241
+ else if ((parseInt(args.type) == null) || isNaN(parseInt(args.type)) || (parseInt(args.type) < 1) || (parseInt(args.type) > 11000)) { console.log(winRemoveSingleQuotes("Invalid agent type, must be a number.")); }
242
+ else if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[meshid]'")); }
243
+ else if ((typeof args.id != 'string') || (args.id.length != 64)) { console.log(winRemoveSingleQuotes("Invalid meshid.")); }
244
else { ok = true; }
245
break;
246
}
@@ -905,6 +904,7 @@ if (args['_'].length == 0) {
904
case 'agentdownload': {
905
console.log("Download an agent of a specific type for a given device group, Example usages:\r\n");
906
console.log(winRemoveSingleQuotes(" MeshCtrl AgentDownload --id 'groupid' --type 3"));
907
+ console.log(winRemoveSingleQuotes(" MeshCtrl AgentDownload --id 'groupid' --type 3 --installflags 1"));
908
console.log("\r\nRequired arguments:\r\n");
909
console.log(" --type [ArchitectureNumber] - Agent architecture number.");
910
if (process.platform == 'win32') {
@@ -912,6 +912,11 @@ if (args['_'].length == 0) {
912
} else {
913
console.log(" --id '[groupid]' - The device group identifier.");
914
}
915
+ console.log("\r\nOptional arguments:\r\n");
916
+ console.log(" --installflags [InstallFlagsNumber] - With the following choices:");
917
+ console.log(" installflags 0 - Default, Interactive & Background, offers connect button & install/uninstall");
918
+ console.log(" installflags 1 - Interactive only, offers only connect button, not install/uninstall");
919
+ console.log(" installflags 2 - Background only, offers only install/uninstall, not connect");
920
break;
921
}
922
case 'upload': {
@@ -1668,6 +1673,12 @@ function serverConnect() {
1673
var u = settings.xxurl.replace('wss://', 'https://').replace('/control.ashx', '/meshagents');
1674
if (u.indexOf('?') > 0) { u += '&'; } else { u += '?'; }
1675
u += 'id=' + args.type + '&meshid=' + args.id;
1676
+ // check, whether the optional installflags have not been set; include them only when set
1677
+ if (args.installflags) {
1678
+ if ((typeof parseInt(args.installflags) != 'number') || isNaN(parseInt(args.installflags)) || (parseInt(args.installflags) < 0) || (parseInt(args.installflags) > 2)) { console.log("Invalid Installflags."); process.exit(1); return; }
1679
+ u += '&installflags=' + args.installflags;
1680
+ }
1681
+ console.log(u);
1682
const options = { rejectUnauthorized: false, checkServerIdentity: onVerifyServer }
1683
const fs = require('fs');
1684
const https = require('https');