5 # Simple wrapper script for cron to use - check for updated packages
6 # and mail admin with any recommended upgrades.
8 # Assumes that apt is configured correctly before we start...
10 # Copyright 2001-2019 Steve McIntyre <steve@einval.com>
17 TMPFILE=/etc/apt/update.tmp
19 . /etc/apt/update.conf
21 for CHROOT in $CHROOTS
23 if [ $CHROOT = / ] ; then
28 $CHR apt-get update > $TMPFILE 2>&1
30 if [ $error -ne 0 ] ; then
31 echo $CHR update failed with error $error
34 # And also check for warnings:
36 if [ $? -eq 0 ] ; then
37 echo "$CHR update gave the following warnings:"
42 THIS_LIST=`$CHR apt-get -s -u dist-upgrade | awk '/^Inst/ {print $2}'`
43 if [ "$THIS_LIST"x != ""x ] ; then
44 UPDATE_LIST="$UPDATE_LIST\n$CHROOT:\n"
47 UPDATE_LIST="$UPDATE_LIST $PKG\n"
49 CHROOT_UPDATED="$CHROOT_UPDATED $CHROOT"
53 if [ "$UPDATE_LIST"x != ""x ] ; then
54 # If we've been configured to download packages, grab them now
56 if [ "$DOWNLOAD_DEBS"x = "yes"x ] ; then
57 for CHROOT in $CHROOT_UPDATED
59 if [ $CHROOT = / ] ; then
64 $CHR apt-get -d -y dist-upgrade > /dev/null
66 if [ $error -ne 0 ] ; then
67 echo $CHR package download failed with error $error
70 UPDATE_LIST="$UPDATE_LIST\n\nPackage(s) downloaded and ready to install\n"
73 printf "$UPDATE_LIST\n"