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
27 CHR="chroot $CHROOT";;
29 CHR="schroot -c $CHROOT --";;
31 $CHR apt-get update > $TMPFILE 2>&1
33 if [ $error -ne 0 ] ; then
34 echo $CHR update failed with error $error
37 # And also check for warnings:
39 if [ $? -eq 0 ] ; then
40 echo "$CHR update gave the following warnings:"
45 THIS_LIST=`$CHR apt-get -s -u dist-upgrade | awk '/^Inst/ {print $2}'`
46 if [ "$THIS_LIST"x != ""x ] ; then
47 UPDATE_LIST="$UPDATE_LIST\n$CHROOT:\n"
50 UPDATE_LIST="$UPDATE_LIST $PKG\n"
52 CHROOT_UPDATED="$CHROOT_UPDATED $CHROOT"
56 if [ "$UPDATE_LIST"x != ""x ] ; then
57 # If we've been configured to download packages, grab them now
59 if [ "$DOWNLOAD_DEBS"x = "yes"x ] ; then
60 for CHROOT in $CHROOT_UPDATED
66 CHR="chroot $CHROOT";;
68 CHR="schroot -c $CHROOT --";;
70 $CHR apt-get -d -y dist-upgrade > /dev/null
72 if [ $error -ne 0 ] ; then
73 echo $CHR package download failed with error $error
76 UPDATE_LIST="$UPDATE_LIST\n\nPackage(s) downloaded and ready to install\n"
79 printf "$UPDATE_LIST\n"