Commits

Andriy Kornatskyy committed 021f1f8

Added apt-upgrade script

Comments (0)

Files changed (2)

     exit 0
 fi
 
-has_upgrades=$(apt-get -s dist-upgrade | grep ^Inst)
+has_upgrades=$(apt-get -s dist-upgrade | grep ^Inst | sed 's/Inst //g')
 if [ "$has_upgrades" ] ; then
     #echo "Sending updates report."
     echo "$has_upgrades" | mail -s \
+#!/bin/bash
+. /usr/local/sbin/func/random_sleep
+
+#mailto=
+mailto='debian-updates@dev.local'
+
+random_sleep 600 30
+
+upgrades=$(apt-get -ysq dist-upgrade | grep ^Inst)
+if [ -z "$upgrades" ] ; then
+    exit 0
+fi
+    
+if [ -z $mailto ]; then
+    apt-get -yqq dist-upgrade
+else
+    upgrades=`apt-get -yq dist-upgrade | grep ^Setting \
+        | sed -e 's/Setting up //g' -e 's/ \.\.\.\r//g'`
+    echo "$upgrades" | mail -s \
+        "Upgraded $(hostname -s) on $(date +%Y-%m-%d)" \
+        $mailto 
+fi
+
+apt-get clean