Fixed minification bug in login page.
This commit is contained in:
parent
39ab885174
commit
cdadf8595b
|
@ -274,19 +274,14 @@
|
|||
<Content Include="translate\readme.txt" />
|
||||
<Content Include="translate\translate.json" />
|
||||
<Content Include="views\agentinvite.handlebars" />
|
||||
<Content Include="views\default-min.handlebars" />
|
||||
<Content Include="views\default-mobile-min.handlebars" />
|
||||
<Content Include="views\default-mobile.handlebars" />
|
||||
<Content Include="views\default.handlebars" />
|
||||
<Content Include="views\download.handlebars" />
|
||||
<Content Include="views\error404-mobile.handlebars" />
|
||||
<Content Include="views\error404.handlebars" />
|
||||
<Content Include="views\login-min.handlebars" />
|
||||
<Content Include="views\login-mobile-min.handlebars" />
|
||||
<Content Include="views\login-mobile.handlebars" />
|
||||
<Content Include="views\login.handlebars" />
|
||||
<Content Include="views\message.handlebars" />
|
||||
<Content Include="views\messenger-min.handlebars" />
|
||||
<Content Include="views\messenger.handlebars" />
|
||||
<Content Include="views\terms-mobile.handlebars" />
|
||||
<Content Include="views\terms.handlebars" />
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -2564,39 +2564,47 @@ function removeItemFromArray(array, element) {
|
|||
}
|
||||
|
||||
// Run MeshCmd, but before we do, we need to see if what type of service we are going to be
|
||||
var serviceName = null;
|
||||
var serviceOpSpecified = 0;
|
||||
var serviceInstall = 0;
|
||||
|
||||
var serviceName = null, serviceDisplayName = null, serviceDesc = null;
|
||||
for (var i in process.argv) {
|
||||
if (process.argv[i].toLowerCase() == 'install') { serviceInstall = 1 } else if (process.argv[i].toLowerCase() == 'uninstall') { serviceInstall = -1 }
|
||||
if ((process.argv[i].toLowerCase() == 'microlms') || (process.argv[i].toLowerCase() == 'amtlms') || (process.argv[i].toLowerCase() == 'lms')) { serviceName = 'MicroLMS'; break; }
|
||||
if ((process.argv[i].toLowerCase() == 'meshcommander') || (process.argv[i].toLowerCase() == 'commander')) { serviceName = 'MeshCommander'; break; }
|
||||
if (process.argv[i].toLowerCase() == 'install') { process.argv[i] = '-install'; }
|
||||
if (process.argv[i].toLowerCase() == 'uninstall') { process.argv[i] = '-uninstall'; }
|
||||
if ((process.argv[i].toLowerCase() == 'microlms') || (process.argv[i].toLowerCase() == 'amtlms') || (process.argv[i].toLowerCase() == 'lms')) {
|
||||
serviceName = 'MicroLMS';
|
||||
serviceDisplayName = 'MicroLMS Service for Intel(R) AMT';
|
||||
serviceDesc = 'Intel AMT Micro Local Manageability Service (MicroLMS)';
|
||||
} else if ((process.argv[i].toLowerCase() == 'intellms')) {
|
||||
serviceName = 'LMS';
|
||||
serviceDisplayName = 'Intel(R) Management and Security Application Local Management Service';
|
||||
serviceDesc = 'Intel(R) Management and Security Application Local Management Service - Provides OS-related Intel(R) ME functionality.';
|
||||
} else if ((process.argv[i].toLowerCase() == 'meshcommander') || (process.argv[i].toLowerCase() == 'commander')) {
|
||||
serviceName = 'MeshCommander';
|
||||
serviceDisplayName = 'MeshCommander, Intel AMT Management console';
|
||||
serviceDesc = 'MeshCommander is a Intel AMT management console.';
|
||||
}
|
||||
}
|
||||
|
||||
if (serviceName == null) {
|
||||
for (var i in process.argv) {
|
||||
if ((process.argv[i].toLowerCase() == 'install') || (process.argv[i].toLowerCase() == 'uninstall')) {
|
||||
console.log('In order to install/uninstall, a service type must be specified.');
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
if (process.execPath.includes('MicroLMS')) { serviceName = 'MicroLMS'; }
|
||||
else if (process.execPath.includes('LMS')) { serviceName = 'LMS'; }
|
||||
else if (process.execPath.includes('MeshCommander')) { serviceName = 'MeshCommander'; }
|
||||
else { serviceName = 'not_a_service'; }
|
||||
if (serviceName == null) { for (var i in process.argv) { if ((process.argv[i].toLowerCase() == '-install') || (process.argv[i].toLowerCase() == '-uninstall')) { console.log('In order to install/uninstall, a service type must be specified.'); process.exit(); } } }
|
||||
if (serviceName == null) { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } process.exit(); }
|
||||
}
|
||||
|
||||
if (serviceInstall == 0) {
|
||||
run(process.argv);
|
||||
} else {
|
||||
var serviceHost = require('service-host');
|
||||
var meshcmdService = new serviceHost({ name: serviceName, startType: 'AUTO_START' });
|
||||
var meshcmdService = new serviceHost({ name: serviceName, displayName: serviceDisplayName, startType: 'AUTO_START', description: serviceDesc });
|
||||
|
||||
// Called when the background service is started.
|
||||
meshcmdService.on('serviceStart', function onStart() {
|
||||
//process.coreDumpLocation = 'C:\\tmp\\meshcommander.dmp';
|
||||
//process.on('exit', function () { console.log('exit3'); _debugCrash(); });
|
||||
console.setDestination(console.Destinations.DISABLED); // Disable console.log().
|
||||
if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } //
|
||||
else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); }
|
||||
//console.setDestination(console.Destinations.LOGFILE);
|
||||
//attachDebuger({ webport: 0, wait: 1 }).then(console.log, console.log);
|
||||
|
||||
if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS
|
||||
else if (process.execPath.includes('LMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS
|
||||
else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); } // Start MeshCommander
|
||||
else { console.log('Aborting Service Start, because unknown binary: ' + process.execPath); process.exit(1); }
|
||||
});
|
||||
|
||||
|
@ -2606,4 +2614,3 @@ if (serviceInstall == 0) {
|
|||
// Called when the executable is not running as a service, run normally.
|
||||
meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } });
|
||||
meshcmdService.run();
|
||||
}
|
||||
|
|
|
@ -2564,39 +2564,47 @@ function removeItemFromArray(array, element) {
|
|||
}
|
||||
|
||||
// Run MeshCmd, but before we do, we need to see if what type of service we are going to be
|
||||
var serviceName = null;
|
||||
var serviceOpSpecified = 0;
|
||||
var serviceInstall = 0;
|
||||
|
||||
var serviceName = null, serviceDisplayName = null, serviceDesc = null;
|
||||
for (var i in process.argv) {
|
||||
if (process.argv[i].toLowerCase() == 'install') { serviceInstall = 1 } else if (process.argv[i].toLowerCase() == 'uninstall') { serviceInstall = -1 }
|
||||
if ((process.argv[i].toLowerCase() == 'microlms') || (process.argv[i].toLowerCase() == 'amtlms') || (process.argv[i].toLowerCase() == 'lms')) { serviceName = 'MicroLMS'; break; }
|
||||
if ((process.argv[i].toLowerCase() == 'meshcommander') || (process.argv[i].toLowerCase() == 'commander')) { serviceName = 'MeshCommander'; break; }
|
||||
if (process.argv[i].toLowerCase() == 'install') { process.argv[i] = '-install'; }
|
||||
if (process.argv[i].toLowerCase() == 'uninstall') { process.argv[i] = '-uninstall'; }
|
||||
if ((process.argv[i].toLowerCase() == 'microlms') || (process.argv[i].toLowerCase() == 'amtlms') || (process.argv[i].toLowerCase() == 'lms')) {
|
||||
serviceName = 'MicroLMS';
|
||||
serviceDisplayName = 'MicroLMS Service for Intel(R) AMT';
|
||||
serviceDesc = 'Intel AMT Micro Local Manageability Service (MicroLMS)';
|
||||
} else if ((process.argv[i].toLowerCase() == 'intellms')) {
|
||||
serviceName = 'LMS';
|
||||
serviceDisplayName = 'Intel(R) Management and Security Application Local Management Service';
|
||||
serviceDesc = 'Intel(R) Management and Security Application Local Management Service - Provides OS-related Intel(R) ME functionality.';
|
||||
} else if ((process.argv[i].toLowerCase() == 'meshcommander') || (process.argv[i].toLowerCase() == 'commander')) {
|
||||
serviceName = 'MeshCommander';
|
||||
serviceDisplayName = 'MeshCommander, Intel AMT Management console';
|
||||
serviceDesc = 'MeshCommander is a Intel AMT management console.';
|
||||
}
|
||||
}
|
||||
|
||||
if (serviceName == null) {
|
||||
for (var i in process.argv) {
|
||||
if ((process.argv[i].toLowerCase() == 'install') || (process.argv[i].toLowerCase() == 'uninstall')) {
|
||||
console.log('In order to install/uninstall, a service type must be specified.');
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
if (process.execPath.includes('MicroLMS')) { serviceName = 'MicroLMS'; }
|
||||
else if (process.execPath.includes('LMS')) { serviceName = 'LMS'; }
|
||||
else if (process.execPath.includes('MeshCommander')) { serviceName = 'MeshCommander'; }
|
||||
else { serviceName = 'not_a_service'; }
|
||||
if (serviceName == null) { for (var i in process.argv) { if ((process.argv[i].toLowerCase() == '-install') || (process.argv[i].toLowerCase() == '-uninstall')) { console.log('In order to install/uninstall, a service type must be specified.'); process.exit(); } } }
|
||||
if (serviceName == null) { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } process.exit(); }
|
||||
}
|
||||
|
||||
if (serviceInstall == 0) {
|
||||
run(process.argv);
|
||||
} else {
|
||||
var serviceHost = require('service-host');
|
||||
var meshcmdService = new serviceHost({ name: serviceName, startType: 'AUTO_START' });
|
||||
var meshcmdService = new serviceHost({ name: serviceName, displayName: serviceDisplayName, startType: 'AUTO_START', description: serviceDesc });
|
||||
|
||||
// Called when the background service is started.
|
||||
meshcmdService.on('serviceStart', function onStart() {
|
||||
//process.coreDumpLocation = 'C:\\tmp\\meshcommander.dmp';
|
||||
//process.on('exit', function () { console.log('exit3'); _debugCrash(); });
|
||||
console.setDestination(console.Destinations.DISABLED); // Disable console.log().
|
||||
if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } //
|
||||
else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); }
|
||||
//console.setDestination(console.Destinations.LOGFILE);
|
||||
//attachDebuger({ webport: 0, wait: 1 }).then(console.log, console.log);
|
||||
|
||||
if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS
|
||||
else if (process.execPath.includes('LMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS
|
||||
else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); } // Start MeshCommander
|
||||
else { console.log('Aborting Service Start, because unknown binary: ' + process.execPath); process.exit(1); }
|
||||
});
|
||||
|
||||
|
@ -2606,4 +2614,3 @@ if (serviceInstall == 0) {
|
|||
// Called when the executable is not running as a service, run normally.
|
||||
meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } });
|
||||
meshcmdService.run();
|
||||
}
|
||||
|
|
|
@ -1,389 +0,0 @@
|
|||
/*
|
||||
Copyright 2018 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
var SERVICE_WIN32 = 0x00000010 | 0x00000020;
|
||||
var SERVICE_STATE = { STOPPED: 0x00000001, SERVICE_START_PENDING: 0x00000002, SERVICE_STOP_PENDING: 0x00000003, RUNNING: 0x00000004 };
|
||||
var SERVICE_ACCEPT = { SERVICE_ACCEPT_STOP: 0x00000001, SERVICE_ACCEPT_SHUTDOWN: 0x00000004, SERVICE_ACCEPT_POWEREVENT: 0x00000040, SERVICE_ACCEPT_SESSIONCHANGE: 0x00000080 };
|
||||
|
||||
var SERVICE_CONTROL = { SERVICE_CONTROL_SHUTDOWN: 0x00000005, SERVICE_CONTROL_STOP: 0x00000001, SERVICE_CONTROL_POWEREVENT: 0x0000000D, SERVICE_CONTROL_SESSIONCHANGE: 0x0000000E};
|
||||
var SESSION_CHANGE_TYPE =
|
||||
{
|
||||
WTS_CONSOLE_CONNECT: 0x1,
|
||||
WTS_CONSOLE_DISCONNECT: 0x2,
|
||||
WTS_REMOTE_CONNECT: 0x3,
|
||||
WTS_REMOTE_DISCONNECT: 0x4,
|
||||
WTS_SESSION_LOGON: 0x5,
|
||||
WTS_SESSION_LOGOFF: 0x6,
|
||||
WTS_SESSION_LOCK: 0x7,
|
||||
WTS_SESSION_UNLOCK: 0x8,
|
||||
WTS_SESSION_REMOTE_CONTROL: 0x9,
|
||||
WTS_SESSION_CREATE: 0xa,
|
||||
WTS_SESSION_TERMINATE: 0xb
|
||||
};
|
||||
|
||||
|
||||
var NO_ERROR = 0;
|
||||
|
||||
var serviceManager = require('service-manager');
|
||||
|
||||
function serviceHost(serviceName)
|
||||
{
|
||||
this._ObjectID = 'service-host';
|
||||
var emitterUtils = require('events').inherits(this);
|
||||
emitterUtils.createEvent('serviceStart');
|
||||
emitterUtils.createEvent('serviceStop');
|
||||
emitterUtils.createEvent('normalStart');
|
||||
emitterUtils.createEvent('session');
|
||||
emitterUtils.createEvent('powerStateChange');
|
||||
|
||||
if (process.platform == 'win32')
|
||||
{
|
||||
this.GM = require('_GenericMarshal');
|
||||
this.Advapi = this.GM.CreateNativeProxy('Advapi32.dll');
|
||||
this.Advapi.CreateMethod({ method: 'StartServiceCtrlDispatcherA', threadDispatch: 1 });
|
||||
this.Advapi.CreateMethod('RegisterServiceCtrlHandlerExA');
|
||||
this.Advapi.CreateMethod('SetServiceStatus');
|
||||
this.Kernel32 = this.GM.CreateNativeProxy('Kernel32.dll');
|
||||
this.Kernel32.CreateMethod('GetLastError');
|
||||
|
||||
this.Ole32 = this.GM.CreateNativeProxy('Ole32.dll');
|
||||
this.Ole32.CreateMethod('CoInitializeEx');
|
||||
this.Ole32.CreateMethod('CoUninitialize');
|
||||
|
||||
this._ServiceName = this.GM.CreateVariable(typeof (serviceName) == 'string' ? serviceName : serviceName.name);
|
||||
this._ServiceMain = this.GM.GetGenericGlobalCallback(2);
|
||||
this._ServiceMain.Parent = this;
|
||||
this._ServiceMain.GM = this.GM;
|
||||
this._ServiceMain.on('GlobalCallback', function onGlobalCallback(argc, argv)
|
||||
{
|
||||
//ToDo: Check to make sure this is for us
|
||||
|
||||
this.Parent._ServiceStatus = this.GM.CreateVariable(28);
|
||||
//typedef struct _SERVICE_STATUS {
|
||||
// DWORD dwServiceType;
|
||||
// DWORD dwCurrentState;
|
||||
// DWORD dwControlsAccepted;
|
||||
// DWORD dwWin32ExitCode;
|
||||
// DWORD dwServiceSpecificExitCode;
|
||||
// DWORD dwCheckPoint;
|
||||
// DWORD dwWaitHint;
|
||||
//} SERVICE_STATUS, *LPSERVICE_STATUS;
|
||||
|
||||
// Initialise service status
|
||||
this.Parent._ServiceStatus.toBuffer().writeUInt32LE(SERVICE_WIN32);
|
||||
this.Parent._ServiceStatus.toBuffer().writeUInt32LE(SERVICE_STATE.SERVICE_STOPPED, 4);
|
||||
this.Parent._ServiceStatusHandle = this.Parent.Advapi.RegisterServiceCtrlHandlerExA(this.Parent._ServiceName, this.Parent._ServiceControlHandler, this.Parent.GM.StashObject(this.Parent._ServiceControlHandler));
|
||||
if(this.Parent._ServiceStatusHandle.Val == 0)
|
||||
{
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Service is starting
|
||||
this.Parent._ServiceStatus.toBuffer().writeUInt32LE(SERVICE_STATE.SERVICE_START_PENDING, 4);
|
||||
this.Parent.Advapi.SetServiceStatus(this.Parent._ServiceStatusHandle, this.Parent._ServiceStatus);
|
||||
|
||||
// Service running
|
||||
this.Parent._ServiceStatus.toBuffer().writeUInt32LE(SERVICE_STATE.RUNNING, 4);
|
||||
this.Parent._ServiceStatus.toBuffer().writeUInt32LE(SERVICE_ACCEPT.SERVICE_ACCEPT_STOP | SERVICE_ACCEPT.SERVICE_ACCEPT_POWEREVENT | SERVICE_ACCEPT.SERVICE_ACCEPT_SESSIONCHANGE, 8);
|
||||
this.Parent.Advapi.SetServiceStatus(this.Parent._ServiceStatusHandle, this.Parent._ServiceStatus);
|
||||
|
||||
this.Parent.Ole32.CoInitializeEx(0, 2);
|
||||
this.Parent.on('~', function OnServiceHostFinalizer()
|
||||
{
|
||||
var GM = require('_GenericMarshal');
|
||||
var Advapi = GM.CreateNativeProxy('Advapi32.dll');
|
||||
Advapi.CreateMethod('SetServiceStatus');
|
||||
|
||||
Kernel32 = this.GM.CreateNativeProxy('Kernel32.dll');
|
||||
Kernel32.CreateMethod('GetLastError');
|
||||
|
||||
var status = GM.CreateVariable(28);
|
||||
|
||||
// Service was stopped
|
||||
status.toBuffer().writeUInt32LE(SERVICE_WIN32);
|
||||
status.toBuffer().writeUInt32LE(0x00000001, 4);
|
||||
status.toBuffer().writeUInt32LE(0, 8);
|
||||
|
||||
Advapi.SetServiceStatus(this._ServiceStatusHandle, status);
|
||||
|
||||
this.Ole32.CoUninitialize();
|
||||
});
|
||||
|
||||
this.Parent.emit('serviceStart');
|
||||
});
|
||||
this._ServiceControlHandler = this.GM.GetGenericGlobalCallback(4);
|
||||
this._ServiceControlHandler.Parent = this;
|
||||
this._ServiceControlHandler.GM = this.GM;
|
||||
this._ServiceControlHandler.on('GlobalCallback', function onServiceControlHandler(code, eventType, eventData, context)
|
||||
{
|
||||
var j = this.Parent.GM.UnstashObject(context);
|
||||
if (j != null && j == this)
|
||||
{
|
||||
switch (code.Val)
|
||||
{
|
||||
case SERVICE_CONTROL.SERVICE_CONTROL_SHUTDOWN:
|
||||
case SERVICE_CONTROL.SERVICE_CONTROL_STOP:
|
||||
this.Parent.emit('serviceStop');
|
||||
return;
|
||||
case SERVICE_CONTROL.SERVICE_CONTROL_SESSIONCHANGE:
|
||||
var sessionId = eventData.Deref(4, 4).toBuffer().readUInt32LE();
|
||||
switch(eventType.Val)
|
||||
{
|
||||
case SESSION_CHANGE_TYPE.WTS_SESSION_LOGON:
|
||||
case SESSION_CHANGE_TYPE.WTS_SESSION_LOGOFF:
|
||||
require('user-sessions').emit('changed');
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
this.Parent.Advapi.SetServiceStatus(this.Parent._ServiceStatusHandle, this.Parent._ServiceStatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (serviceName) { this._ServiceOptions = typeof (serviceName) == 'object' ? serviceName : { name: serviceName }; }
|
||||
else
|
||||
{
|
||||
throw ('Must specify either ServiceName or Options');
|
||||
}
|
||||
if (!this._ServiceOptions.servicePath)
|
||||
{
|
||||
this._ServiceOptions.servicePath = process.execPath;
|
||||
}
|
||||
|
||||
this.run = function run()
|
||||
{
|
||||
var serviceOperation = 0;
|
||||
|
||||
for(var i = 0; i<process.argv.length; ++i)
|
||||
{
|
||||
switch(process.argv[i])
|
||||
{
|
||||
case '-install':
|
||||
if (!this._svcManager) { this._svcManager = new serviceManager(); }
|
||||
try
|
||||
{
|
||||
this._svcManager.installService(this._ServiceOptions);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
console.log(e);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
console.log(this._ServiceOptions.name + ' installed');
|
||||
process.exit();
|
||||
break;
|
||||
case '-uninstall':
|
||||
if (!this._svcManager) { this._svcManager = new serviceManager(); }
|
||||
try
|
||||
{
|
||||
this._svcManager.uninstallService(this._ServiceOptions);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
console.log(e);
|
||||
process.exit();
|
||||
}
|
||||
if (process.platform == 'win32' || process.platform == 'darwin')
|
||||
{
|
||||
// Only do this on Windows/MacOS, becuase Linux is async... It'll complete later
|
||||
console.log(this._ServiceOptions.name + ' uninstalled');
|
||||
process.exit();
|
||||
}
|
||||
i = process.argv.length;
|
||||
serviceOperation = 1;
|
||||
break;
|
||||
case 'start':
|
||||
case '-d':
|
||||
if (process.platform != 'win32') { break; }
|
||||
if (!this._svcManager) { this._svcManager = new serviceManager(); }
|
||||
this._svcManager.getService(this._ServiceOptions.name).start();
|
||||
console.log(this._ServiceOptions.name + ' starting...');
|
||||
process.exit();
|
||||
break;
|
||||
case 'stop':
|
||||
case '-s':
|
||||
if (process.platform != 'win32') { break; }
|
||||
if (!this._svcManager) { this._svcManager = new serviceManager(); }
|
||||
this._svcManager.getService(this._ServiceOptions.name).stop();
|
||||
console.log(this._ServiceOptions.name + ' stopping...');
|
||||
process.exit();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (process.platform == 'win32')
|
||||
{
|
||||
var serviceTable = this.GM.CreateVariable(4 * this.GM.PointerSize);
|
||||
this._ServiceName.pointerBuffer().copy(serviceTable.toBuffer());
|
||||
this._ServiceMain.pointerBuffer().copy(serviceTable.toBuffer(), this.GM.PointerSize);
|
||||
this._sscd = this.Advapi.StartServiceCtrlDispatcherA(serviceTable);
|
||||
this._sscd.parent = this;
|
||||
this._sscd.on('done', function OnStartServiceCtrlDispatcherA(retVal) {
|
||||
if (retVal.Val == 0)
|
||||
{
|
||||
this.parent.emit('normalStart');
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
else if (process.platform == 'linux')
|
||||
{
|
||||
var moduleName = this._ServiceOptions ? this._ServiceOptions.name : process.execPath.substring(1 + process.execPath.lastIndexOf('/'));
|
||||
|
||||
for (var i = 0; i < process.argv.length; ++i) {
|
||||
switch (process.argv[i]) {
|
||||
case 'start':
|
||||
case '-d':
|
||||
var child = require('child_process').execFile(process.execPath, [moduleName], { type: require('child_process').SpawnTypes.DETACHED });
|
||||
var pstream = null;
|
||||
try {
|
||||
pstream = require('fs').createWriteStream('/var/run/' + moduleName + '.pid', { flags: 'w' });
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
if (pstream == null) {
|
||||
pstream = require('fs').createWriteStream('.' + moduleName + '.pid', { flags: 'w' });
|
||||
}
|
||||
pstream.end(child.pid.toString());
|
||||
|
||||
console.log(moduleName + ' started!');
|
||||
process.exit();
|
||||
break;
|
||||
case 'stop':
|
||||
case '-s':
|
||||
var pid = null;
|
||||
try {
|
||||
pid = parseInt(require('fs').readFileSync('/var/run/' + moduleName + '.pid', { flags: 'r' }));
|
||||
require('fs').unlinkSync('/var/run/' + moduleName + '.pid');
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
if (pid == null) {
|
||||
try {
|
||||
pid = parseInt(require('fs').readFileSync('.' + moduleName + '.pid', { flags: 'r' }));
|
||||
require('fs').unlinkSync('.' + moduleName + '.pid');
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (pid) {
|
||||
process.kill(pid);
|
||||
console.log(moduleName + ' stopped');
|
||||
}
|
||||
else {
|
||||
console.log(moduleName + ' not running');
|
||||
}
|
||||
process.exit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (serviceOperation == 0) {
|
||||
// This is non-windows, so we need to check how this binary was started to determine if this was a service start
|
||||
|
||||
// Start by checking if we were started with start/stop
|
||||
var pid = null;
|
||||
try {
|
||||
pid = parseInt(require('fs').readFileSync('/var/run/' + moduleName + '.pid', { flags: 'r' }));
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
if (pid == null) {
|
||||
try {
|
||||
pid = parseInt(require('fs').readFileSync('.' + moduleName + '.pid', { flags: 'r' }));
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (pid != null && pid == process.pid) {
|
||||
this.emit('serviceStart');
|
||||
}
|
||||
else {
|
||||
// Now we need to check if we were started with systemd
|
||||
if (require('process-manager').getProcessInfo(1).Name == 'systemd') {
|
||||
this._checkpid = require('child_process').execFile('/bin/sh', ['sh'], { type: require('child_process').SpawnTypes.TERM });
|
||||
this._checkpid.result = '';
|
||||
this._checkpid.parent = this;
|
||||
this._checkpid.on('exit', function onCheckPIDExit() {
|
||||
var lines = this.result.split('\r\n');
|
||||
for (i in lines) {
|
||||
if (lines[i].startsWith(' Main PID:')) {
|
||||
var tokens = lines[i].split(' ');
|
||||
if (parseInt(tokens[3]) == process.pid) {
|
||||
this.parent.emit('serviceStart');
|
||||
}
|
||||
else {
|
||||
this.parent.emit('normalStart');
|
||||
}
|
||||
delete this.parent._checkpid;
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.parent.emit('normalStart');
|
||||
delete this.parent._checkpid;
|
||||
});
|
||||
this._checkpid.stdout.on('data', function (chunk) { this.parent.result += chunk.toString(); });
|
||||
this._checkpid.stdin.write("systemctl status " + moduleName + " | grep 'Main PID:'\n");
|
||||
this._checkpid.stdin.write('exit\n');
|
||||
}
|
||||
else {
|
||||
// This isn't even a systemd platform, so this couldn't have been a service start
|
||||
this.emit('normalStart');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(process.platform == 'darwin')
|
||||
{
|
||||
// First let's fetch all the PIDs of running services
|
||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
child.stdout.str = '';
|
||||
child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
|
||||
child.stdin.write('launchctl list\nexit\n');
|
||||
child.waitExit();
|
||||
|
||||
var lines = child.stdout.str.split('\n');
|
||||
var tokens, i;
|
||||
var p = {};
|
||||
for (i = 1; i < lines.length; ++i)
|
||||
{
|
||||
tokens = lines[i].split('\t');
|
||||
if (tokens[0] && tokens[0] != '-') { p[tokens[0]] = tokens[0]; }
|
||||
}
|
||||
|
||||
if(p[process.pid.toString()])
|
||||
{
|
||||
// We are a service!
|
||||
this.emit('serviceStart');
|
||||
}
|
||||
else
|
||||
{
|
||||
this.emit('normalStart');
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = serviceHost;
|
|
@ -1,497 +0,0 @@
|
|||
/*
|
||||
Copyright 2018 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
function parseServiceStatus(token)
|
||||
{
|
||||
var j = {};
|
||||
var serviceType = token.Deref(0, 4).IntVal;
|
||||
j.isFileSystemDriver = ((serviceType & 0x00000002) == 0x00000002);
|
||||
j.isKernelDriver = ((serviceType & 0x00000001) == 0x00000001);
|
||||
j.isSharedProcess = ((serviceType & 0x00000020) == 0x00000020);
|
||||
j.isOwnProcess = ((serviceType & 0x00000010) == 0x00000010);
|
||||
j.isInteractive = ((serviceType & 0x00000100) == 0x00000100);
|
||||
switch (token.Deref((1 * 4), 4).toBuffer().readUInt32LE())
|
||||
{
|
||||
case 0x00000005:
|
||||
j.state = 'CONTINUE_PENDING';
|
||||
break;
|
||||
case 0x00000006:
|
||||
j.state = 'PAUSE_PENDING';
|
||||
break;
|
||||
case 0x00000007:
|
||||
j.state = 'PAUSED';
|
||||
break;
|
||||
case 0x00000004:
|
||||
j.state = 'RUNNING';
|
||||
break;
|
||||
case 0x00000002:
|
||||
j.state = 'START_PENDING';
|
||||
break;
|
||||
case 0x00000003:
|
||||
j.state = 'STOP_PENDING';
|
||||
break;
|
||||
case 0x00000001:
|
||||
j.state = 'STOPPED';
|
||||
break;
|
||||
}
|
||||
var controlsAccepted = token.Deref((2 * 4), 4).toBuffer().readUInt32LE();
|
||||
j.controlsAccepted = [];
|
||||
if ((controlsAccepted & 0x00000010) == 0x00000010)
|
||||
{
|
||||
j.controlsAccepted.push('SERVICE_CONTROL_NETBINDADD');
|
||||
j.controlsAccepted.push('SERVICE_CONTROL_NETBINDREMOVE');
|
||||
j.controlsAccepted.push('SERVICE_CONTROL_NETBINDENABLE');
|
||||
j.controlsAccepted.push('SERVICE_CONTROL_NETBINDDISABLE');
|
||||
}
|
||||
if ((controlsAccepted & 0x00000008) == 0x00000008) { j.controlsAccepted.push('SERVICE_CONTROL_PARAMCHANGE'); }
|
||||
if ((controlsAccepted & 0x00000002) == 0x00000002) { j.controlsAccepted.push('SERVICE_CONTROL_PAUSE'); j.controlsAccepted.push('SERVICE_CONTROL_CONTINUE'); }
|
||||
if ((controlsAccepted & 0x00000100) == 0x00000100) { j.controlsAccepted.push('SERVICE_CONTROL_PRESHUTDOWN'); }
|
||||
if ((controlsAccepted & 0x00000004) == 0x00000004) { j.controlsAccepted.push('SERVICE_CONTROL_SHUTDOWN'); }
|
||||
if ((controlsAccepted & 0x00000001) == 0x00000001) { j.controlsAccepted.push('SERVICE_CONTROL_STOP'); }
|
||||
if ((controlsAccepted & 0x00000020) == 0x00000020) { j.controlsAccepted.push('SERVICE_CONTROL_HARDWAREPROFILECHANGE'); }
|
||||
if ((controlsAccepted & 0x00000040) == 0x00000040) { j.controlsAccepted.push('SERVICE_CONTROL_POWEREVENT'); }
|
||||
if ((controlsAccepted & 0x00000080) == 0x00000080) { j.controlsAccepted.push('SERVICE_CONTROL_SESSIONCHANGE'); }
|
||||
j.pid = token.Deref((7 * 4), 4).toBuffer().readUInt32LE();
|
||||
return (j);
|
||||
}
|
||||
|
||||
function serviceManager()
|
||||
{
|
||||
this._ObjectID = 'service-manager';
|
||||
if (process.platform == 'win32')
|
||||
{
|
||||
this.GM = require('_GenericMarshal');
|
||||
this.proxy = this.GM.CreateNativeProxy('Advapi32.dll');
|
||||
this.proxy.CreateMethod('OpenSCManagerA');
|
||||
this.proxy.CreateMethod('EnumServicesStatusExA');
|
||||
this.proxy.CreateMethod('OpenServiceA');
|
||||
this.proxy.CreateMethod('QueryServiceStatusEx');
|
||||
this.proxy.CreateMethod('ControlService');
|
||||
this.proxy.CreateMethod('StartServiceA');
|
||||
this.proxy.CreateMethod('CloseServiceHandle');
|
||||
this.proxy.CreateMethod('CreateServiceA');
|
||||
this.proxy.CreateMethod('ChangeServiceConfig2A');
|
||||
this.proxy.CreateMethod('DeleteService');
|
||||
this.proxy.CreateMethod('AllocateAndInitializeSid');
|
||||
this.proxy.CreateMethod('CheckTokenMembership');
|
||||
this.proxy.CreateMethod('FreeSid');
|
||||
|
||||
this.proxy2 = this.GM.CreateNativeProxy('Kernel32.dll');
|
||||
this.proxy2.CreateMethod('GetLastError');
|
||||
|
||||
this.isAdmin = function isAdmin() {
|
||||
var NTAuthority = this.GM.CreateVariable(6);
|
||||
NTAuthority.toBuffer().writeInt8(5, 5);
|
||||
var AdministratorsGroup = this.GM.CreatePointer();
|
||||
var admin = false;
|
||||
|
||||
if (this.proxy.AllocateAndInitializeSid(NTAuthority, 2, 32, 544, 0, 0, 0, 0, 0, 0, AdministratorsGroup).Val != 0)
|
||||
{
|
||||
var member = this.GM.CreateInteger();
|
||||
if (this.proxy.CheckTokenMembership(0, AdministratorsGroup.Deref(), member).Val != 0)
|
||||
{
|
||||
if (member.toBuffer().readUInt32LE() != 0) { admin = true; }
|
||||
}
|
||||
this.proxy.FreeSid(AdministratorsGroup.Deref());
|
||||
}
|
||||
return admin;
|
||||
};
|
||||
this.getProgramFolder = function getProgramFolder()
|
||||
{
|
||||
if (require('os').arch() == 'x64')
|
||||
{
|
||||
// 64 bit Windows
|
||||
if (this.GM.PointerSize == 4)
|
||||
{
|
||||
return process.env['ProgramFiles(x86)']; // 32 Bit App
|
||||
}
|
||||
return process.env['ProgramFiles']; // 64 bit App
|
||||
}
|
||||
|
||||
// 32 bit Windows
|
||||
return process.env['ProgramFiles'];
|
||||
};
|
||||
this.getServiceFolder = function getServiceFolder() { return this.getProgramFolder() + '\\mesh'; };
|
||||
|
||||
this.enumerateService = function () {
|
||||
var machineName = this.GM.CreatePointer();
|
||||
var dbName = this.GM.CreatePointer();
|
||||
var handle = this.proxy.OpenSCManagerA(0x00, 0x00, 0x0001 | 0x0004);
|
||||
|
||||
var bytesNeeded = this.GM.CreatePointer();
|
||||
var servicesReturned = this.GM.CreatePointer();
|
||||
var resumeHandle = this.GM.CreatePointer();
|
||||
//var services = this.proxy.CreateVariable(262144);
|
||||
var success = this.proxy.EnumServicesStatusExA(handle, 0, 0x00000030, 0x00000003, 0x00, 0x00, bytesNeeded, servicesReturned, resumeHandle, 0x00);
|
||||
if (bytesNeeded.IntVal <= 0) {
|
||||
throw ('error enumerating services');
|
||||
}
|
||||
var sz = bytesNeeded.IntVal;
|
||||
var services = this.GM.CreateVariable(sz);
|
||||
this.proxy.EnumServicesStatusExA(handle, 0, 0x00000030, 0x00000003, services, sz, bytesNeeded, servicesReturned, resumeHandle, 0x00);
|
||||
console.log("servicesReturned", servicesReturned.IntVal);
|
||||
|
||||
var ptrSize = dbName._size;
|
||||
var blockSize = 36 + (2 * ptrSize);
|
||||
blockSize += ((ptrSize - (blockSize % ptrSize)) % ptrSize);
|
||||
var retVal = [];
|
||||
for (var i = 0; i < servicesReturned.IntVal; ++i) {
|
||||
var token = services.Deref(i * blockSize, blockSize);
|
||||
var j = {};
|
||||
j.name = token.Deref(0, ptrSize).Deref().String;
|
||||
j.displayName = token.Deref(ptrSize, ptrSize).Deref().String;
|
||||
j.status = parseServiceStatus(token.Deref(2 * ptrSize, 36));
|
||||
retVal.push(j);
|
||||
}
|
||||
this.proxy.CloseServiceHandle(handle);
|
||||
return (retVal);
|
||||
}
|
||||
this.getService = function (name) {
|
||||
var serviceName = this.GM.CreateVariable(name);
|
||||
var ptr = this.GM.CreatePointer();
|
||||
var bytesNeeded = this.GM.CreateVariable(ptr._size);
|
||||
var handle = this.proxy.OpenSCManagerA(0x00, 0x00, 0x0001 | 0x0004 | 0x0020 | 0x0010);
|
||||
if (handle.Val == 0) { throw ('could not open ServiceManager'); }
|
||||
var h = this.proxy.OpenServiceA(handle, serviceName, 0x0004 | 0x0020 | 0x0010 | 0x00010000);
|
||||
if (h.Val != 0) {
|
||||
var success = this.proxy.QueryServiceStatusEx(h, 0, 0, 0, bytesNeeded);
|
||||
var status = this.GM.CreateVariable(bytesNeeded.toBuffer().readUInt32LE());
|
||||
success = this.proxy.QueryServiceStatusEx(h, 0, status, status._size, bytesNeeded);
|
||||
if (success != 0) {
|
||||
retVal = {};
|
||||
retVal.status = parseServiceStatus(status);
|
||||
retVal._scm = handle;
|
||||
retVal._service = h;
|
||||
retVal._GM = this.GM;
|
||||
retVal._proxy = this.proxy;
|
||||
require('events').inherits(retVal);
|
||||
retVal.on('~', function () { this._proxy.CloseServiceHandle(this); this._proxy.CloseServiceHandle(this._scm); });
|
||||
retVal.name = name;
|
||||
retVal.stop = function () {
|
||||
if (this.status.state == 'RUNNING') {
|
||||
var newstate = this._GM.CreateVariable(36);
|
||||
var success = this._proxy.ControlService(this._service, 0x00000001, newstate);
|
||||
if (success == 0) {
|
||||
throw (this.name + '.stop() failed');
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw ('cannot call ' + this.name + '.stop(), when current state is: ' + this.status.state);
|
||||
}
|
||||
}
|
||||
retVal.start = function () {
|
||||
if (this.status.state == 'STOPPED') {
|
||||
var success = this._proxy.StartServiceA(this._service, 0, 0);
|
||||
if (success == 0) {
|
||||
throw (this.name + '.start() failed');
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw ('cannot call ' + this.name + '.start(), when current state is: ' + this.status.state);
|
||||
}
|
||||
}
|
||||
return (retVal);
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
this.proxy.CloseServiceHandle(handle);
|
||||
throw ('could not find service: ' + name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isAdmin = function isAdmin()
|
||||
{
|
||||
return (require('user-sessions').isRoot());
|
||||
}
|
||||
}
|
||||
this.installService = function installService(options)
|
||||
{
|
||||
if (process.platform == 'win32')
|
||||
{
|
||||
if (!this.isAdmin()) { throw ('Installing as Service, requires admin'); }
|
||||
|
||||
// Before we start, we need to copy the binary to the right place
|
||||
var folder = this.getServiceFolder();
|
||||
if (!require('fs').existsSync(folder)) { require('fs').mkdirSync(folder); }
|
||||
require('fs').copyFileSync(options.servicePath, folder + '\\' + options.name + '.exe');
|
||||
options.servicePath = folder + '\\' + options.name + '.exe';
|
||||
|
||||
var servicePath = this.GM.CreateVariable('"' + options.servicePath + '"');
|
||||
var handle = this.proxy.OpenSCManagerA(0x00, 0x00, 0x0002);
|
||||
if (handle.Val == 0) { throw ('error opening SCManager'); }
|
||||
var serviceName = this.GM.CreateVariable(options.name);
|
||||
var displayName = this.GM.CreateVariable(options.name);
|
||||
var allAccess = 0x000F01FF;
|
||||
var serviceType;
|
||||
|
||||
|
||||
switch (options.startType) {
|
||||
case 'BOOT_START':
|
||||
serviceType = 0x00;
|
||||
break;
|
||||
case 'SYSTEM_START':
|
||||
serviceType = 0x01;
|
||||
break;
|
||||
case 'AUTO_START':
|
||||
serviceType = 0x02;
|
||||
break;
|
||||
case 'DEMAND_START':
|
||||
serviceType = 0x03;
|
||||
break;
|
||||
default:
|
||||
serviceType = 0x04; // Disabled
|
||||
break;
|
||||
}
|
||||
|
||||
var h = this.proxy.CreateServiceA(handle, serviceName, displayName, allAccess, 0x10 | 0x100, serviceType, 0, servicePath, 0, 0, 0, 0, 0);
|
||||
if (h.Val == 0) { this.proxy.CloseServiceHandle(handle); throw ('Error Creating Service: ' + this.proxy2.GetLastError().Val); }
|
||||
if (options.description) {
|
||||
console.log(options.description);
|
||||
|
||||
var dscPtr = this.GM.CreatePointer();
|
||||
dscPtr.Val = this.GM.CreateVariable(options.description);
|
||||
|
||||
if (this.proxy.ChangeServiceConfig2A(h, 1, dscPtr) == 0) {
|
||||
this.proxy.CloseServiceHandle(h);
|
||||
this.proxy.CloseServiceHandle(handle);
|
||||
throw ('Unable to set description');
|
||||
}
|
||||
}
|
||||
this.proxy.CloseServiceHandle(h);
|
||||
this.proxy.CloseServiceHandle(handle);
|
||||
return (this.getService(options.name));
|
||||
}
|
||||
if(process.platform == 'linux')
|
||||
{
|
||||
if (!this.isAdmin()) { throw ('Installing as Service, requires root'); }
|
||||
|
||||
switch (this.getServiceType())
|
||||
{
|
||||
case 'init':
|
||||
require('fs').copyFileSync(options.servicePath, '/etc/init.d/' + options.name);
|
||||
console.log('copying ' + options.servicePath);
|
||||
var m = require('fs').statSync('/etc/init.d/' + options.name).mode;
|
||||
m |= (require('fs').CHMOD_MODES.S_IXUSR | require('fs').CHMOD_MODES.S_IXGRP);
|
||||
require('fs').chmodSync('/etc/init.d/' + options.name, m);
|
||||
this._update = require('child_process').execFile('/bin/sh', ['sh'], { type: require('child_process').SpawnTypes.TERM });
|
||||
this._update._moduleName = options.name;
|
||||
this._update.stdout.on('data', function (chunk) { });
|
||||
this._update.stdin.write('update-rc.d ' + options.name + ' defaults\n');
|
||||
this._update.stdin.write('exit\n');
|
||||
//update-rc.d meshagent defaults # creates symlinks for rc.d
|
||||
//service meshagent start
|
||||
|
||||
this._update.waitExit();
|
||||
|
||||
break;
|
||||
case 'systemd':
|
||||
var serviceDescription = options.description ? options.description : 'MeshCentral Agent';
|
||||
if (!require('fs').existsSync('/usr/local/mesh')) { require('fs').mkdirSync('/usr/local/mesh'); }
|
||||
require('fs').copyFileSync(options.servicePath, '/usr/local/mesh/' + options.name);
|
||||
var m = require('fs').statSync('/usr/local/mesh/' + options.name).mode;
|
||||
m |= (require('fs').CHMOD_MODES.S_IXUSR | require('fs').CHMOD_MODES.S_IXGRP);
|
||||
require('fs').chmodSync('/usr/local/mesh/' + options.name, m);
|
||||
require('fs').writeFileSync('/lib/systemd/system/' + options.name + '.service', '[Unit]\nDescription=' + serviceDescription + '\n[Service]\nExecStart=/usr/local/mesh/' + options.name + '\nStandardOutput=null\nRestart=always\nRestartSec=3\n[Install]\nWantedBy=multi-user.target\nAlias=' + options.name + '.service\n', { flags: 'w' });
|
||||
this._update = require('child_process').execFile('/bin/sh', ['sh'], { type: require('child_process').SpawnTypes.TERM });
|
||||
this._update._moduleName = options.name;
|
||||
this._update.stdout.on('data', function (chunk) { });
|
||||
this._update.stdin.write('systemctl enable ' + options.name + '.service\n');
|
||||
this._update.stdin.write('exit\n');
|
||||
this._update.waitExit();
|
||||
break;
|
||||
default: // unknown platform service type
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(process.platform == 'darwin')
|
||||
{
|
||||
if (!this.isAdmin()) { throw ('Installing as Service, requires root'); }
|
||||
|
||||
// Mac OS
|
||||
var stdoutpath = (options.stdout ? ('<key>StandardOutPath</key>\n<string>' + options.stdout + '</string>') : '');
|
||||
var autoStart = (options.startType == 'AUTO_START' ? '<true/>' : '<false/>');
|
||||
var params = ' <key>ProgramArguments</key>\n';
|
||||
params += ' <array>\n';
|
||||
params += (' <string>/usr/local/mesh_services/' + options.name + '/' + options.name + '</string>\n');
|
||||
if(options.parameters)
|
||||
{
|
||||
for(var itm in options.parameters)
|
||||
{
|
||||
params += (' <string>' + options.parameters[itm] + '</string>\n');
|
||||
}
|
||||
}
|
||||
params += ' </array>\n';
|
||||
|
||||
var plist = '<?xml version="1.0" encoding="UTF-8"?>\n';
|
||||
plist += '<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n';
|
||||
plist += '<plist version="1.0">\n';
|
||||
plist += ' <dict>\n';
|
||||
plist += ' <key>Label</key>\n';
|
||||
plist += (' <string>' + options.name + '</string>\n');
|
||||
plist += (params + '\n');
|
||||
plist += ' <key>WorkingDirectory</key>\n';
|
||||
plist += (' <string>/usr/local/mesh_services/' + options.name + '</string>\n');
|
||||
plist += (stdoutpath + '\n');
|
||||
plist += ' <key>RunAtLoad</key>\n';
|
||||
plist += (autoStart + '\n');
|
||||
plist += ' </dict>\n';
|
||||
plist += '</plist>';
|
||||
|
||||
if (!require('fs').existsSync('/usr/local/mesh_services')) { require('fs').mkdirSync('/usr/local/mesh_services'); }
|
||||
if (!require('fs').existsSync('/Library/LaunchDaemons/' + options.name + '.plist'))
|
||||
{
|
||||
if (!require('fs').existsSync('/usr/local/mesh_services/' + options.name)) { require('fs').mkdirSync('/usr/local/mesh_services/' + options.name); }
|
||||
if (options.binary)
|
||||
{
|
||||
require('fs').writeFileSync('/usr/local/mesh_services/' + options.name + '/' + options.name, options.binary);
|
||||
}
|
||||
else
|
||||
{
|
||||
require('fs').copyFileSync(options.servicePath, '/usr/local/mesh_services/' + options.name + '/' + options.name);
|
||||
}
|
||||
require('fs').writeFileSync('/Library/LaunchDaemons/' + options.name + '.plist', plist);
|
||||
var m = require('fs').statSync('/usr/local/mesh_services/' + options.name + '/' + options.name).mode;
|
||||
m |= (require('fs').CHMOD_MODES.S_IXUSR | require('fs').CHMOD_MODES.S_IXGRP);
|
||||
require('fs').chmodSync('/usr/local/mesh_services/' + options.name + '/' + options.name, m);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ('Service: ' + options.name + ' already exists');
|
||||
}
|
||||
}
|
||||
}
|
||||
this.uninstallService = function uninstallService(name)
|
||||
{
|
||||
if (!this.isAdmin()) { throw ('Uninstalling a service, requires admin'); }
|
||||
|
||||
if (typeof (name) == 'object') { name = name.name; }
|
||||
if (process.platform == 'win32')
|
||||
{
|
||||
var service = this.getService(name);
|
||||
if (service.status.state == undefined || service.status.state == 'STOPPED')
|
||||
{
|
||||
if (this.proxy.DeleteService(service._service) == 0)
|
||||
{
|
||||
throw ('Uninstall Service for: ' + name + ', failed with error: ' + this.proxy2.GetLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
require('fs').unlinkSync(this.getServiceFolder() + '\\' + name + '.exe');
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ('Cannot uninstall service: ' + name + ', because it is: ' + service.status.state);
|
||||
}
|
||||
}
|
||||
else if(process.platform == 'linux')
|
||||
{
|
||||
switch (this.getServiceType())
|
||||
{
|
||||
case 'init':
|
||||
this._update = require('child_process').execFile('/bin/sh', ['sh'], { type: require('child_process').SpawnTypes.TERM });
|
||||
this._update.stdout.on('data', function (chunk) { });
|
||||
this._update.stdin.write('service ' + name + ' stop\n');
|
||||
this._update.stdin.write('update-rc.d -f ' + name + ' remove\n');
|
||||
this._update.stdin.write('exit\n');
|
||||
this._update.waitExit();
|
||||
try
|
||||
{
|
||||
require('fs').unlinkSync('/etc/init.d/' + name);
|
||||
console.log(name + ' uninstalled');
|
||||
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
console.log(name + ' could not be uninstalled', e)
|
||||
}
|
||||
break;
|
||||
case 'systemd':
|
||||
this._update = require('child_process').execFile('/bin/sh', ['sh'], { type: require('child_process').SpawnTypes.TERM });
|
||||
this._update.stdout.on('data', function (chunk) { });
|
||||
this._update.stdin.write('systemctl stop ' + name + '.service\n');
|
||||
this._update.stdin.write('systemctl disable ' + name + '.service\n');
|
||||
this._update.stdin.write('exit\n');
|
||||
this._update.waitExit();
|
||||
try
|
||||
{
|
||||
require('fs').unlinkSync('/usr/local/mesh/' + name);
|
||||
require('fs').unlinkSync('/lib/systemd/system/' + name + '.service');
|
||||
console.log(name + ' uninstalled');
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
console.log(name + ' could not be uninstalled', e)
|
||||
}
|
||||
break;
|
||||
default: // unknown platform service type
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(process.platform == 'darwin')
|
||||
{
|
||||
if (require('fs').existsSync('/Library/LaunchDaemons/' + name + '.plist'))
|
||||
{
|
||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
child.stdout.on('data', function (chunk) { });
|
||||
child.stdin.write('launchctl stop ' + name + '\n');
|
||||
child.stdin.write('launchctl unload /Library/LaunchDaemons/' + name + '.plist\n');
|
||||
child.stdin.write('exit\n');
|
||||
child.waitExit();
|
||||
|
||||
try
|
||||
{
|
||||
require('fs').unlinkSync('/usr/local/mesh_services/' + name + '/' + name);
|
||||
require('fs').unlinkSync('/Library/LaunchDaemons/' + name + '.plist');
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
throw ('Error uninstalling service: ' + name + ' => ' + e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
require('fs').rmdirSync('/usr/local/mesh_services/' + name);
|
||||
}
|
||||
catch(e)
|
||||
{}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ('Service: ' + name + ' does not exist');
|
||||
}
|
||||
}
|
||||
}
|
||||
if(process.platform == 'linux')
|
||||
{
|
||||
this.getServiceType = function getServiceType()
|
||||
{
|
||||
return (require('process-manager').getProcessInfo(1).Name);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = serviceManager;
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "meshcentral",
|
||||
"version": "0.4.3-a",
|
||||
"version": "0.4.3-c",
|
||||
"keywords": [
|
||||
"Remote Management",
|
||||
"Intel AMT",
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
@ECHO OFF
|
||||
CD ..\translate
|
||||
C:\Users\Default.DESKTOP-M9I88C9\AppData\Roaming\nvm\v12.13.0\node translate.js minifyall
|
|
@ -141,7 +141,7 @@ function start() {
|
|||
if (minifyLib = 2) {
|
||||
var minifiedOut = minify(fs.readFileSync(outname).toString(), {
|
||||
collapseBooleanAttributes: true,
|
||||
collapseInlineTagWhitespace: true,
|
||||
collapseInlineTagWhitespace: false, // This is not good.
|
||||
collapseWhitespace: true,
|
||||
minifyCSS: true,
|
||||
minifyJS: true,
|
||||
|
@ -333,7 +333,7 @@ function translateFromHtml(lang, file, createSubDir) {
|
|||
if (minifyLib = 2) {
|
||||
var minifiedOut = minify(out, {
|
||||
collapseBooleanAttributes: true,
|
||||
collapseInlineTagWhitespace: true,
|
||||
collapseInlineTagWhitespace: false, // This is not good.
|
||||
collapseWhitespace: true,
|
||||
minifyCSS: true,
|
||||
minifyJS: true,
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -267,6 +267,8 @@
|
|||
</div>
|
||||
<script>
|
||||
'use strict';
|
||||
var loginMode = '{{{loginmode}}}';
|
||||
var newAccount = '{{{newAccount}}}';
|
||||
var passhint = '{{{passhint}}}';
|
||||
var newAccountPass = parseInt('{{{newAccountPass}}}');
|
||||
var emailCheck = ('{{{emailcheck}}}' == 'true');
|
||||
|
@ -309,14 +311,14 @@
|
|||
center();
|
||||
validateLogin();
|
||||
validateCreate();
|
||||
if ('{{loginmode}}' != '') { go(parseInt('{{loginmode}}')); } else { go(1); }
|
||||
QV('newAccountDiv', ('{{{newAccount}}}' === '1') || ('{{{newAccount}}}' === 'true')); // If new accounts are not allowed, don't display the new account link.
|
||||
if (loginMode.length != 0) { go(parseInt(loginMode)); } else { go(1); }
|
||||
QV('newAccountDiv', (newAccount === '1') || (newAccount === 'true')); // If new accounts are not allowed, don't display the new account link.
|
||||
if ((passRequirements.hint === true) && (passhint != null) && (passhint.length > 0)) { QV('showPassHintLink', true); }
|
||||
QV('newAccountPass', (newAccountPass == 1));
|
||||
QV('resetAccountDiv', (emailCheck == true));
|
||||
QV('hrAccountDiv', (emailCheck == true) || (newAccountPass == 1));
|
||||
|
||||
if ('{{loginmode}}' == '4') {
|
||||
if (loginMode == '4') {
|
||||
try { if (hardwareKeyChallenge.length > 0) { hardwareKeyChallenge = JSON.parse(hardwareKeyChallenge); } else { hardwareKeyChallenge = null; } } catch (ex) { hardwareKeyChallenge = null }
|
||||
if ((hardwareKeyChallenge != null) && (hardwareKeyChallenge.type == 'webAuthn')) {
|
||||
hardwareKeyChallenge.challenge = Uint8Array.from(atob(hardwareKeyChallenge.challenge), function (c) { return c.charCodeAt(0) }).buffer;
|
||||
|
@ -347,7 +349,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
if ('{{loginmode}}' == '5') {
|
||||
if (loginMode == '5') {
|
||||
try { if (hardwareKeyChallenge.length > 0) { hardwareKeyChallenge = JSON.parse(hardwareKeyChallenge); } else { hardwareKeyChallenge = null; } } catch (ex) { hardwareKeyChallenge = null }
|
||||
if ((hardwareKeyChallenge != null) && (hardwareKeyChallenge.type == 'webAuthn')) {
|
||||
hardwareKeyChallenge.challenge = Uint8Array.from(atob(hardwareKeyChallenge.challenge), function (c) { return c.charCodeAt(0) }).buffer;
|
||||
|
|
|
@ -260,6 +260,8 @@
|
|||
<script>
|
||||
'use strict';
|
||||
var passhint = '{{{passhint}}}';
|
||||
var loginMode = '{{{loginmode}}}';
|
||||
var newAccount = '{{{newAccount}}}';
|
||||
var newAccountPass = parseInt('{{{newAccountPass}}}');
|
||||
var emailCheck = ('{{{emailcheck}}}' == 'true');
|
||||
var passRequirements = '{{{passRequirements}}}';
|
||||
|
@ -318,14 +320,14 @@
|
|||
|
||||
validateLogin();
|
||||
validateCreate();
|
||||
if ('{{loginmode}}' != '') { go(parseInt('{{loginmode}}')); } else { go(1); }
|
||||
QV('newAccountDiv', ('{{{newAccount}}}' === '1') || ('{{{newAccount}}}' === 'true')); // If new accounts are not allowed, don't display the new account link.
|
||||
if (loginMode.length != 0) { go(parseInt(loginMode)); } else { go(1); }
|
||||
QV('newAccountDiv', (newAccount === '1') || (newAccount === 'true')); // If new accounts are not allowed, don't display the new account link.
|
||||
if ((passhint != null) && (passhint.length > 0)) { QV('showPassHintLink', true); }
|
||||
QV('newAccountPass', (newAccountPass == 1));
|
||||
QV('resetAccountDiv', (emailCheck == true));
|
||||
QV('hrAccountDiv', (emailCheck == true) || (newAccountPass == 1));
|
||||
|
||||
if ('{{loginmode}}' == '4') {
|
||||
if (loginMode == '4') {
|
||||
try { if (hardwareKeyChallenge.length > 0) { hardwareKeyChallenge = JSON.parse(hardwareKeyChallenge); } else { hardwareKeyChallenge = null; } } catch (ex) { hardwareKeyChallenge = null }
|
||||
if ((hardwareKeyChallenge != null) && (hardwareKeyChallenge.type == 'webAuthn')) {
|
||||
hardwareKeyChallenge.challenge = Uint8Array.from(atob(hardwareKeyChallenge.challenge), function (c) { return c.charCodeAt(0) }).buffer;
|
||||
|
@ -358,7 +360,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
if ('{{loginmode}}' == '5') {
|
||||
if (loginMode == '5') {
|
||||
try { if (hardwareKeyChallenge.length > 0) { hardwareKeyChallenge = JSON.parse(hardwareKeyChallenge); } else { hardwareKeyChallenge = null; } } catch (ex) { hardwareKeyChallenge = null }
|
||||
if ((hardwareKeyChallenge != null) && (hardwareKeyChallenge.type == 'webAuthn')) {
|
||||
hardwareKeyChallenge.challenge = Uint8Array.from(atob(hardwareKeyChallenge.challenge), function (c) { return c.charCodeAt(0) }).buffer;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -265,6 +265,8 @@
|
|||
</div>
|
||||
<script>
|
||||
'use strict';
|
||||
var loginMode = '{{{loginmode}}}';
|
||||
var newAccount = '{{{newAccount}}}';
|
||||
var passhint = '{{{passhint}}}';
|
||||
var newAccountPass = parseInt('{{{newAccountPass}}}');
|
||||
var emailCheck = ('{{{emailcheck}}}' == 'true');
|
||||
|
@ -307,14 +309,14 @@
|
|||
center();
|
||||
validateLogin();
|
||||
validateCreate();
|
||||
if ('{{loginmode}}' != '') { go(parseInt('{{loginmode}}')); } else { go(1); }
|
||||
QV('newAccountDiv', ('{{{newAccount}}}' === '1') || ('{{{newAccount}}}' === 'true')); // If new accounts are not allowed, don't display the new account link.
|
||||
if (loginMode.length != 0) { go(parseInt(loginMode)); } else { go(1); }
|
||||
QV('newAccountDiv', (newAccount === '1') || (newAccount === 'true')); // If new accounts are not allowed, don't display the new account link.
|
||||
if ((passRequirements.hint === true) && (passhint != null) && (passhint.length > 0)) { QV('showPassHintLink', true); }
|
||||
QV('newAccountPass', (newAccountPass == 1));
|
||||
QV('resetAccountDiv', (emailCheck == true));
|
||||
QV('hrAccountDiv', (emailCheck == true) || (newAccountPass == 1));
|
||||
|
||||
if ('{{loginmode}}' == '4') {
|
||||
if (loginMode == '4') {
|
||||
try { if (hardwareKeyChallenge.length > 0) { hardwareKeyChallenge = JSON.parse(hardwareKeyChallenge); } else { hardwareKeyChallenge = null; } } catch (ex) { hardwareKeyChallenge = null }
|
||||
if ((hardwareKeyChallenge != null) && (hardwareKeyChallenge.type == 'webAuthn')) {
|
||||
hardwareKeyChallenge.challenge = Uint8Array.from(atob(hardwareKeyChallenge.challenge), function (c) { return c.charCodeAt(0) }).buffer;
|
||||
|
@ -345,7 +347,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
if ('{{loginmode}}' == '5') {
|
||||
if (loginMode == '5') {
|
||||
try { if (hardwareKeyChallenge.length > 0) { hardwareKeyChallenge = JSON.parse(hardwareKeyChallenge); } else { hardwareKeyChallenge = null; } } catch (ex) { hardwareKeyChallenge = null }
|
||||
if ((hardwareKeyChallenge != null) && (hardwareKeyChallenge.type == 'webAuthn')) {
|
||||
hardwareKeyChallenge.challenge = Uint8Array.from(atob(hardwareKeyChallenge.challenge), function (c) { return c.charCodeAt(0) }).buffer;
|
||||
|
|
|
@ -258,6 +258,8 @@
|
|||
<script>
|
||||
'use strict';
|
||||
var passhint = '{{{passhint}}}';
|
||||
var loginMode = '{{{loginmode}}}';
|
||||
var newAccount = '{{{newAccount}}}';
|
||||
var newAccountPass = parseInt('{{{newAccountPass}}}');
|
||||
var emailCheck = ('{{{emailcheck}}}' == 'true');
|
||||
var passRequirements = '{{{passRequirements}}}';
|
||||
|
@ -316,14 +318,14 @@
|
|||
|
||||
validateLogin();
|
||||
validateCreate();
|
||||
if ('{{loginmode}}' != '') { go(parseInt('{{loginmode}}')); } else { go(1); }
|
||||
QV('newAccountDiv', ('{{{newAccount}}}' === '1') || ('{{{newAccount}}}' === 'true')); // If new accounts are not allowed, don't display the new account link.
|
||||
if (loginMode.length != 0) { go(parseInt(loginMode)); } else { go(1); }
|
||||
QV('newAccountDiv', (newAccount === '1') || (newAccount === 'true')); // If new accounts are not allowed, don't display the new account link.
|
||||
if ((passhint != null) && (passhint.length > 0)) { QV('showPassHintLink', true); }
|
||||
QV('newAccountPass', (newAccountPass == 1));
|
||||
QV('resetAccountDiv', (emailCheck == true));
|
||||
QV('hrAccountDiv', (emailCheck == true) || (newAccountPass == 1));
|
||||
|
||||
if ('{{loginmode}}' == '4') {
|
||||
if (loginMode == '4') {
|
||||
try { if (hardwareKeyChallenge.length > 0) { hardwareKeyChallenge = JSON.parse(hardwareKeyChallenge); } else { hardwareKeyChallenge = null; } } catch (ex) { hardwareKeyChallenge = null }
|
||||
if ((hardwareKeyChallenge != null) && (hardwareKeyChallenge.type == 'webAuthn')) {
|
||||
hardwareKeyChallenge.challenge = Uint8Array.from(atob(hardwareKeyChallenge.challenge), function (c) { return c.charCodeAt(0) }).buffer;
|
||||
|
@ -356,7 +358,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
if ('{{loginmode}}' == '5') {
|
||||
if (loginMode == '5') {
|
||||
try { if (hardwareKeyChallenge.length > 0) { hardwareKeyChallenge = JSON.parse(hardwareKeyChallenge); } else { hardwareKeyChallenge = null; } } catch (ex) { hardwareKeyChallenge = null }
|
||||
if ((hardwareKeyChallenge != null) && (hardwareKeyChallenge.type == 'webAuthn')) {
|
||||
hardwareKeyChallenge.challenge = Uint8Array.from(atob(hardwareKeyChallenge.challenge), function (c) { return c.charCodeAt(0) }).buffer;
|
||||
|
|
Loading…
Reference in New Issue