Juan Cruz Viotti 5c33abca21 fix: add a delay before the final unmount on success (#1416)
If the user has the "Unmount on success" setting enabled, then Etcher
will unmount the drive after ther flashing process completed, right
after closing the drive file descriptor.

Turns out macOS will attempt to re-mount a drive once its file
descriptor gets closed, which means that if we try to unmount too fast,
then the drive will get re-mounted again.

As a naive solution, we add a timeout before finally unmounting the
drive. Keep in the mind this is only a temporary solution until we fix
mountutils to do the right thing.

See: https://github.com/resin-io/etcher/pull/1414
Fixes: https://github.com/resin-io/etcher/issues/1385
Change-Type: patch
Changelog-Entry: Prevent drive from getting re-mounted in macOS even when the unmount on success setting is enabled.
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
2017-05-12 00:40:08 -04:00
..

Etcher CLI

The Etcher CLI is a command line interface to the Etcher writer backend, and currently the only module in the "Etcher" umbrella that makes use of this backend directly.

This module also has the task of unmounting the drives before and after flashing.

Notice the Etcher CLI is not worried about elevation, and assumes it has enough permissions to continue, throwing an error otherwise. Consult the lib/child-writer module to understand how elevation works on Etcher.

The robot option

Setting the ETCHER_CLI_ROBOT environment variable allows other applications to easily consume the output of the Etcher CLI in real-time. When using the ETCHER_CLI_ROBOT option, the --yes option is implicit, therefore you need to manually specify --drive.

When ETCHER_CLI_ROBOT is used, the program will output JSON lines containing the progress state and other useful information. For example:

$ sudo ETCHER_CLI_ROBOT=1 etcher image.iso --drive /dev/disk2
{"command":"progress","data":{"type":"write","percentage":1,"eta":130,"speed":1703936}}
...
{"command":"progress","data":{"type":"check","percentage":100,"eta":0,"speed":17180514}}
{"command":"done","data":{"sourceChecksum":"27c39a5d"}}

See documentation about the robot mode at lib/shared/robot.

Exit codes

The Etcher CLI uses certain exit codes to signal the result of the operation. These are documented in lib/shared/exit-codes.js and are also printed on the Etcher CLI help page.