diff --git a/README.md b/README.md index 250251c..f6c1899 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Systemd.js +![Publish](https://github.com/systemd-js/systemd/actions/workflows/publish.yaml/badge.svg) + Collection of packages useful when interfacing with systemd. ## @systemd-js/conf @@ -19,7 +21,8 @@ yarn add @systemd-js/conf Parse systemd ini file into object. -Note: Ini parser is not fully implemented, lacks support for escaping and quoting. +Note: Ini parser is not fully implemented, lacks support for escaping and +quoting. ```ts import {INI} from "@systemd-js/conf"; @@ -64,7 +67,6 @@ const ini = INI.fromString(unit).toObject(); User: "root", }, }; - ``` Create service unit for ini string and modify service user definition. @@ -88,12 +90,12 @@ PrivateTmp=yes User=root `; -const ini = INI.fromString(unit) -const service = Service.fromINI(ini) +const ini = INI.fromString(unit); +const service = Service.fromINI(ini); service .getServiceSection() - .setUser("test") + .setUser("test"); service.toINIString(); ``` @@ -101,33 +103,33 @@ service.toINIString(); Create service unit using fluent builder ```ts -import {Service} from "@systemd-js/config"; +import { Service } from "@systemd-js/config"; const service = new Service(); service .getUnitSection() - .setDescription("This is a example unit") + .setDescription("This is a example unit"); service .getInstallSection() - .setWantedBy("multi-user.target") - + .setWantedBy("multi-user.target"); + service - .getServiceSection() - .setType("simple") - .setWorkingDirectory("/tmp") - .setRestart("always") - .setExecStartPre("/usr/bin/echo 'Before'") - .setExecStart("/usr/bin/echo 'Hello World'") - .setExecStartPost("/usr/bin/echo 'After'") + .getServiceSection() + .setType("simple") + .setWorkingDirectory("/tmp") + .setRestart("always") + .setExecStartPre("/usr/bin/echo 'Before'") + .setExecStart("/usr/bin/echo 'Hello World'") + .setExecStartPost("/usr/bin/echo 'After'"); ``` Create timer unit using fluent builder ```ts -import {Timer} from "@systemd-js/config"; -const timer = new Timer() +import { Timer } from "@systemd-js/config"; +const timer = new Timer(); timer .getUnitSection() @@ -136,7 +138,7 @@ timer timer .getInstallSection() - .setWantedBy("multi-user.target"); + .setWantedBy("multi-user.target"); timer .getTimerSection() @@ -146,8 +148,8 @@ timer ## @systemd-js/ctl -Control over units. Interface to systemctl. -At the moment this lack proper error handling. +Control over units. Interface to systemctl. At the moment this lack proper error +handling. ### Installation @@ -160,57 +162,54 @@ yarn add @systemd-js/ctl State manipulation of existing service. ```ts -import {Ctl} from "@systemd-js/ctl"; - -const ctl = new Ctl("test.service") +import { Ctl } from "@systemd-js/ctl"; -ctl.disable() -ctl.enable() -ctl.stop() -ctl.start() -ctl.restart() +const ctl = new Ctl("test.service"); +ctl.disable(); +ctl.enable(); +ctl.stop(); +ctl.start(); +ctl.restart(); ``` Creation of new service "example.service" ```ts -import {Service} from "@systemd-js/config"; -import {Ctl} from "@systemd-js/ctl"; +import { Service } from "@systemd-js/config"; +import { Ctl } from "@systemd-js/ctl"; const service = new Service(); service .getUnitSection() - .setDescription("This is a example unit") + .setDescription("This is a example unit"); service .getInstallSection() - .setWantedBy("multi-user.target") - -service - .getServiceSection() - .setType("simple") - .setExecStart("/usr/bin/echo 'Hello World'") + .setWantedBy("multi-user.target"); -const ctl = new Ctl("example", service) +service + .getServiceSection() + .setType("simple") + .setExecStart("/usr/bin/echo 'Hello World'"); -ctl.create() -ctl.enable() -ctl.start() +const ctl = new Ctl("example", service); +ctl.create(); +ctl.enable(); +ctl.start(); ``` In addition to `Ctl` class, package expose functions to call systemctl directly. ```ts -import {restart, start, stop} from "@systemd-js/ctl"; - -stop("example.service") -start("example.service") -enable("example.service") -disable("example.service") -reload("example.service") -restart("example.service") - +import { restart, start, stop } from "@systemd-js/ctl"; + +stop("example.service"); +start("example.service"); +enable("example.service"); +disable("example.service"); +reload("example.service"); +restart("example.service"); ```