Files
kernel-automation/server/install.sh
T
patrickandClaude Opus 5.5 16d647cf9c Support Ubuntu 22.04 (agent and server on Python 3.10)
The server only needed Python 3.11 for tomllib. Fall back to a small
parser for the flat key = value subset the config uses, checked against
tomllib on the shipped example. Relax the installer's version check to
3.10 and list Ubuntu 22.04 as supported for agents and server.

Add status tests using uname -v / package versions captured from real
22.04.5 and 24.04.4 HWE hosts, confirming the Ubuntu build mapping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 10:23:00 -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, 10))' 2>/dev/null; then
echo "kernelwatch needs /usr/bin/python3 >= 3.10 (Debian 12+, Ubuntu 22.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>"