Improve systemd documentation
This commit is contained in:
parent
381800d263
commit
7507eb84ed
@ -11,6 +11,7 @@
|
|||||||
- [Recipes](./recipes/index.md)
|
- [Recipes](./recipes/index.md)
|
||||||
- [Declare](./recipes/declare.md)
|
- [Declare](./recipes/declare.md)
|
||||||
- [Operating System Recipes](./recipes/os/index.md)
|
- [Operating System Recipes](./recipes/os/index.md)
|
||||||
|
- [Systemd](./recipes/os/systemd.md)
|
||||||
- [Users](./recipes/os/users.md)
|
- [Users](./recipes/os/users.md)
|
||||||
- [Filesystem Recipes](./recipes/filesystem/index.md)
|
- [Filesystem Recipes](./recipes/filesystem/index.md)
|
||||||
- [Database Recipes](./recipes/database/index.md)
|
- [Database Recipes](./recipes/database/index.md)
|
||||||
|
@ -7,9 +7,10 @@ This Scone module allows declaring units, enabling them, and marking them to be
|
|||||||
| Recipe | Needs | Provides |
|
| Recipe | Needs | Provides |
|
||||||
| -----: | ----- | -------- |
|
| -----: | ----- | -------- |
|
||||||
| [`systemd`](#systemd) | `file`? | |
|
| [`systemd`](#systemd) | `file`? | |
|
||||||
|
| [`systemd-timer`](#systemd-timer) | | |
|
||||||
|
|
||||||
|
|
||||||
## `systemd`: Systemd unit
|
## `systemd`
|
||||||
|
|
||||||
Declares and optionally enables and/or starts a systemd unit.
|
Declares and optionally enables and/or starts a systemd unit.
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ Declares and optionally enables and/or starts a systemd unit.
|
|||||||
| Argument | Accepted Values | Default | Description |
|
| Argument | Accepted Values | Default | Description |
|
||||||
| -------: | --------------- | ------- | ----------- |
|
| -------: | --------------- | ------- | ----------- |
|
||||||
| unit | any systemd unit name string | *required* | Name of the Systemd unit. If no extension is provided, `.service` will be inferred. |
|
| unit | any systemd unit name string | *required* | Name of the Systemd unit. If no extension is provided, `.service` will be inferred. |
|
||||||
| at | a path | *semi-optional* | If specified, the path to where the . |
|
| at | a path | *semi-optional* | If specified, the path to where the unit file already exists. |
|
||||||
| already_installed | true, false | false | If true, no path is needed, as it will be assumed that the unit is already available. |
|
| already_installed | true, false | false | If true, no path is needed, as it will be assumed that the unit is already available. |
|
||||||
| enabled | true, false | *optional* | If true, the unit will be enabled ('installed'). |
|
| enabled | true, false | *optional* | If true, the unit will be enabled ('installed'). |
|
||||||
| started | true, false | *optional* | If true, the unit will be started. |
|
| started | true, false | *optional* | If true, the unit will be started. |
|
||||||
@ -37,3 +38,51 @@ at = "/etc/systemd/system/gitea.service"
|
|||||||
enabled = true
|
enabled = true
|
||||||
started = true
|
started = true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## `systemd-timer`
|
||||||
|
|
||||||
|
Declares and starts a Systemd Timer (along with a simple service for it to trigger). This is a useful alternative to cronjobs.
|
||||||
|
|
||||||
|
**Note:** probably must be run as the `root` user.
|
||||||
|
|
||||||
|
**Preconditions:** The `cd` path must be provided.
|
||||||
|
|
||||||
|
**Postconditions:** `{unit}.service` and `{unit}.timer` will exist as Systemd units. `{unit}.timer` will be configured to trigger `{unit}.service` and will be started.
|
||||||
|
|
||||||
|
| Argument | Accepted Values | Default | Description |
|
||||||
|
| -------: | --------------- | ------- | ----------- |
|
||||||
|
| user | string | *required* | Name of the user that will run the executable in the systemd service. |
|
||||||
|
| group | string | same as `user` | Name of the group that will run the executable in the systemd service. |
|
||||||
|
| unit | any systemd unit name string | *required* | Name of the Systemd units, **without** extension. |
|
||||||
|
| description | string | *required* | `[Unit] Description=` string for systemd. |
|
||||||
|
| cd | path | *required* | Working directory for the executable |
|
||||||
|
| command | string | *required* | Executable for the service to start. |
|
||||||
|
| calendar | string or list of strings | *required* | List of Systemd `OnCalendar=` times to trigger this timer at. |
|
||||||
|
| persistent | true, false | false | If true, the timer will trigger immediately upon activation if it missed the previous trigger time. |
|
||||||
|
| enabled | true, false | true | If true, the timer will be enabled and started. |
|
||||||
|
| environment | dict of string to string | *optional* | If specified, these environment variables will be provided to the command. |
|
||||||
|
|
||||||
|
|
||||||
|
### Systemd `OnCalendar` syntax
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
* `Fri *-*-* 10:00:00`: every Friday at 10h00
|
||||||
|
* `*-*-1 09:00:00`: every 1st of the month at 09h00
|
||||||
|
* `Wed *-*-1..7 12:00:00`: the first Wednesday of every month at noon
|
||||||
|
* `*-11-* 06,09:00:00`: every day of November at 06h00 and 09h00
|
||||||
|
|
||||||
|
You can use `systemd-analyze calendar '*-*-* *:*:*'` (for example) to test an `OnCalendar` expression.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```scoml
|
||||||
|
[[systemd-timer]] Install timer to renew certificates every day at 04h00
|
||||||
|
user = radm
|
||||||
|
unit = "radm_renew"
|
||||||
|
description = "Renews, issues and deploys TLS certificates"
|
||||||
|
cd = "/home/radm/rei-acme-dns"
|
||||||
|
command = "/home/radm/rei-acme-dns/radm.sh --contact 'mailto:${radm.contact_email}'"
|
||||||
|
calendar = "*-*-* 04:00:00"
|
||||||
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user