NetBSDCheckPackages

How to check the installed packages for the latest version

One of the great advantages of NetBSD is the excellent, and often overlooked pkgsrc, its software packaging system. Simple and powerful, well documented, and just as portable as the operating system it was created on, pkgsrc is really a gem!

Here is the script that I use to check the latest version of the packages on my machine:

#!/bin/ksh

# ####################################################
# #
# # check updates on packages and mail results
# #
# ####################################################

# --- create report file ---

touch /root/audit_report.txt

# --- insert date/time ---

echo "--- START ---" >> /root/audit_report.txt
echo `date` >> /root/audit_report.txt

# --- download the latest vulnerabilities file ---

/usr/sbin/pkg_admin fetch-pkg-vulnerabilities

# --- check installed packages for vulnerabilities ---

/usr/sbin/pkg_admin audit >> /root/audit_report.txt

# --- check packages for new versions ---

/usr/pkg/bin/lintpkgsrc -i >> /root/audit_report.txt

# --- insert date/time ---

echo `date` >> /root/audit_report.txt
echo "--- END ---" >> /root/audit_report.txt

# --- mail to the main user of the machine ---   ;-)
# replace admin@localhost by your admin email address

echo "Package check for machine `uname -n`. Report is attached." | /usr/bin/mailx -a /root/audit_report.txt -s "Package check - `date`" admin@localhost

# --- delete the report file ---

rm /root/audit_report.txt

exit 0

Stick this in your root crontab, and you are in business!

See Also: