Feb

26

Debian: Nie wieder vergessene Updates ;)

Bei renemoser.net habe ich ein kleines Skript zum Versenden einer E-Mail bei verfügbaren Updates gefunden. Da es nicht sofort funktioniert hat… (Die „“ um die aptitude-Befehle stören)… hab ich gleich auch noch n bisserl rumgepfuscht und es nach meinen Wünschen angepasst (Optik) und hier das Ergebnis:

#!/bin/bash
#
# Cron Script – run from /etc/crontab or /etc/cron.daily
#
# Checks if an update is available and sends an e-mail
#
# Author: http://www.renemoser.net/archives/190
# Modified by: http://blog.splash.de

MAIL_TO=“xxx@email.com“
QUIET=0

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

UPDATES=`apt-get -s dist-upgrade 2>&1 | awk ‚/Inst/{n++}; END {print n+0}’`
if [ $UPDATES -ne 0 ]
then
PACKAGES=`apt-get -s dist-upgrade 2>&1 | awk ‚/^(Inst)/ {sub(/^Inst+/, „+++“); print}’`
echo „These packages need an update on `hostname`:

$PACKAGES

Please perform ‚apt update && apt upgrade‘ as root“ | mailx -s „[`hostname`] $UPDATES update(s) available“ $MAIL_TO
if [ $QUIET -ne 1 ]
then
echo „These packages need an update on `hostname`:
$PACKAGES“
fi
fi
fi
exit 0

P.S.: Ja, mir ist das „cron-apt“-Paket bekannt ;)

4 Kommentare bis jetzt

  1. Kommentar von scytale:

    Neben cron-apt, gibt es auch noch apticron. Was kann das Skript besser als die beiden? apticron finde ich sehr schick…

  2. Kommentar von proog:

    apticron hatte ich übersehen… und da stören mich die abhängigkeiten ;)
    cron-apt stuft sich selbst als „security risk“ ein…

    und im grunde reicht ja auch n einfaches bash-skript (und hei, ich habs ja nedmal in php geschrieben *fg*)

Track-/PingBacks

  1. splash ;):

    Debian: Vergessene Updates die zweite……

    Hatte die Tage “mein” Skript nochmals etwas nachgebessert und herausgekommen ist folgende Variante:
    #!/bin/bash
    #
    # Cron Script – run from /etc/crontab or /etc/cron.daily
    #
    # Checks if an update is available and sends an e-mail
    #
    # Author: …

  2. eMail bei neuen Serverupdates - Linux: Linux-Forum:

    […] […]

Kommentar hinterlassen

You must be logged in to post a comment.

Archiv

Zufällige Bilder

  • Webmaster-Tools - Website-Leistung
  • Schach (ohne GI/Photoshop)
  • Bloggeramt.de: Blog des Monats

Kommentare (28 Tage)

Sonstiges


Bloggeramt.de