Add converge-wake.service and systemd-sleep hook for wake-from-sleep sync
Build / build (push) Failing after 12m9s
Build / build (push) Failing after 12m9s
Creates a oneshot user service (converge-wake.service) that runs converge --sync after the network is online, and a systemd-sleep hook (/usr/lib/systemd/system-sleep/converge-wake) that triggers the service for each logged-in user on resume. Uses After=network-online.target for proper network timing on NetworkManager/systemd-networkd setups, with a 5-second ExecStartPre delay as a safety net for netctl and other environments where network-online.target may not gate on resume. Updated PKGBUILD and AGENTS.md accordingly.
This commit is contained in:
@@ -20,7 +20,9 @@ test/GitPullSpec.hs # Pull/rebase tests
|
||||
test/GitSafetySpec.hs # Operation-in-progress detection tests
|
||||
SPEC.md # Human-readable specifications
|
||||
converge.example.yaml # Example config file
|
||||
converge.service # systemd unit file
|
||||
converge.service # systemd user service (daemon mode)
|
||||
converge-wake.service # systemd user service (wake-from-sleep sync)
|
||||
src/system-sleep/ # systemd-sleep hook scripts
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
@@ -15,11 +15,15 @@ optdepends=('converge-relay: realtime push notifications via SSE relay server')
|
||||
backup=('etc/converge/config.example.yaml')
|
||||
source=(
|
||||
"converge.service"
|
||||
"converge-wake.service"
|
||||
"converge.example.yaml"
|
||||
"src/system-sleep/converge-wake"
|
||||
)
|
||||
md5sums=(
|
||||
'SKIP'
|
||||
'SKIP'
|
||||
'SKIP'
|
||||
'SKIP'
|
||||
)
|
||||
|
||||
build() {
|
||||
@@ -54,9 +58,15 @@ package() {
|
||||
install -Dm755 "$srcdir/bin/converge" \
|
||||
"$pkgdir/usr/bin/converge"
|
||||
|
||||
# User systemd service
|
||||
# User systemd services
|
||||
install -Dm644 converge.service \
|
||||
"$pkgdir/usr/lib/systemd/user/converge.service"
|
||||
install -Dm644 converge-wake.service \
|
||||
"$pkgdir/usr/lib/systemd/user/converge-wake.service"
|
||||
|
||||
# Sleep hook (runs converge --sync for all logged-in users after resume)
|
||||
install -Dm755 src/system-sleep/converge-wake \
|
||||
"$pkgdir/usr/lib/systemd/system-sleep/converge-wake"
|
||||
|
||||
# Example config
|
||||
install -Dm644 converge.example.yaml \
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
[Unit]
|
||||
Description=Converge - sync repos after waking from sleep
|
||||
Documentation=https://github.com/jbrechtel/converge
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/converge --sync
|
||||
# Small delay as a safety net for environments (e.g. netctl) where
|
||||
# network-online.target may not gate properly on resume, giving the
|
||||
# network stack time to reconnect before converge attempts to pull.
|
||||
ExecStartPre=/bin/sleep 5
|
||||
|
||||
# Allow notify-send to reach the desktop session
|
||||
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%U/bus
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
@@ -0,0 +1,19 @@
|
||||
[Unit]
|
||||
Description=Converge - sync repos after waking from sleep
|
||||
Documentation=https://github.com/jbrechtel/converge
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/converge --sync
|
||||
# Small delay as a safety net for environments (e.g. netctl) where
|
||||
# network-online.target may not gate properly on resume, giving the
|
||||
# network stack time to reconnect before converge attempts to pull.
|
||||
ExecStartPre=/bin/sleep 5
|
||||
|
||||
# Allow notify-send to reach the desktop session
|
||||
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%U/bus
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
# Hook for systemd-sleep: run converge --sync for each logged-in user after resume.
|
||||
# Installed to /usr/lib/systemd/system-sleep/converge-wake.
|
||||
# Called with $1 = "pre" (before sleep) or "post" (after resume).
|
||||
|
||||
if [ "$1" = "post" ]; then
|
||||
# The converge-wake.service has After=network-online.target, so systemd
|
||||
# won't run the actual sync until the network stack is restored. This
|
||||
# hook only needs to request the start.
|
||||
loginctl list-users --no-legend 2>/dev/null | while read uid name rest; do
|
||||
[ "$uid" -ge 1000 ] 2>/dev/null || continue
|
||||
su "$name" -c "XDG_RUNTIME_DIR=/run/user/$uid systemctl --user start converge-wake.service" 2>/dev/null || true
|
||||
done
|
||||
fi
|
||||
Reference in New Issue
Block a user