conf/113913: New file: /etc/periodic/daily/490.status-pkg-changes

Oliver Fromme olli at secnetix.de
Thu Jun 21 15:00:11 UTC 2007


>Number:         113913
>Category:       conf
>Synopsis:       New file: /etc/periodic/daily/490.status-pkg-changes
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 21 15:00:10 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Oliver Fromme
>Release:        FreeBSD 6.2-STABLE-20070615 i386
>Organization:
secnetix GmbH & Co. KG
		http://www.secnetix.de/bsd
>Environment:

FreeBSD RELENG_6 and HEAD (7-current)

>Description:

The script below adds a new status report to the daily
periodic output:  A paragraph that lists packages that
have been added, updated or deleted in the past 24 hours.

That information is particularly useful on servers that
are maintained by multiple administrators.  When someone
adds, updates or deletes a package, the others will see
it in the daily periodic output.

Such a paragraph looks like this (example):

Changes in installed packages:
-gawk-3.1.1_1        The GNU version of Awk
+gawk-3.1.5          The GNU version of Awk
-ispell-3.2.06_17    An interactive spelling checker for multiple languages
-w3m-0.5.1_6         A pager/text-based WWW browser
+w3m-0.5.2           A pager/text-based WWW browser
+zsh-4.3.2_1         The Z shell

Of course, if there are no changes, nothing is displayed
at all.  The format is intentionally simple and compact.

>How-To-Repeat:

Save the script below as /etc/periodic/daily/490.status-pkg-changes
and add this line to /etc/periodic.conf:
daily_status_pkg_changes_enable="YES"

Suggested default entry for /etc/defaults/periodic.conf:
# 490.status-pkg-changes
daily_status_pkg_changes_enable="NO"      # Show package changes

>Fix:

#!/bin/sh -
# Show which packages have been added, updated or deleted.

# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
    . /etc/defaults/periodic.conf
    source_periodic_confs
fi

case "$daily_status_pkg_changes_enable" in
    [Yy][Ee][Ss])
	if [ ! -f /usr/sbin/pkg_info ]; then
	    echo '$daily_status_pkg_changes_enable is enabled but' \
		 "/usr/sbin/pkg_info doesn't exist"
	    rc=2
	else
	    bak=/var/backups
	    rc=0

	    if [ -f $bak/pkg_info.bak ]; then
	    	mv -f $bak/pkg_info.bak $bak/pkg_info.bak2
	    fi
	    /usr/sbin/pkg_info > $bak/pkg_info.bak

	    if ! cmp -sz $bak/pkg_info.bak $bak/pkg_info.bak2; then
		echo ""
		echo "Changes in installed packages:"
		diff -U 0 $bak/pkg_info.bak2 $bak/pkg_info.bak \
		| grep '^[-+][^-+]' | sort -k 1.2
	    fi
	fi
	;;

    *)
	rc=0
	;;
esac

exit $rc
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list