switch-systemd-unit

a cli tool for switching systemd unit quickly

Usage no npm install needed!

<script type="module">
  import switchSystemdUnit from 'https://cdn.skypack.dev/switch-systemd-unit';
</script>

README

switch-systemd-unit

version

a cli tool for switching systemd unit more quickly

Install

$ npm i -g switch-systemd-unit

Usage

$ switch-unit -h

# Usage: switch-unit
#   -h, --help:     show this
#   -c, --config:   config file for options below, default: "/etc/switch-systemd-unit.json"
#   -t, --template: systemd unit template name, format: "name@.suffix"
#   --dir:          directory for reading unit instance name
#   --extname:      extname of instance files, default: ""

Example

xxxx@.service:

[Unit]
Description=xxxxx
After=network.target

[Service]
Type=simple
User=nobody
ExecStart=start-sth -c /etc/my-config/%i.json

[Install]
WantedBy=multi-user.target

corresponding usage

pass arguments directly:

$ switch-unit --dir /etc/my-config --template xxxx@.service --extname .json

or just use JSON config /path/to/config.json:

{
  "extname": ".json",
  "dir": "/etc/my-config",
  "template": "xxxx@.service"
}
$ switch-unit -c /path/to/config.json

LICENSE

ISC