Deliver end-to-end native monitoring path under runit with existing CLI/TUI controls and truthful status, preserving systemd behavior. Changes: - Add init system abstraction layer (src/fenris/init_system.py) that detects systemd vs runit and provides unified interface for timer control, on-demand collection, and service state queries - Create runit service files (units/runit/) with completion-relative 5-minute cadence, 2-minute boot delay, bounded execution (90s), no catch-up, and serialized runs via flock - Update monitor.py to use abstraction layer instead of direct systemctl - Update status.py to use abstraction layer for service state queries - Update all packaging scripts (deb, rpm) for init-system-aware setup - Update Makefile to install runit service files alongside systemd units - Add 46 tests for init system abstraction layer Spec: ADR 0008, §8.4, §8.5, §8.6, §8.7, §8.8 Closes #84 Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
34 lines
1.0 KiB
Bash
Executable File
34 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
# prerm — deb pre-removal (spec §7).
|
|
#
|
|
# dpkg calls: prerm remove (package being removed)
|
|
# prerm upgrade (old version about to be replaced)
|
|
set -eu
|
|
|
|
# Detect init system
|
|
if [ -d /run/systemd/system ] || [ "$(cat /proc/1/comm 2>/dev/null)" = "systemd" ]; then
|
|
INIT_SYSTEM="systemd"
|
|
else
|
|
INIT_SYSTEM="runit"
|
|
fi
|
|
|
|
case "${1:-}" in
|
|
remove)
|
|
# Sanctioned disable — close monitoring period (spec §7)
|
|
if [ -x /usr/libexec/fenris/fenris-monitor ]; then
|
|
/usr/libexec/fenris/fenris-monitor disable --now 2>/dev/null || true
|
|
fi
|
|
if [ "${INIT_SYSTEM}" = "systemd" ]; then
|
|
systemctl stop fenris-collect.timer 2>/dev/null || true
|
|
systemctl disable fenris-collect.timer 2>/dev/null || true
|
|
else
|
|
# runit: remove the service symlink
|
|
rm -f /var/service/fenris-collect
|
|
touch /etc/sv/fenris-collect/down 2>/dev/null || true
|
|
fi
|
|
;;
|
|
upgrade)
|
|
# Never interrupt monitoring on upgrade
|
|
;;
|
|
esac
|