This is a but.sh template for creating a systemd unit file (.automount, .device, .mount, .path, .scope, .service, .slice, .socket, .swap, .timer, ...)
This, of course, requires but.sh
The template itself requires only bash and gnu-coreutils.
The valid section names are:
- Automount
- Install
- Mount
- Path
- Scope
- Service
- Slice
- Socket
- Swap
- Timer
- Unit
Variables are named like <section_name_allcaps>_<option_name>
, where the option name is also all-caps and words separated by underscores. (Example: SERVICE_GUESS_MAIN_PID
would match GuessMainPID
in the [Service]
section.)
If any variables are defined in a given section, the section is created; they are defined in the alphabetical order.
All of the .env files in this gist are examples for unit files of the stated type.
wget https://gist.github.com/nealian/4219ce02189e3abaad3c66dcaa1b2c3b/raw/systemd-unit.buttemplate{,.src}
but.sh systemd-unit.buttemplate -c systemd-unit.buttemplate.src -c unit.env -o /usr/lib/systemd/system/unit.service