File check-for-updates of Package updatecheck

#!/bin/sh

# (C) 2011 Peter Conrad <conrad@quisquis.de>

# This program is licensed under the terms of the
# GNU General Public License Version 2. A copy of these terms should be
# enclosed as "GPL-2.0.txt" in the package containing this file.

CONFIG=/etc/sysconfig/updatecheck
[ -r "$CONFIG" ] && . "$CONFIG"

cd /root
zypper $GENERAL_ZYPPER_OPTS lu $ZYPPER_LU_OPTS >zypper-lu.out 2>&1
if [ -s zypper-lu.out ]; then
    touch zypper-lu.old
    if ! diff -q zypper-lu.old zypper-lu.out >/dev/null; then
	if [ -z "$RECIPIENT" ]; then
	    cat zypper-lu.out
	else
	    ( echo "Date: `date -R`"
	      echo "Subject: Updates available for `hostname --fqdn`"
	      echo ""
	      cat zypper-lu.out ) | /usr/sbin/sendmail $RECIPIENT
	fi
	mv zypper-lu.out zypper-lu.old
    fi
fi
 
rm -f zypper-lu.out
exit 0

openSUSE Build Service is sponsored by