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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/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