mirror of
https://github.com/Ylianst/MeshAgent
synced 2026-02-08 12:40:05 +00:00
1. Updated installer to support --installPath on most all platforms
2. Updated installer, so if service already exists, and installPath isn't specified, it will try to use the existing path.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -72,6 +72,23 @@ function installService(params)
|
||||
options.parameters.splice(i, 1);
|
||||
options.installInPlace = true;
|
||||
}
|
||||
|
||||
if (global._workingpath != null && global._workingpath != '' && global._workingpath != '/')
|
||||
{
|
||||
for (i = 0; i < options.parameters.length; ++i)
|
||||
{
|
||||
if (options.parameters[i].startsWith('--installPath='))
|
||||
{
|
||||
global._workingpath = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(global._workingpath != null)
|
||||
{
|
||||
options.parameters.push('--installPath="' + global._workingpath + '"');
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < options.parameters.length; ++i)
|
||||
{
|
||||
if(options.parameters[i].startsWith('--installPath='))
|
||||
@@ -454,11 +471,14 @@ function fullInstall(jsonString)
|
||||
console.setDestination(console.Destinations.DISABLED);
|
||||
var parms = JSON.parse(jsonString);
|
||||
var loc = null;
|
||||
|
||||
try
|
||||
{
|
||||
process.stdout.write('...Checking for previous installation');
|
||||
var s = require('service-manager').manager.getService(process.platform == 'win32' ? 'Mesh Agent' : 'meshagent');
|
||||
loc = s.appLocation();
|
||||
|
||||
global._workingpath = s.appWorkingDirectory();
|
||||
s.close();
|
||||
}
|
||||
catch (e)
|
||||
|
||||
@@ -64,7 +64,7 @@ limitations under the License.
|
||||
|
||||
/*****/
|
||||
|
||||
function _install()
|
||||
function _install(parms)
|
||||
{
|
||||
var mstr = require('fs').createWriteStream(process.execPath + '.msh', { flags: 'wb' });
|
||||
mstr.write('MeshName=' + msh.MeshName + '\n');
|
||||
@@ -74,9 +74,13 @@ limitations under the License.
|
||||
mstr.write('MeshServer=' + msh.MeshServer + '\n');
|
||||
mstr.end();
|
||||
|
||||
global._child = require('child_process').execFile(process.execPath,
|
||||
[process.execPath.split('/').pop(), '-fullinstall', '--no-embedded=1', '--copy-msh=1']);
|
||||
if (parms == null) { parms = []; }
|
||||
parms.unshift('--copy-msh=1');
|
||||
parms.unshift('--no-embedded=1');
|
||||
parms.unshift('-fullinstall');
|
||||
parms.unshift(process.execPath.split('/').pop());
|
||||
|
||||
global._child = require('child_process').execFile(process.execPath, parms);
|
||||
global._child.stdout.on('data', function (c) { process.stdout.write(c.toString()); });
|
||||
global._child.stderr.on('data', function (c) { process.stdout.write(c.toString()); });
|
||||
global._child.waitExit();
|
||||
@@ -94,6 +98,7 @@ limitations under the License.
|
||||
var s = null;
|
||||
try { s = require('service-manager').manager.getService('meshagent'); } catch (e) { }
|
||||
var buttons = ['Cancel'];
|
||||
var skip = false;
|
||||
|
||||
if (msh.InstallFlags == null)
|
||||
{
|
||||
@@ -136,56 +141,26 @@ limitations under the License.
|
||||
{
|
||||
if (!require('message-box').kdialog && (require('message-box').zenity == null || (!require('message-box').zenity.extra)))
|
||||
{
|
||||
console.log('\n' + "This installer cannot run on this system.");
|
||||
console.log("Try installing/updating Zenity, and run again." + '\n');
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!require('user-sessions').isRoot()) { console.log('\n' + "This utility requires elevated permissions. Please try again with sudo."); process.exit(); }
|
||||
}
|
||||
|
||||
|
||||
if (!s)
|
||||
{
|
||||
msg = "Agent: " + "NOT INSTALLED" + '\n';
|
||||
} else
|
||||
{
|
||||
msg = "Agent: " + (s.isRunning() ? "RUNNING" : "NOT RUNNING") + '\n';
|
||||
}
|
||||
|
||||
msg += ("Device Group: " + msh.MeshName + '\n');
|
||||
msg += ("Server URL: " + msh.MeshServer + '\n');
|
||||
|
||||
var p = require('message-box').create("MeshCentral Agent Setup", msg, 99999, buttons);
|
||||
p.then(function (v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case "Cancel":
|
||||
process.exit();
|
||||
break;
|
||||
case 'Setup':
|
||||
var d = require('message-box').create("MeshCentral Agent", msg, 99999, ['Update', 'Uninstall', 'Cancel']);
|
||||
d.then(function (v)
|
||||
if (process.argv.includes('-install') || process.argv.includes('-update'))
|
||||
{
|
||||
var p = [];
|
||||
for (var i = 0; i < process.argv.length; ++i)
|
||||
{
|
||||
switch(v)
|
||||
if(process.argv[i].startsWith('--installPath='))
|
||||
{
|
||||
case 'Update':
|
||||
case 'Install':
|
||||
_install();
|
||||
break;
|
||||
case 'Uninstall':
|
||||
_uninstall();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
p.push('--installPath="' + process.argv[i].split('=').pop() + '"');
|
||||
}
|
||||
process.exit();
|
||||
}).catch(function (v) { process.exit(); });
|
||||
break;
|
||||
case "Connect":
|
||||
}
|
||||
_install(p);
|
||||
process.exit();
|
||||
}
|
||||
else if(process.argv.includes('-uninstall'))
|
||||
{
|
||||
_uninstall();
|
||||
process.exit();
|
||||
}
|
||||
else if(process.argv.includes('-connect'))
|
||||
{
|
||||
global._child = require('child_process').execFile(process.execPath,
|
||||
[process.execPath.split('/').pop(), '--no-embedded=1', '--disableUpdate=1',
|
||||
'--MeshName="' + msh.MeshName + '"', '--MeshType="' + msh.MeshType + '"',
|
||||
@@ -198,36 +173,128 @@ limitations under the License.
|
||||
global._child.stderr.on('data', function (c) { });
|
||||
global._child.on('exit', function (code) { process.exit(code); });
|
||||
|
||||
msg = ("Device Group: " + msh.MeshName + '\n');
|
||||
msg += ("Server URL: " + msh.MeshServer + '\n');
|
||||
|
||||
if (process.platform != 'darwin')
|
||||
console.log("\nConnecting to: " + msh.MeshServer);
|
||||
console.log("Device Group: " + msh.MeshName);
|
||||
console.log('\nPress Ctrl-c to exit\n');
|
||||
skip = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('\n' + "The graphical version of this installer cannot run on this system.");
|
||||
console.log("Try installing/updating Zenity, and run again." + '\n');
|
||||
console.log("You can also run the text version from the command line with the following command(s): ");
|
||||
if ((msh.InstallFlags & 1) == 1)
|
||||
{
|
||||
if(!require('message-box').zenity && require('message-box').kdialog)
|
||||
console.log('./' + process.execPath.split('/').pop() + ' -connect');
|
||||
}
|
||||
if ((msh.InstallFlags & 2) == 2)
|
||||
{
|
||||
if (s)
|
||||
{
|
||||
msg += ('\nPress OK to Disconnect');
|
||||
console.log('./' + process.execPath.split('/').pop() + ' -update');
|
||||
console.log('./' + process.execPath.split('/').pop() + ' -uninstall');
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('./' + process.execPath.split('/').pop() + ' -install');
|
||||
console.log('./' + process.execPath.split('/').pop() + ' -install --installPath="/alternate/path"');
|
||||
}
|
||||
}
|
||||
|
||||
var d = require('message-box').create("MeshCentral Agent", msg, 99999, ['Disconnect']);
|
||||
d.then(function (v) { process.exit(); }).catch(function (v) { process.exit(); });
|
||||
break;
|
||||
case "Uninstall":
|
||||
_uninstall();
|
||||
console.log('');
|
||||
process.exit();
|
||||
break;
|
||||
case "Install":
|
||||
case "Update":
|
||||
_install();
|
||||
process.exit();
|
||||
break;
|
||||
default:
|
||||
console.log(v);
|
||||
process.exit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}).catch(function (e)
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log(e);
|
||||
process.exit();
|
||||
});
|
||||
if (!require('user-sessions').isRoot()) { console.log('\n' + "This utility requires elevated permissions. Please try again with sudo."); process.exit(); }
|
||||
}
|
||||
|
||||
|
||||
if (!skip)
|
||||
{
|
||||
if (!s)
|
||||
{
|
||||
msg = "Agent: " + "NOT INSTALLED" + '\n';
|
||||
} else
|
||||
{
|
||||
msg = "Agent: " + (s.isRunning() ? "RUNNING" : "NOT RUNNING") + '\n';
|
||||
}
|
||||
|
||||
msg += ("Device Group: " + msh.MeshName + '\n');
|
||||
msg += ("Server URL: " + msh.MeshServer + '\n');
|
||||
|
||||
var p = require('message-box').create("MeshCentral Agent Setup", msg, 99999, buttons);
|
||||
p.then(function (v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case "Cancel":
|
||||
process.exit();
|
||||
break;
|
||||
case 'Setup':
|
||||
var d = require('message-box').create("MeshCentral Agent", msg, 99999, ['Update', 'Uninstall', 'Cancel']);
|
||||
d.then(function (v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case 'Update':
|
||||
case 'Install':
|
||||
_install();
|
||||
break;
|
||||
case 'Uninstall':
|
||||
_uninstall();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
process.exit();
|
||||
}).catch(function (v) { process.exit(); });
|
||||
break;
|
||||
case "Connect":
|
||||
global._child = require('child_process').execFile(process.execPath,
|
||||
[process.execPath.split('/').pop(), '--no-embedded=1', '--disableUpdate=1',
|
||||
'--MeshName="' + msh.MeshName + '"', '--MeshType="' + msh.MeshType + '"',
|
||||
'--MeshID="' + msh.MeshID + '"',
|
||||
'--ServerID="' + msh.ServerID + '"',
|
||||
'--MeshServer="' + msh.MeshServer + '"',
|
||||
'--AgentCapabilities="0x00000020"']);
|
||||
|
||||
global._child.stdout.on('data', function (c) { });
|
||||
global._child.stderr.on('data', function (c) { });
|
||||
global._child.on('exit', function (code) { process.exit(code); });
|
||||
|
||||
msg = ("Device Group: " + msh.MeshName + '\n');
|
||||
msg += ("Server URL: " + msh.MeshServer + '\n');
|
||||
|
||||
if (process.platform != 'darwin')
|
||||
{
|
||||
if (!require('message-box').zenity && require('message-box').kdialog)
|
||||
{
|
||||
msg += ('\nPress OK to Disconnect');
|
||||
}
|
||||
}
|
||||
|
||||
var d = require('message-box').create("MeshCentral Agent", msg, 99999, ['Disconnect']);
|
||||
d.then(function (v) { process.exit(); }).catch(function (v) { process.exit(); });
|
||||
break;
|
||||
case "Uninstall":
|
||||
_uninstall();
|
||||
process.exit();
|
||||
break;
|
||||
case "Install":
|
||||
case "Update":
|
||||
_install();
|
||||
process.exit();
|
||||
break;
|
||||
default:
|
||||
console.log(v);
|
||||
process.exit();
|
||||
break;
|
||||
}
|
||||
}).catch(function (e)
|
||||
{
|
||||
console.log(e);
|
||||
process.exit();
|
||||
});
|
||||
}
|
||||
@@ -1979,20 +1979,31 @@ function serviceManager()
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (options.installPath == null) { options.installPath = '/usr/local/mesh_services/' + options.name + '/'; }
|
||||
prepareFolders(options.installPath);
|
||||
|
||||
if (options.binary)
|
||||
{
|
||||
require('fs').writeFileSync(options.installPath + options.target, options.binary);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (options.servicePath != (options.installPath + options.target))
|
||||
{
|
||||
require('fs').copyFileSync(options.servicePath, options.installPath + options.target);
|
||||
}
|
||||
}
|
||||
|
||||
var m = require('fs').statSync(options.installPath + options.target).mode;
|
||||
m |= (require('fs').CHMOD_MODES.S_IXUSR | require('fs').CHMOD_MODES.S_IXGRP | require('fs').CHMOD_MODES.S_IXOTH);
|
||||
require('fs').chmodSync(options.installPath + options.target, m);
|
||||
}
|
||||
if (process.platform == 'freebsd')
|
||||
{
|
||||
if (!this.isAdmin()) { console.log('Installing a Service requires root'); throw ('Installing as Service, requires root'); }
|
||||
var parameters = options.parameters ? options.parameters.join(' ') : '';
|
||||
if (!require('fs').existsSync('/usr/local/mesh_services')) { require('fs').mkdirSync('/usr/local/mesh_services'); }
|
||||
if (!require('fs').existsSync('/usr/local/mesh_services/' + options.name)) { require('fs').mkdirSync('/usr/local/mesh_services/' + options.name); }
|
||||
|
||||
if (options.servicePath != '/usr/local/mesh_services/' + options.name + '/' + options.target)
|
||||
{
|
||||
require('fs').copyFileSync(options.servicePath, '/usr/local/mesh_services/' + options.name + '/' + options.target);
|
||||
}
|
||||
var bm = require('fs').statSync('/usr/local/mesh_services/' + options.name + '/' + options.target).mode;
|
||||
bm |= (require('fs').CHMOD_MODES.S_IXUSR | require('fs').CHMOD_MODES.S_IXGRP | require('fs').CHMOD_MODES.S_IXOTH);
|
||||
require('fs').chmodSync('/usr/local/mesh_services/' + options.name + '/' + options.target, bm);
|
||||
|
||||
var rc = require('fs').createWriteStream('/usr/local/etc/rc.d/' + options.name, { flags: 'wb' });
|
||||
rc.write('#!/bin/sh\n');
|
||||
@@ -2004,9 +2015,11 @@ function serviceManager()
|
||||
rc.write('desc="' + (options.description ? options.description : 'MeshCentral Agent') + '"\n');
|
||||
rc.write('rcvar=${name}_enable\n');
|
||||
rc.write('pidfile="/var/run/' + options.name + '.pid"\n');
|
||||
rc.write(options.name + '_chdir="/usr/local/mesh_services/' + options.name + '"\n');
|
||||
rc.write(options.name + '_chdir="' + options.installPath + '"\n');
|
||||
|
||||
rc.write('command="/usr/sbin/daemon"\n');
|
||||
rc.write('command_args="-P ${pidfile} ' + ((options.failureRestart == null || options.failureRestart > 0)?'-r':'') + ' -f /usr/local/mesh_services/' + options.name + '/' + options.target + ' ' + parameters + '"\n');
|
||||
rc.write('command_args="-P ${pidfile} ' + ((options.failureRestart == null || options.failureRestart > 0) ? '-r' : '') + ' -f ' + options.installPath + options.target + ' ' + parameters + '"\n');
|
||||
|
||||
rc.write('\n');
|
||||
rc.write('load_rc_config $name\n');
|
||||
rc.write(': ${' + options.name + '_enable="' + ((options.startType == 'AUTO_START' || options.startType == 'BOOT_START')?'YES':'NO') + '"}\n');
|
||||
@@ -2025,17 +2038,6 @@ function serviceManager()
|
||||
switch (options.servicePlatform)
|
||||
{
|
||||
case 'procd':
|
||||
if (options.installPath == null) { options.installPath = '/usr/local/mesh_services/' + options.name + '/'; }
|
||||
prepareFolders(options.installPath);
|
||||
if (options.servicePath != (options.installPath + options.target))
|
||||
{
|
||||
require('fs').copyFileSync(options.servicePath, options.installPath + options.target);
|
||||
}
|
||||
|
||||
var m = require('fs').statSync(options.installPath + options.target).mode;
|
||||
m |= (require('fs').CHMOD_MODES.S_IXUSR | require('fs').CHMOD_MODES.S_IXGRP | require('fs').CHMOD_MODES.S_IXOTH);
|
||||
require('fs').chmodSync(options.installPath + options.target, m);
|
||||
|
||||
var conf = require('fs').createWriteStream('/etc/init.d/' + options.name, { flags: 'wb' });
|
||||
conf.write('#!/bin/sh /etc/rc.common\n');
|
||||
conf.write('USE_PROCD=1\n');
|
||||
@@ -2083,20 +2085,6 @@ function serviceManager()
|
||||
|
||||
break;
|
||||
case 'init':
|
||||
if (!require('fs').existsSync('/usr/local/mesh_services/')) { require('fs').mkdirSync('/usr/local/mesh_services'); }
|
||||
if (!require('fs').existsSync('/usr/local/mesh_services/' + options.name)) { require('fs').mkdirSync('/usr/local/mesh_services/' + options.name); }
|
||||
|
||||
if (options.servicePath != '/usr/local/mesh_services/' + options.name + '/' + options.target)
|
||||
{
|
||||
require('fs').copyFileSync(options.servicePath, '/usr/local/mesh_services/' + options.name + '/' + options.target);
|
||||
}
|
||||
console.log('copying ' + options.servicePath);
|
||||
|
||||
var m = require('fs').statSync('/usr/local/mesh_services/' + options.name + '/' + options.target).mode;
|
||||
m |= (require('fs').CHMOD_MODES.S_IXUSR | require('fs').CHMOD_MODES.S_IXGRP | require('fs').CHMOD_MODES.S_IXOTH);
|
||||
|
||||
require('fs').chmodSync('/usr/local/mesh_services/' + options.name + '/' + options.target, m);
|
||||
|
||||
if (options.failureRestart == null || options.failureRestart > 0)
|
||||
{
|
||||
// Crash Restart is enabled, but it isn't inherently supported by INIT, so we must fake it with JS
|
||||
@@ -2128,19 +2116,6 @@ function serviceManager()
|
||||
}
|
||||
break;
|
||||
case 'upstart':
|
||||
if (!require('fs').existsSync('/usr/local/mesh_services/')) { require('fs').mkdirSync('/usr/local/mesh_services'); }
|
||||
if (!require('fs').existsSync('/usr/local/mesh_services/' + options.name)) { require('fs').mkdirSync('/usr/local/mesh_services/' + options.name); }
|
||||
|
||||
if (options.servicePath != '/usr/local/mesh_services/' + options.name + '/' + options.target)
|
||||
{
|
||||
require('fs').copyFileSync(options.servicePath, '/usr/local/mesh_services/' + options.name + '/' + options.target);
|
||||
}
|
||||
console.log('copying ' + options.servicePath);
|
||||
|
||||
var m = require('fs').statSync('/usr/local/mesh_services/' + options.name + '/' + options.target).mode;
|
||||
m |= (require('fs').CHMOD_MODES.S_IXUSR | require('fs').CHMOD_MODES.S_IXGRP | require('fs').CHMOD_MODES.S_IXOTH);
|
||||
require('fs').chmodSync('/usr/local/mesh_services/' + options.name + '/' + options.target, m);
|
||||
|
||||
conf = require('fs').createWriteStream('/etc/init/' + options.name + '.conf', { flags: 'wb' });
|
||||
switch (options.startType)
|
||||
{
|
||||
@@ -2157,26 +2132,12 @@ function serviceManager()
|
||||
{
|
||||
conf.write('respawn\n\n');
|
||||
}
|
||||
conf.write('chdir /usr/local/mesh_services/' + options.name + '\n');
|
||||
conf.write('exec /usr/local/mesh_services/' + options.name + '/' + options.target + ' ' + parameters + '\n\n');
|
||||
conf.write('chdir ' + options.installPath + '\n');
|
||||
conf.write('exec ' + options.installPath + options.target + ' ' + parameters + '\n\n');
|
||||
conf.end();
|
||||
break;
|
||||
case 'systemd':
|
||||
var serviceDescription = options.description ? options.description : 'MeshCentral Agent';
|
||||
|
||||
if (!require('fs').existsSync('/usr/local/mesh_services/')) { require('fs').mkdirSync('/usr/local/mesh_services'); }
|
||||
if (!require('fs').existsSync('/usr/local/mesh_services/' + options.name)) { require('fs').mkdirSync('/usr/local/mesh_services/' + options.name); }
|
||||
|
||||
if (options.servicePath != '/usr/local/mesh_services/' + options.name + '/' + options.target)
|
||||
{
|
||||
console.log('copying ' + options.servicePath);
|
||||
require('fs').copyFileSync(options.servicePath, '/usr/local/mesh_services/' + options.name + '/' + options.target);
|
||||
}
|
||||
|
||||
var m = require('fs').statSync('/usr/local/mesh_services/' + options.name + '/' + options.target).mode;
|
||||
m |= (require('fs').CHMOD_MODES.S_IXUSR | require('fs').CHMOD_MODES.S_IXGRP | require('fs').CHMOD_MODES.S_IXOTH);
|
||||
require('fs').chmodSync('/usr/local/mesh_services/' + options.name + '/' + options.target, m);
|
||||
|
||||
if (require('fs').existsSync('/lib/systemd/system'))
|
||||
{
|
||||
conf = require('fs').createWriteStream('/lib/systemd/system/' + options.name + '.service', { flags: 'wb' });
|
||||
@@ -2192,8 +2153,8 @@ function serviceManager()
|
||||
|
||||
conf.write('[Unit]\nDescription=' + serviceDescription + '\n');
|
||||
conf.write('[Service]\n');
|
||||
conf.write('WorkingDirectory=/usr/local/mesh_services/' + options.name + '\n');
|
||||
conf.write('ExecStart=/usr/local/mesh_services/' + options.name + '/' + options.target + ' ' + parameters + '\n');
|
||||
conf.write('WorkingDirectory=' + options.installPath + '\n');
|
||||
conf.write('ExecStart=' + options.installPath + options.target + ' ' + parameters + '\n');
|
||||
conf.write('StandardOutput=null\n');
|
||||
if (options.failureRestart == null || options.failureRestart > 0)
|
||||
{
|
||||
@@ -2282,7 +2243,7 @@ function serviceManager()
|
||||
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.target + '</string>\n');
|
||||
params += (' <string>' + options.installPath + options.target + '</string>\n');
|
||||
if(options.parameters)
|
||||
{
|
||||
for(var itm in options.parameters)
|
||||
@@ -2300,7 +2261,7 @@ function serviceManager()
|
||||
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 += (' <string>' + options.installPath + '</string>\n');
|
||||
plist += (stdoutpath + '\n');
|
||||
plist += ' <key>RunAtLoad</key>\n';
|
||||
plist += (autoStart + '\n');
|
||||
@@ -2324,31 +2285,6 @@ function serviceManager()
|
||||
|
||||
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.target, options.binary);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (options.servicePath != '/usr/local/mesh_services/' + options.name + '/' + options.target)
|
||||
{
|
||||
require('fs').copyFileSync(options.servicePath, '/usr/local/mesh_services/' + options.name + '/' + options.target);
|
||||
}
|
||||
}
|
||||
require('fs').writeFileSync('/Library/LaunchDaemons/' + options.name + '.plist', plist);
|
||||
var m = require('fs').statSync('/usr/local/mesh_services/' + options.name + '/' + options.target).mode;
|
||||
m |= (require('fs').CHMOD_MODES.S_IXUSR | require('fs').CHMOD_MODES.S_IXGRP | require('fs').CHMOD_MODES.S_IXOTH);
|
||||
require('fs').chmodSync('/usr/local/mesh_services/' + options.name + '/' + options.target, m);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ('Service: ' + options.name + ' already exists');
|
||||
}
|
||||
}
|
||||
|
||||
if (options.files)
|
||||
@@ -2462,6 +2398,7 @@ function serviceManager()
|
||||
if (typeof (name) == 'object') { name = name.name; }
|
||||
var service = this.getService(name);
|
||||
var servicePath = service.appLocation();
|
||||
var workingPath = service.appWorkingDirectory();
|
||||
|
||||
if (process.platform == 'win32')
|
||||
{
|
||||
@@ -2635,7 +2572,7 @@ function serviceManager()
|
||||
|
||||
try
|
||||
{
|
||||
require('fs').rmdirSync('/usr/local/mesh_services/' + name);
|
||||
require('fs').rmdirSync(workingPath);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
@@ -2651,7 +2588,7 @@ function serviceManager()
|
||||
require('fs').unlinkSync(service.rc);
|
||||
try
|
||||
{
|
||||
require('fs').rmdirSync('/usr/local/mesh_services/' + name);
|
||||
require('fs').rmdirSync(workingPath);
|
||||
}
|
||||
catch (e)
|
||||
{ }
|
||||
|
||||
Reference in New Issue
Block a user