#!/bin/sh
#
# $Id: CheckPatches.cron,v 1.10 2001/01/26 16:48:22 reggers Exp $
#
# This script is designed to call CheckPatches from cron regularly
# and mail the results. An example cron entry might be
#
# 1)   # Check patch level at 3:22am the 5th and 20th of each month:
#      3 22 5,20 * * /usr/local/lib/CheckPatches.cron
#
# If you want to mail to someone other than the user root try this:
#
# 2)   # mail results to operator not "root"
#      3 22 5,20 * * ADMIN=operator /usr/local/lib/CheckPatches.cron
#
# If you have to contend with a local ftp proxy try this:
#
# 3)   # pass additional arguments to "CheckPatches" to get thru proxy
#      3 22 5,20 * * /usr/local/lib/CheckPatches.cron -u ftp@sunsolve.sun.com -s proxy.my.com
#
# If your ROOT isn't /usr/local, if you'd rather not work in /var/adm then:
#
# 4)   # Different location for package. Some like /opt
#      3 22 5,20 * * ROOT=/opt/patches VAR=/var/patches /usr/local/lib/CheckPatches.cron
#
# Solaris patch reports are published around the 1st and the 15th of
# the month. It's probably prudent to wait at little before grabbing
# anything. You may be more anxious, I'm not. REQ.
#
# BEWARE: THIS SCRIPT LEAVES FILES IN VAR=${VAR:-/var/adm}
#
# Original work by Sean Boran 1.Dec.00 v1.0

ARGS="$*"				# if you use a proxy, see 3)
ADMIN=${ADMIN:-root}			# honor environment, see 2)
VAR=${VAR:-/var/adm}			# honor environment, see 4)
ROOT=${ROOT:-/usr/local}		# honor environment, see 4)
ETC=${ETC:-${ROOT}/etc}			# honor environment, see 4)

TMP=/tmp/PatchReport.$$

# Search path includes CheckPatches tool found in $ETC

PATH=/usr/bin:/usr/sbin:$ETC; export PATH

RELEASE=`uname -srpn`;
SUBJECT="Patches Required for $RELEASE";

# Call with '-f' to ensure new report is fetched.

cd $VAR; if CheckPatches -f $ARGS >$TMP; then
	: everything is hunky dory.
else
	mailx -s "$SUBJECT" $ADMIN < $TMP
fi

rm $TMP; exit 0;

