-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into bumps-version-1.9.17
- Loading branch information
Showing
28 changed files
with
3,632 additions
and
112 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
exports.play = 'mpg123'; | ||
exports.raise_volume = 'pactl set-sink-mute 0 0 && pactl set-sink-volume 0 65536'; | ||
exports.raise_volume = 'pactl set-sink-mute @DEFAULT_SINK@ 0&&pactl set-sink-volume @DEFAULT_SINK@ 100%'; |
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,9 @@ | ||
$namespaceName = "root\cimv2\mdm\dmmap" | ||
$className = "MDM_RemoteWipe" | ||
$methodName = "doWipeMethod" | ||
$session = New-CimSession | ||
$params = New-Object Microsoft.Management.Infrastructure.CimMethodParametersCollection | ||
$param = [Microsoft.Management.Infrastructure.CimMethodParameter]::Create("param", "", "String", "In") | ||
$params.Add($param) | ||
$instance = Get-CimInstance -Namespace $namespaceName -ClassName $className -Filter "ParentID='./Vendor/MSFT' and InstanceID='RemoteWipe'" | ||
$session.InvokeMethod($namespaceName, $instance, $methodName, $params) |
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,108 @@ | ||
var os = require('os'), | ||
path = require('path'), | ||
join = path.join, | ||
Emitter = require('events').EventEmitter, | ||
common = require('../../common'), | ||
logger = common.logger.prefix('factoryreset'), | ||
token = require('./../../token'), | ||
system = require('./../../../system'), | ||
errors = require('./../../errors').status; | ||
|
||
var emitter, | ||
action, | ||
node_bin = join(system.paths.current, 'bin', 'node'), | ||
file_factory_reset = join(system.paths.current, 'lib', 'agent','actions','factoryreset','bin','factory-reset.ps1'); | ||
|
||
|
||
var time_execution = () => { | ||
var now = new Date(); | ||
now.setMinutes(now.getMinutes() + 2); //add two minuts | ||
now = new Date(now); | ||
datetext = now.toTimeString(); | ||
var time = datetext.split(' ')[0]; | ||
return time; | ||
|
||
} | ||
|
||
exports.start = function(id, opts, cb) { | ||
var os_name = os.platform().replace('darwin', 'mac').replace('win32', 'windows'); | ||
|
||
if (os_name != 'windows'){ | ||
let error = new Error('Action only allowed on Windows 1O'); | ||
error.code = 3; | ||
error.name = errors.find( x => x.status_code == error.code).message; | ||
return cb(error); | ||
} | ||
|
||
var opts = opts || {}; | ||
if (!opts || id == undefined || opts.token == undefined || opts.target == undefined){ | ||
let error = new Error('The factory reset data is not valid'); | ||
error.code = 2; | ||
error.name = errors.find( x => x.status_code == error.code).message; | ||
return cb(error); | ||
} | ||
|
||
var finished = function(err, out) { | ||
logger.info('Factory Reset Process initialized!'); | ||
var output = null; | ||
|
||
if (!err) { | ||
output = {}; | ||
if (!out) return emitter.emit('end', id); | ||
|
||
if(out && out.error){ | ||
output.data = 1;//error | ||
output.message = out.message; | ||
logger.warn("Error executing Factory reset : " + out.message ); | ||
} | ||
else{ | ||
output.data = 0;// factory reset ok | ||
output.message = "OK"; | ||
} | ||
|
||
} | ||
if (!emitter) return; | ||
return emitter.emit('end', id, err, output); | ||
} | ||
|
||
token.post_token({action : opts.target, token : opts.token, id : opts.messageID },(err) => { | ||
|
||
console.log("error token->" , err) | ||
if (err) { | ||
let error = err; | ||
error.code = 5; | ||
error.name = errors.find( x => x.status_code == error.code).message; | ||
return cb(error); | ||
} | ||
|
||
var data = { | ||
key: "device-key", | ||
token: "token", | ||
logged: false, | ||
dirs : [file_factory_reset, time_execution(), process.arch] | ||
} | ||
|
||
action = 'factory-reset'; | ||
|
||
emitter = new Emitter; | ||
cb(null, emitter); | ||
|
||
system.spawn_as_admin_user(node_bin, data, function(err, child) { | ||
if(err){ | ||
logger.info('Error executing Factory Reset :' + JSON.stringify(err)); | ||
} | ||
if (typeof child == 'function') { // only for windows | ||
child(action, data, finished); | ||
} else { | ||
let error = new Error('Admin service not available'); | ||
error.code = 4; | ||
error.name = errors.find( x => x.status_code == error.code).message; | ||
return cb(error); | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
exports.stop = function(){ | ||
emitter = null; | ||
} |
Binary file not shown.
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,99 @@ | ||
var os = require('os'), | ||
path = require('path'), | ||
join = path.join, | ||
Emitter = require('events').EventEmitter, | ||
common = require('../../common'), | ||
logger = common.logger.prefix('fullwipe'), | ||
token = require('./../../token'), | ||
system = require('./../../../system'), | ||
errors = require('./../../errors').status; | ||
|
||
var emitter, | ||
action, | ||
node_bin = join(system.paths.current, 'bin', 'node'); | ||
|
||
exports.timeout = 2 * 60 * 1000; | ||
|
||
exports.start = function(id, opts, cb) { | ||
var os_name = os.platform().replace('darwin', 'mac').replace('win32', 'windows'); | ||
if (os_name != 'windows'){ | ||
let error = new Error('Action only allowed on Windows 1O'); | ||
error.code = 3; | ||
error.name = errors.find( x => x.status_code == error.code).message; | ||
return cb(error) | ||
} | ||
|
||
var opts = opts || {}; | ||
if (!opts || id == undefined || opts.token == undefined || opts.target == undefined){ | ||
let error = new Error('The factory reset data is not valid'); | ||
error.code = 2; | ||
error.name = errors.find( x => x.status_code == error.code).message; | ||
return cb(error); | ||
} | ||
|
||
var finished = function(err, out) { | ||
logger.info('Full Wipe Process initialized!'); | ||
var output = null; | ||
|
||
if (!err) { | ||
output = {}; | ||
if (!out) return emitter.emit('end', id); | ||
|
||
if(out && out.error){ | ||
output.data = 1;//error Fullwipe | ||
output.message = out.message; | ||
logger.warn("Error executing FullWipe: " + out.message ); | ||
err = new Error('Admin service Error'); | ||
err.code = 4; | ||
err.name = errors.find( x => x.status_code == err.code).message; | ||
} | ||
else{ | ||
output.data= 0;// full wipe ok | ||
output.message = "OK"; | ||
} | ||
} | ||
if (!emitter) return; | ||
return emitter.emit('end', id, err, output); | ||
} | ||
|
||
token.post_token({action : opts.target, token : opts.token, id : opts.messageID },(err) => { | ||
|
||
if (err) { | ||
let error = err; | ||
error.code = 5; | ||
error.name = errors.find( x => x.status_code == error.code).message; | ||
return cb(error); | ||
} | ||
|
||
var data = { | ||
key: "device-key", | ||
token: "token", | ||
logged: false, | ||
dirs : [] | ||
} | ||
|
||
action = 'full-wipe'; | ||
|
||
emitter = new Emitter; | ||
cb(null, emitter); | ||
|
||
system.spawn_as_admin_user(node_bin, data, function(err, child) { | ||
|
||
if(err){ | ||
logger.info('Error executing Full Wipe :' + JSON.stringify(err)); | ||
} | ||
if (typeof child == 'function') { // only for windows | ||
child(action, data, finished); | ||
} else { | ||
let error = new Error('Admin service not available'); | ||
error.code = 4; | ||
error.name = errors.find( x => x.status_code == error.code).message; | ||
return cb(error); | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
exports.stop = function(){ | ||
emitter = null; | ||
} |
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
Oops, something went wrong.