feat: order/delay in service files, enable cmd, --all on unit commands
- install/uninstall/start/stop/enable take <name> or --all; *all kept as shortcuts - add enable (enable at boot + start); startall no longer enables - order/delay resolved by config.ResolveOrder and written into systemd, OpenRC and runit service files (After=/sleep), so they apply at boot - install --all stops and disables units before removing their files - update regenerates all installed, enabled units and removes disabled ones - edit creates the config dir; docs and man page updated - tests: fake Init for cmd, ResolveOrder, backend ordering output
This commit is contained in:
@@ -85,27 +85,51 @@ Queries Podman and Docker for running containers, adds new ones to the config, a
|
||||
sudo unitdore edit
|
||||
```
|
||||
|
||||
Opens `/etc/unitdore/units.yaml` in `$EDITOR` (falls back to `vi`).
|
||||
Opens `/etc/unitdore/units.yaml` in `$EDITOR` (falls back to `nvim`, `nano`, `vi`; creates the config dir if missing).
|
||||
|
||||
### Install systemd unit files
|
||||
### Install service files
|
||||
|
||||
```bash
|
||||
sudo unitdore install
|
||||
sudo unitdore install <name>
|
||||
```
|
||||
|
||||
Generates `.service` files for all enabled units and writes them to systemd. Use `--dry-run` to preview without writing.
|
||||
Generates the service file for one enabled unit (error if unknown or disabled). Does not enable or start it.
|
||||
|
||||
```bash
|
||||
sudo unitdore install --dry-run
|
||||
sudo unitdore install <name> --dry-run # preview, write nothing
|
||||
sudo unitdore install --all # all enabled units; installed + disabled ones are stopped and removed
|
||||
sudo unitdore installall # same as install --all
|
||||
```
|
||||
|
||||
### Enable and start units
|
||||
### Start / stop / enable / uninstall
|
||||
|
||||
```bash
|
||||
sudo unitdore active
|
||||
sudo unitdore start <name> # start only
|
||||
sudo unitdore enable <name> # enable at boot + start
|
||||
sudo unitdore stop <name>
|
||||
sudo unitdore uninstall <name> # stop, disable, remove service file
|
||||
```
|
||||
|
||||
Runs `systemctl enable --now` for all installed, enabled units in startup order.
|
||||
Each takes `--all` instead of a name to act on every unit (shortcuts: `startall`, `enableall`, `stopall`, `uninstallall`, `installall`).
|
||||
|
||||
- `start/enable --all`: installed, enabled units in `order` (lowest first); same `order` → parallel
|
||||
- `stop/uninstall --all`: all installed units, reverse `order`, one at a time
|
||||
|
||||
### Order and delay at boot
|
||||
|
||||
`order`/`delay` are written into the generated service files, so they also apply at boot.
|
||||
|
||||
| Backend | `order` | `delay` |
|
||||
|---|---|---|
|
||||
| systemd | `After=` units of the previous group | `ExecStartPre=sleep N`, `TimeoutStartSec=N+90` |
|
||||
| OpenRC | `depend() { after … }` | `start_pre() { sleep N }` |
|
||||
| runit | `sv -w 30 check <prev>` in `run` | `sleep N` in `run` |
|
||||
|
||||
- Previous group = nearest lower `order` among enabled units of the same user
|
||||
- `delay` is the unit's own, ignored in the first group
|
||||
- Changing `order`/`enabled` via `update` regenerates all installed, enabled units
|
||||
- Delay also applies to manual `start` and to restarts
|
||||
- `delay` must be a valid non-negative duration (`5s`, `1m`); an invalid value fails config load
|
||||
|
||||
### Check status
|
||||
|
||||
@@ -139,7 +163,7 @@ units:
|
||||
user: "" # empty = root/system unit
|
||||
command: "" # optional: override ExecStart entirely
|
||||
order: 1 # startup order (lower = earlier)
|
||||
delay: 0s # delay after previous order group
|
||||
delay: 0s # wait before start (own delay, not first group)
|
||||
enabled: true
|
||||
disabled_reason: "" # auto-set by syncup reconciliation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user