Files
steward/deploy/debian/postinst
T
abrown38andClaude Opus 5.5 3c0808591f Steward 0.1.0 (in development): a DHCPv4 server with a web UI, API and CLI
Subnets served per interface, pools, reservations, options at three
levels, leases in SQLite saved before the ACK, ping and decline conflict
checks, validated changes with history and undo, users and tokens, an
audit log, a Kea importer, a sandboxed systemd unit and Debian packages.
Tested with real udhcpc and dhcpcd clients in Docker (scripts/e2e.sh).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 12:14:07 +01:00

58 lines
2.4 KiB
Bash
Executable File

#!/bin/sh
# Steward: runs after the package's files are in place.
set -e
if [ "$1" = configure ]; then
# The steward system user and Steward's directories: /etc/steward,
# /var/lib/steward and /var/backups/steward.
systemd-sysusers steward.conf
systemd-tmpfiles --create steward.conf || true
# An example configuration on the first install; an existing one is
# never touched.
if [ ! -e /etc/steward/steward.yaml ]; then
/usr/bin/stewardd config --example > /etc/steward/steward.yaml.dpkg-new
chown root:steward /etc/steward/steward.yaml.dpkg-new
chmod 0640 /etc/steward/steward.yaml.dpkg-new
mv /etc/steward/steward.yaml.dpkg-new /etc/steward/steward.yaml
fi
# The daily database backup (steward-backup.timer) is on by default. An
# administrator's 'systemctl disable steward-backup.timer' is remembered
# by deb-systemd-helper and kept across upgrades. Before 'stewardd init'
# the backup skips itself (there is no database yet).
if command -v deb-systemd-helper >/dev/null 2>&1; then
deb-systemd-helper unmask steward-backup.timer >/dev/null || true
if deb-systemd-helper --quiet was-enabled steward-backup.timer; then
deb-systemd-helper enable steward-backup.timer >/dev/null || true
else
deb-systemd-helper update-state steward-backup.timer >/dev/null || true
fi
elif [ -z "$2" ] && [ -d /run/systemd/system ]; then
systemctl enable steward-backup.timer >/dev/null 2>&1 || true
fi
if [ -d /run/systemd/system ]; then
systemctl daemon-reload || true
if systemctl is-enabled --quiet steward-backup.timer 2>/dev/null; then
systemctl start steward-backup.timer || true
fi
# An upgrade restarts a running stewardd (its database is upgraded
# when it starts). A first install starts nothing: Steward needs
# 'stewardd init' first.
if [ -n "$2" ] && systemctl is-active --quiet steward.service; then
systemctl restart steward.service || echo "steward: restarting stewardd failed; see 'journalctl -u steward'" >&2
fi
fi
if [ -z "$2" ]; then
echo "Steward is installed. Next: create the database and start it, as described"
echo "in /usr/share/doc/steward/docs/install.md:"
echo " sudo -u steward stewardd init && sudo systemctl enable --now steward"
echo "Stop any other DHCP server first (Kea, dnsmasq, isc-dhcp-server): only one"
echo "can listen on an interface's port 67. 'steward import kea' brings Kea's setup over."
fi
fi
exit 0