2.1.5 • Published 10 years ago

@mh-cbon/systemd-simple-api v2.1.5

Weekly downloads
-
License
MIT
Repository
-
Last release
10 years ago

systemd-simple-api

Simple api for node to interface with systemd bin.

Install

npm i @mh-cbon/systemd-simple-api --save

Usage

var SystemdSimpleApi = require('@mh-cbon/systemd-simple-api');
var sds = new SystemdSimpleApi(/* version */);

// enable sudo
sds.enableElevation(''); // will now read the password from yasudo env variable
sds.enableElevation('the password'); // will now use 'the password'
sds.enableElevation(false); // will disable use of sudo

// systemctl --user -t service --all
sds.list(opts={user: true, t: 'service', all: true}, function (err, items) {
  console.log(items);
})

// systemctl -t timers
sds.list(opts={t: 'timers'}, function (err, items) {
  console.log(items);
})

// systemctl list-unit-files --user
sds.listUnitFiles(opts={user: true}, function (err, items) {
  console.log(items);
})

// systemctl show serviceId --user
sds.describe('serviceId', opts={user: true}, function (err, info) {
  console.log(info);
})

// systemctl start serviceId --user
sds.start('serviceId', opts={user: true}, function (err) {
  console.log(err);
})

// systemctl stop serviceId --user
sds.stop('serviceId', opts={user: true}, function (err) {
  console.log(err);
})

// systemctl reload serviceId --user
sds.reload(opts={user: true}, function (err) {
  console.log(err);
})

// systemctl reload-or-restart serviceId --user
sds.reloadOrRestart(opts={user: true}, function (err) {
  console.log(err);
})

// systemctl daemon-reload
sds.refresh(function () {
  console.log('systemd is refreshed')
})

Install a service

// per user
var service = {
  install:{},
  unit: {
    Description: "your service"
  },
  service: {
    ExecStart: '/bin/sh ...'
  }
}
sds.install({user: true, id: 'fake', properties: service}, done)

// system wide
var service = {
  install:{},
  unit: {
    Description: "your service"
  },
  service: {
    ExecStart: '/bin/sh ...'
  }
}
sds.install({user: !true, id: 'fake', properties: service}, done)


// later...
sds.uninstall({user: !true, id: 'fake', properties: service}, done)

Run the tests

  • install vagrant
  • run npm run test-fedora

Read more

2.1.5

10 years ago

2.1.4

10 years ago

2.1.3

10 years ago

2.1.2

10 years ago

2.1.1

10 years ago

2.1.0

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.0.2

10 years ago