Merge pull request #2118 from resin-io/fix-linux-usbboot

fix(scanner): Enable usbboot on Linux if run as root
This commit is contained in:
Jonas Hermsmeier 2018-03-21 22:56:15 +01:00 committed by GitHub
commit 22f6cc1c6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -11,7 +11,7 @@
ng-click="modal.toggleDrive(drive)"> ng-click="modal.toggleDrive(drive)">
<img class="list-group-item-section" alt="Drive device type logo" <img class="list-group-item-section" alt="Drive device type logo"
ng-if="drive.icon" ng-if="drive.icon"
ng-src="./assets/{{drive.icon}}.svg" ng-src="../assets/{{drive.icon}}.svg"
width="25" width="25"
height="30"> height="30">
<div <div

View File

@ -22,13 +22,14 @@ const fs = Bluebird.promisifyAll(require('fs'))
const path = require('path') const path = require('path')
const settings = require('../models/settings') const settings = require('../models/settings')
const SDK = require('../../../sdk') const SDK = require('../../../sdk')
const permissions = require('../../../shared/permissions')
/** /**
* @summary The Etcher "blobs" directory path * @summary The Etcher "blobs" directory path
* @type {String} * @type {String}
* @constant * @constant
*/ */
const BLOBS_DIRECTORY = path.join(__dirname, '..', '..', 'blobs') const BLOBS_DIRECTORY = path.join(__dirname, '..', '..', '..', 'blobs')
const scanner = SDK.createScanner({ const scanner = SDK.createScanner({
blockdevice: { blockdevice: {
@ -51,4 +52,17 @@ const scanner = SDK.createScanner({
} }
}) })
// NOTE: Enable USBBoot on Linux if run as root
permissions.isElevated().then((elevated) => {
if (elevated && process.platform === 'linux') {
const UsbbootAdapter = require('../../../sdk/adapters/usbboot')
const adapter = new UsbbootAdapter()
scanner.stop()
scanner.subscribe(adapter)
scanner.start()
}
}).catch((error) => {
console.warn('Could not add usbboot adapter:', error)
})
module.exports = scanner module.exports = scanner