dotfiles/.local/bin/package-alert

24 lines
546 B
Bash
Executable file

#! /usr/bin/bash
set -euo pipefail
IFS=$'\n\t'
WATCHLIST="$(systemd-path user-shared)"/package-alert/watchlist
agg_results=""
if [ -f "${WATCHLIST}" ]; then
while read -r pattern; do
pat_results=$(apt-cache search --names-only "${pattern}")
if [ -n "${pat_results}" ]; then
agg_results="${agg_results:+${agg_results}
}Packages matching \"${pattern}\":
${pat_results}
"
fi
done < "${WATCHLIST}"
fi
if [ -n "${agg_results}" ]; then
printf '%s' "${agg_results}" | /usr/sbin/sendmail "${USER}"
fi