Optionally refresh apt package lists before each report
CI / tests (Python 3.10) (pull_request) Successful in 15s
CI / tests (Python 3.11) (pull_request) Successful in 15s
CI / tests (Python 3.12) (pull_request) Successful in 15s
CI / tests (Python 3.13) (pull_request) Successful in 15s
CI / lint (pull_request) Successful in 3s

The agent's dist-upgrade simulation already finds new-ABI kernels and
security updates, but only once apt's lists know about them. Debian
doesn't refresh lists by default, so a kernel security release could
stay invisible until someone ran apt update.

install.sh --with-apt-update adds a marker that enables
kernelwatch-apt-update.service, a sandboxed root oneshot the agent pulls
in before each report. Failures (no network, apt lock held) are ignored
so the report still goes out. deploy.sh now ships the unit; a test keeps
deploy.sh's file list in sync with what install.sh uses.

Agent 0.3.2, server 0.3.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
patrickandClaude Opus 5.5 committed 2026-10-17 17:13:55 -04:00
1 parent e9c8f889c7
commit f35cc007f5
8 files changed
+104 -11

No files matched your search

+16 -3
View File
@@ -2,12 +2,16 @@
# Install or upgrade kernelwatch-agent on a Debian 12/13 or Ubuntu 22.04/24.04 host.
#
# sudo ./install.sh --server https://kernelwatch.example.internal [--ca ca.pem]
# [--with-needrestart]
# [--with-needrestart] [--with-apt-update | --without-apt-update]
#
# --with-needrestart installs needrestart (Ubuntu has it already) so the
# dashboard can show services needing a restart, and sets it to only list
# services after apt upgrades instead of asking interactively.
#
# --with-apt-update refreshes apt's package lists (apt-get update) before each
# hourly report, so new kernel and security updates show up within the hour.
# --without-apt-update turns that off again. Without either, it stays as it was.
#
# The host token (from `kernelwatch add-host <name>` on the server) is read
# from --token-file, the KERNELWATCH_TOKEN environment variable, or a prompt,
# so it never lands in shell history. Re-running without --server or a token
@@ -19,6 +23,7 @@ server=
ca=
token_file=
with_needrestart=0
apt_update=
while (($#)); do
case $1 in
@@ -26,7 +31,9 @@ while (($#)); do
--ca) ca=${2:?--ca needs a file}; shift 2 ;;
--token-file) token_file=${2:?--token-file needs a file}; shift 2 ;;
--with-needrestart) with_needrestart=1; shift ;;
-h | --help) sed -n '2,14s/^# \{0,1\}//p' "$0"; exit 0 ;;
--with-apt-update) apt_update=on; shift ;;
--without-apt-update) apt_update=off; shift ;;
-h | --help) sed -n '2,19s/^# \{0,1\}//p' "$0"; exit 0 ;;
*) echo "unknown argument: $1" >&2; exit 2 ;;
esac
done
@@ -58,7 +65,13 @@ fi
install -d -m 0755 /etc/kernelwatch
install -m 0755 "$here/kernelwatch-agent" /usr/local/sbin/kernelwatch-agent
install -m 0644 "$here/kernelwatch-agent.service" "$here/kernelwatch-agent.timer" \
"$here/kernelwatch-needrestart.service" /etc/systemd/system/
"$here/kernelwatch-needrestart.service" "$here/kernelwatch-apt-update.service" \
/etc/systemd/system/
case $apt_update in
on) touch /etc/kernelwatch/apt-update ;;
off) rm -f /etc/kernelwatch/apt-update ;;
esac
if [[ -n $ca ]]; then
install -m 0644 "$ca" /etc/kernelwatch/ca.pem