Add --iderstart as an option to amtider

Allows you to change when the IDER session begins, either `onreboot`, `graceful` or `now`

Chris Thornton committed Apr 4, 2022 at 15:23 UTC d8cb4d10e4a4502ec79478141666c30a5db39549
1 file changed +16 -9
agents/meshcmd.js
+16 -9
@@ -153,6 +153,7 @@ function run(argv) {
153 if ((typeof args.scan) == 'string') { settings.scan = args.scan; }
154 if ((typeof args.token) == 'string') { settings.token = args.token; }
155 if ((typeof args.timeout) == 'string') { settings.timeout = parseInt(args.timeout); }
156 + if ((typeof args.iderstart) == 'string') { settings.iderstart = args.iderstart; }
157 if ((typeof args.uuidoutput) == 'string' || args.uuidoutput) { settings.uuidoutput = args.uuidoutput; }
158 if ((typeof args.desc) == 'string') { settings.desc = args.desc; }
159 if ((typeof args.dnssuffix) == 'string') { settings.dnssuffix = args.dnssuffix; }
@@ -357,13 +358,14 @@ function run(argv) {
358 } else if (action == 'amtider') {
359 console.log('AmtIDER will mount a local disk images to a remote Intel AMT computer. Example usage:\r\n\r\n meshcmd amtider --host 1.2.3.4 --user admin --pass mypassword --tls --floppy disk.img --cdrom disk.iso');
360 console.log('\r\nPossible arguments:\r\n');
360 - console.log(' --host [hostname] The IP address or DNS name of Intel AMT.');
361 - console.log(' --user [username] The Intel AMT login username, admin is default.');
362 - console.log(' --pass [password] The Intel AMT login password.');
363 - console.log(' --tls Specifies that TLS must be used.');
364 - console.log(' --floppy [file] Specifies .img file to be mounted as a flppy disk.');
365 - console.log(' --cdrom [file] Specifies .img file to be mounted as a CDROM disk.');
366 - console.log(' --timeout [seconds] Optional, disconnect after number of seconds without disk read.');
361 + console.log(' --host [hostname] The IP address or DNS name of Intel AMT.');
362 + console.log(' --user [username] The Intel AMT login username, admin is default.');
363 + console.log(' --pass [password] The Intel AMT login password.');
364 + console.log(' --tls Specifies that TLS must be used.');
365 + console.log(' --floppy [file] Specifies .img file to be mounted as a flppy disk.');
366 + console.log(' --cdrom [file] Specifies .img file to be mounted as a CDROM disk.');
367 + console.log(' --timeout [seconds] Optional, disconnect after number of seconds without disk read.');
368 + console.log(' --iderstart [onreboot|graceful|now] Optional, when to start the IDER session.');
369 } else if (action == 'amtscan') {
370 console.log('AmtSCAN will look for Intel AMT device on the network. Example usage:\r\n\r\n meshcmd amtscan --scan 192.168.1.0/24');
371 console.log('\r\Required arguments:\r\n');
@@ -862,7 +864,6 @@ function run(argv) {
864 if (args.bootindex && args.bootindex >=0) {
865 settings.bootindex = args.bootindex;
866 }
865 -
867 performAmtPowerAction();
868 } else {
869 console.log('Invalid "action" specified.'); exit(1); return;
@@ -2291,6 +2292,8 @@ iderIdleTimer = null;
2292 function performIder() {
2293 if ((settings.floppy != null) && fs.existsSync(settings.floppy) == false) { console.log("Unable to floppy image file: " + settings.floppy); exit(); return; }
2294 if ((settings.cdrom != null) && fs.existsSync(settings.cdrom) == false) { console.log("Unable to CDROM image file: " + settings.cdrom); exit(); return; }
2295 + var iderStarts = ['onreboot', 'graceful', 'now'];
2296 + if ((settings.iderstart != null) && iderStarts.indexOf(settings.iderstart) < 0) { console.log("Unknown iderstart option: " + settings.iderstart); exit(); return; }
2297 try {
2298 var sfloppy = null, scdrom = null;
2299 if (settings.floppy) { try { if (sfloppy = fs.statSync(settings.floppy)) { sfloppy.file = fs.openSync(settings.floppy, 'rbN'); } } catch (ex) { console.log(ex); exit(1); return; } }
@@ -2300,7 +2303,11 @@ function performIder() {
2303 ider.onStateChanged = onIderStateChange;
2304 ider.m.floppy = sfloppy;
2305 ider.m.cdrom = scdrom;
2303 - ider.m.iderStart = 1; // OnReboot = 0, Graceful = 1, Now = 2
2306 + if (settings.iderstart) {
2307 + ider.m.iderStart = iderStarts.indexOf(settings.iderstart);
2308 + } else {
2309 + ider.m.iderStart = 1; // OnReboot = 0, Graceful = 1, Now = 2
2310 + }
2311 ider.m.debug = (settings.debuglevel > 0);
2312 if (settings.timeout > 0) {
2313 ider.m.sectorStats = iderSectorStats;