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
53
54
55
|
#!/bin/sh -e
#
# helper for update-motd
# poor mans force
if [ "$1" = "--force" ]; then
NEED_UPDATE_CHECK=yes
fi
# check time when we did the last udpate check
stamp="/var/lib/update-notifier/updates-available"
if [ -e "$stamp" ]; then
stampt=$(stat -c %Y $stamp)
else
stampt=0
fi
# get list dir
StateDir="/var/lib/apt/"
ListDir="lists/"
eval $(apt-config shell StateDir Dir::State)
eval $(apt-config shell ListDir Dir::State::Lists)
# check if we have a list file that needs checking
d="/$StateDir/$ListDir"
for f in $d/*; do
# ignore dirs
if [ ! -f $f ]; then
continue
fi
t=$(stat -c %Y $f)
if [ $t -gt $stampt ]; then
NEED_UPDATE_CHECK=yes
fi
done
# check if sources.list was modified since last check
EtcDir="etc/apt/"
SourceList="sources.list"
eval $(apt-config shell EtcDir Dir::Etc)
eval $(apt-config shell SourceList Dir::Etc::sourcelist)
if [ $(stat -c %Y "/$EtcDir/$SourceList") -gt $stampt ]; then
NEED_UPDATE_CHECK=yes
fi
# output something for update-motd
if [ -n "$NEED_UPDATE_CHECK" ]; then
echo "" > $stamp
/usr/lib/update-notifier/apt-check --human-readable >> $stamp
echo "" >> $stamp
fi
# output what we have (either cached or newly generated)
cat $stamp
|