feat: OpenRC and runit init backends behind an Init interface
Extract init-neutral unit resolution into service/, add initsys.Init with systemd, openrc and runit backends, selected by 'init:' config or autodetect. OpenRC and runit are root only; rootless units run as system services as that user. Add docs and generated examples for all three.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
> *A door you open and close for container units.*
|
||||
|
||||
Unitdore bridges your container runtime (Podman, Docker) and systemd. It discovers running containers and podman-compose stacks, stores them in a config file, and generates + manages systemd `.service` units for each one.
|
||||
Unitdore bridges your container runtime (Podman, Docker) and your init system (systemd, OpenRC, runit). It discovers running containers and podman-compose stacks, stores them in a config file, and generates + manages a service for each one.
|
||||
|
||||
## Install
|
||||
|
||||
@@ -107,6 +107,8 @@ oldthing podman hein no no — container
|
||||
**Location:** `/etc/unitdore/units.yaml`
|
||||
|
||||
```yaml
|
||||
init: "" # optional: systemd | openrc | runit (empty = autodetect)
|
||||
service_dir: "" # optional: runit supervised dir (empty = /var/service or /etc/service)
|
||||
prefix: "" # optional: prepended to all service names, e.g. "prod-"
|
||||
suffix: "" # optional: appended to all service names, e.g. "-svc"
|
||||
users: [hein] # root only: rootless users scanned by syncup
|
||||
@@ -158,6 +160,27 @@ units:
|
||||
enabled: true
|
||||
```
|
||||
|
||||
### Init systems
|
||||
|
||||
Set `init:` in the config, or leave empty to autodetect (`/run/systemd/system` → systemd, `/run/openrc` → openrc, `/etc/runit` → runit, else systemd).
|
||||
|
||||
| | systemd | openrc | runit |
|
||||
|---|---|---|---|
|
||||
| Service file | `/etc/systemd/system/unitdore-<n>.service` | `/etc/init.d/unitdore-<n>` | `/etc/sv/unitdore-<n>/{run,finish}` + symlink in `service_dir` |
|
||||
| Start / stop | `systemctl` | `rc-service` | `sv` |
|
||||
| Enable at boot | `systemctl enable` | `rc-update add … default` | remove `down` file |
|
||||
| Installed state | disabled until enabled | not in runlevel | symlinked with `down` file (no autostart) |
|
||||
| Rootless `user:` | `systemctl --user` unit (needs linger) | system service, `command_user` | system service, `chpst -u` |
|
||||
| Non-root use | yes (own user units) | **root only** | **root only** |
|
||||
| `restart*` | `Restart=on-failure`, `StartLimitBurst` | `supervise-daemon` `respawn_*` (always respawns) | `finish`: on-failure, `RestartSec`; **no retry limit** |
|
||||
| `docker` dependency | `Requires=docker.service` | `need docker` | none |
|
||||
| `oneshot` | `RemainAfterExit` | `start()`/`stop()` functions | run once, then `tail -f /dev/null` |
|
||||
|
||||
- Rootless units on openrc/runit set `HOME` and `XDG_RUNTIME_DIR=/run/user/<uid>` and create that dir if missing.
|
||||
- `command` / `args` use systemd quoting; they are re-quoted for sh on openrc/runit.
|
||||
- No log redirection is generated on openrc; use the runtime's own logs.
|
||||
- `docs/generated-units.md` shows systemd output only.
|
||||
|
||||
### Script / executable units
|
||||
|
||||
Added manually (`unitdore edit`); syncup never creates or disables them.
|
||||
|
||||
Reference in New Issue
Block a user