1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-10 05:13:38 +00:00

Fixed freebsd bug with installService()

This commit is contained in:
Bryan Roe
2020-04-14 01:16:22 -07:00
parent e3b8cc4d2c
commit 7a1da84490
2 changed files with 18 additions and 15 deletions

File diff suppressed because one or more lines are too long

View File

@@ -877,7 +877,7 @@ function serviceManager()
{
this.getService = function getService(name)
{
var ret = { name: name};
var ret = { name: name, close: function () { } };
if(require('fs').existsSync('/etc/rc.d/' + name))
{
Object.defineProperty(ret, 'rc', { value: '/etc/rc.d/' + name });
@@ -1697,6 +1697,9 @@ function serviceManager()
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); }
require('fs').copyFileSync(options.servicePath, '/usr/local/mesh_services/' + options.name + '/' + options.target);
var bm = require('fs').statSync(options.servicePath, '/usr/local/mesh_services/' + options.name + '/' + options.target).mode;
bm |= (require('fs').CHMOD_MODES.S_IXUSR | require('fs').CHMOD_MODES.S_IXGRP);
require('fs').chmodSync(options.servicePath, '/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');