Archive for July, 2007

Apt Update Notify Script

Hier ein kleines, nützliches Bash Script für Debian-based Distributionen, welches informiert ob für das System Updates vorhanden sind.

#!/bin/bash
#
# Cron Script - run from /etc/crontab or /etc/cron.daily
#
# Checks if an update is available and sends an e-mail

MAIL_TO="info@example.com"

LANG=C

if [[ `apt-get update 2>&1 | grep Get` ]]
 then

 UPDATES=`apt-get -s dist-upgrade 2>&1 | grep Inst | wc -l`
 if [ $UPDATES -ne 0 ]
  then
  PACKAGES=`apt-get -s dist-upgrade 2>&1 | grep Inst`
  echo "These packages need an update on `hostname`:

$PACKAGES

Please perform \"aptitude update && aptitude upgrade\" as root" | mailx -s "$UPDATES update(s) available on `hostname`" $MAIL_TO
  echo "$UPDATES update(s) available on `hostname`";
 fi
fi
exit 0