mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-28 05:36:34 +00:00
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:
commit
22f6cc1c6f
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user