-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
2,225 additions
and
628 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env node | ||
|
||
// System Objects | ||
var child_process = require('child_process'); | ||
var fs = require('fs'); | ||
|
||
// Third Party Dependencies | ||
// ... | ||
|
||
// Internal | ||
var logs = require('../lib/logs'); | ||
|
||
module.exports.install = function() { | ||
if (process.platform === 'linux') { | ||
var rules_name = '85-tessel.rules'; | ||
var dest = '/etc/udev/rules.d/' + rules_name; | ||
var rules = fs.readFileSync(__dirname + '/../resources/' + rules_name); | ||
|
||
try { | ||
fs.writeFileSync(dest, rules); | ||
} catch (e) { | ||
if (e.code === 'EACCES') { | ||
logs.info('Could not write to ' + dest); | ||
logs.info('Run `sudo t2 install-drivers`'); | ||
return -1; | ||
} else { | ||
throw e; | ||
} | ||
} | ||
logs.info('udev rules installed to ' + dest); | ||
|
||
|
||
var udevadm = child_process.spawn('udevadm', ['control', '--reload-rules']); | ||
udevadm.on('close', function(code) { | ||
if (code !== 0) { | ||
logs.error('Error reloading udev'); | ||
return code; | ||
} else { | ||
logs.info('Done. Unplug and re-plug Tessel to update permissions.'); | ||
return code; | ||
} | ||
}); | ||
} else { | ||
logs.info('No driver installation necessary.'); | ||
} | ||
|
||
}; |
Oops, something went wrong.