Files
kernel-automation/server/install.sh
T
patrickandClaude Opus 5.5 07749b01b0 Scaffold kernelwatch: fleet kernel status agent and dashboard
Agent: bash script run hourly by a hardened systemd timer on Debian 12/13
and Ubuntu 24.04. Collects running vs installed kernel (needrestart when
available), pending/security updates via a read-only apt simulation,
reboot-required state and apt list freshness, and POSTs them as JSON.

Server: stdlib-only Python + SQLite (system python3 >= 3.11). Token-bound
ingest API, login-protected dashboard with per-host status
(stale/reboot/update/ok) and history, admin CLI, systemd unit and installer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 10:15:06 -04:00

52 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Install or upgrade the kernelwatch server on Debian 12/13 or Ubuntu 24.04.
#
# sudo ./install.sh
#
# Installs to /opt/kernelwatch, config in /etc/kernelwatch/server.toml (kept
# on upgrade), data in /var/lib/kernelwatch. Then put a TLS reverse proxy in
# front (see README) and create a dashboard user: sudo kernelwatch set-password admin
set -euo pipefail
here=$(cd "$(dirname "$0")" && pwd)
[[ $(id -u) == 0 ]] || { echo "run as root" >&2; exit 1; }
if ! /usr/bin/python3 -c 'import sys; sys.exit(sys.version_info < (3, 11))' 2>/dev/null; then
echo "kernelwatch needs /usr/bin/python3 >= 3.11 (Debian 12+, Ubuntu 24.04)" >&2
exit 1
fi
if ! id kernelwatch >/dev/null 2>&1; then
useradd --system --home-dir /var/lib/kernelwatch --no-create-home \
--shell /usr/sbin/nologin kernelwatch
fi
rm -rf /opt/kernelwatch.new
install -d -m 0755 /opt/kernelwatch.new/kernelwatch
install -m 0755 "$here/kernelwatch-server" /opt/kernelwatch.new/
install -m 0644 "$here"/kernelwatch/*.py /opt/kernelwatch.new/kernelwatch/
rm -rf /opt/kernelwatch.old
[[ -d /opt/kernelwatch ]] && mv /opt/kernelwatch /opt/kernelwatch.old
mv /opt/kernelwatch.new /opt/kernelwatch
rm -rf /opt/kernelwatch.old
install -m 0755 "$here/kernelwatch.sh" /usr/local/bin/kernelwatch
install -d -m 0755 /etc/kernelwatch
if [[ ! -e /etc/kernelwatch/server.toml ]]; then
install -m 0640 -g kernelwatch "$here/server.toml.example" /etc/kernelwatch/server.toml
fi
install -d -m 0750 -o kernelwatch -g kernelwatch /var/lib/kernelwatch
install -m 0644 "$here/kernelwatch.service" /etc/systemd/system/
systemctl daemon-reload
systemctl enable kernelwatch.service
systemctl restart kernelwatch.service
echo
echo "kernelwatch is running on $(grep -E '^listen_' /etc/kernelwatch/server.toml | tr '\n' ' ')"
if [[ -z $(kernelwatch list-users) ]]; then
echo "Create a dashboard login: sudo kernelwatch set-password admin"
fi
echo "Register a host: sudo kernelwatch add-host <name>"