-
Notifications
You must be signed in to change notification settings - Fork 1
/
debupdatecheck.sh
executable file
·52 lines (42 loc) · 1.06 KB
/
debupdatecheck.sh
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
#
# $Id$
#
# Silently and automatically
# * Do an apt-get update
# * Collect any packages that would be upgraded
# * Optionally download them
# * Send a mail if there is anything new
#
. /etc/debtrack.conf
LOG="$VAR/debupdchk.$$.log"
UPG="$VAR/debupdchk.$$.dat"
exec > "$LOG" 2>&1
# First update package information
apt-get -qq update
# Now check for upgraded packages
apt-get -qq -s upgrade > "$UPG"
if grep "Inst" "$UPG" > /dev/null ; then
echo "Upgraded Packages:"
awk '$1 ~ /Inst/ {printf " %-20s %20s --> %s)\n", $2, $3, $4}' < $UPG
if [ "$DOWNLOAD" = "true" ]; then
echo ""
echo "Starting background download at `date +'%Y-%m-%d %H:%M:%S'`"
apt-get -qq -y -d upgrade
echo "Finished background download at `date +'%Y-%m-%d %H:%M:%S'`"
fi
fi
# Aything to send?
if [ -s "$LOG" -a "$REPORT" = "true" ] ; then
(
echo "DebTrack AutoUpdate Notification for $HOST $DATE"
echo ""
echo "`grep "Inst" $UPG | wc -l` upgrades pending:"
echo ""
cat "$LOG"
echo ""
) | mail -s "NOTIFY: $HOST updates pending" "$MDST"
fi
rm -f "$LOG"
rm -f "$UPG"
exit 0