Skip to content

Commit caecb64

Browse files
committed
systemd: Add bootc-status-updated.{path,target} units
This adds a new systemd path unit which activates on bootc status changing, and in turn triggers a new systemd target. This allows adding arbitrary new systemd services with `WantedBy = bootc-status-updated.target` that will be activated each time the bootc status is updated. Signed-off-by: John Eckersberg <[email protected]>
1 parent 93079bb commit caecb64

File tree

6 files changed

+59
-1
lines changed

6 files changed

+59
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ install:
2424
install -D -m 0644 -t $(DESTDIR)$(prefix)/share/man/man8 $$d/*.8; \
2525
fi; \
2626
done
27-
install -D -m 0644 -t $(DESTDIR)/$(prefix)/lib/systemd/system systemd/*.service systemd/*.timer
27+
install -D -m 0644 -t $(DESTDIR)/$(prefix)/lib/systemd/system systemd/*.service systemd/*.timer systemd/*.path systemd/*.target
2828

2929
# Run this to also take over the functionality of `ostree container` for example.
3030
# Only needed for OS/distros that have callers invoking `ostree container` and not bootc.

docs/src/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
- [`man bootc-rollback`](man/bootc-rollback.md)
2929
- [`man bootc-usr-overlay`](man/bootc-usr-overlay.md)
3030
- [`man bootc-fetch-apply-updates.service`](man-md/bootc-fetch-apply-updates.service.md)
31+
- [`man bootc-status-updated.path`](man-md/bootc-status-updated.path.md)
32+
- [`man bootc-status-updated.target`](man-md/bootc-status-updated.target.md)
3133
- [Controlling bootc via API](bootc-via-api.md)
3234

3335
# Using `bootc install`
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
% bootc-status-updated.path(8)
2+
3+
# NAME
4+
5+
bootc-status-updated.path
6+
7+
# DESCRIPTION
8+
9+
This unit watches the `bootc` root directory (/ostree/bootc) for
10+
modification, and triggers the companion `bootc-status-updated.target`
11+
systemd unit.
12+
13+
The `bootc` program updates the mtime on its root directory when the
14+
contents of `bootc status` changes as a result of an
15+
update/upgrade/edit/switch/rollback operation.
16+
17+
# SEE ALSO
18+
19+
**bootc**(1), **bootc-status-updated.target**(8)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
% bootc-status-updated.target(8)
2+
3+
# NAME
4+
5+
bootc-status-updated.target
6+
7+
# DESCRIPTION
8+
9+
This unit is triggered by the companion `bootc-status-updated.path`
10+
systemd unit. This target is intended to enable users to add custom
11+
services to trigger as a result of `bootc status` changing.
12+
13+
Add the following to your unit configuration to active it when `bootc
14+
status` changes:
15+
16+
```
17+
[Install]
18+
WantedBy=bootc-status-updated.target
19+
```
20+
21+
# SEE ALSO
22+
23+
**bootc**(1), **bootc-status-updated.path**(8)

systemd/bootc-status-updated.path

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Unit]
2+
Description=Monitor bootc for status changes
3+
Documentation=man:bootc-status-updated.path(8)
4+
5+
[Path]
6+
PathChanged=/ostree/bootc
7+
Unit=bootc-status-updated.target
8+
9+
[Install]
10+
WantedBy=multi-user.target

systemd/bootc-status-updated.target

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[Unit]
2+
Description=Target for bootc status changes
3+
Documentation=man:bootc-status-updated.target(8)
4+
StopWhenUnneeded=true

0 commit comments

Comments
 (0)