This script checks for new updates and mails the output to the sysadmin!
#!/bin/sh
#Copyright: Jonas Genannt jonas.genannt (AT) capi2name.de
#License: GPL
MAIL_CMD="/usr/bin/mail"
EMAIL_ADDR="email@domain.tld"
TMPNAME="`mktemp`"
IPADDR="`LC_ALL='en' /sbin/ifconfig eth0 | sed -n -e'/inet addr:/s/^.*inet addr:\([0-9.]*\).*$/\1/p'`"
if [ -z ${IPADDR} ]; then
IPADDR="`LC_ALL='en' /sbin/ifconfig eth0:1 | sed -n -e'/inet addr:/s/^.*inet addr:\([0-9.]*\).*$/\1/p'`"
fi
if [ -z ${IPADDR} ]; then
IPADDR=`/bin/hostname -f`
fi
apt-get update > /dev/null
if [ `apt-get --just-print upgrade | grep -c -E "^Inst"` -gt "0" ]; then
echo -e "apt-get upgrade would like to install these packages:\n" >> ${TMPNAME}
`apt-get --just-print -u upgrade | grep "^Inst " | awk '{print$2}' >> ${TMPNAME}`
echo -e "\n-------------------------------------\nSecurity Updates. You know the drill." >> ${TMPNAME}
${MAIL_CMD} ${EMAIL_ADDR} -s "Updates available on ${IPADDR}" < ${TMPNAME}
rm -f ${TMPNAME}
fi