Skip to content

Instantly share code, notes, and snippets.

@pyllyukko
Created June 26, 2019 11:06
Show Gist options
  • Save pyllyukko/a0ef50d1bbb28d148c4a41f651a8d929 to your computer and use it in GitHub Desktop.
Save pyllyukko/a0ef50d1bbb28d148c4a41f651a8d929 to your computer and use it in GitHub Desktop.
#!/bin/bash
# pkg_audit.sh for FreeBSD
# Run from cron so it will mail the diff
umask 077
oldlog="/root/pkg_audit.txt"
newlog="$( /usr/bin/mktemp )"
/usr/sbin/pkg audit -F 1>"${newlog}"
/usr/bin/sed -i -e 1d "${newlog}"
if [ ! -f "${oldlog}" ]
then
/bin/mv "${newlog}" "${oldlog}"
exit 0
fi
if /usr/bin/cmp "${oldlog}" "${newlog}"
then
/bin/rm "${newlog}"
else
/usr/bin/diff "${oldlog}" "${newlog}"
/bin/mv "${newlog}" "${oldlog}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment