~ubuntu-core-dev/update-notifier/ubuntu

« back to all changes in this revision

Viewing changes to data/update-motd-updates-available

  • Committer: Balint Reczey
  • Date: 2020-06-11 18:46:02 UTC
  • Revision ID: balint.reczey@canonical.com-20200611184602-2rv1zan3xu723x2u
Moved to git at https://git.launchpad.net/update-notifier

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh -e
2
 
#
3
 
# helper for update-motd
4
 
 
5
 
 
6
 
# poor mans force
7
 
if [ "$1" = "--force" ]; then
8
 
    NEED_UPDATE_CHECK=yes
9
 
else
10
 
    NEED_UPDATE_CHECK=no
11
 
fi
12
 
 
13
 
# check time when we did the last update check
14
 
stamp="/var/lib/update-notifier/updates-available"
15
 
 
16
 
# get list dir
17
 
StateDir="/var/lib/apt/"
18
 
ListDir="lists/"
19
 
eval "$(apt-config shell StateDir Dir::State)"
20
 
eval "$(apt-config shell ListDir Dir::State::Lists)"
21
 
 
22
 
# get dpkg status file
23
 
DpkgStatus="/var/lib/dpkg/status"
24
 
eval "$(apt-config shell DpkgStatus Dir::State::status)"
25
 
 
26
 
# get sources.list file
27
 
EtcDir="etc/apt/"
28
 
SourceList="sources.list"
29
 
eval "$(apt-config shell EtcDir Dir::Etc)"
30
 
eval "$(apt-config shell SourceList Dir::Etc::sourcelist)"
31
 
 
32
 
# let the actual update be asynchronous to avoid stalling apt-get
33
 
cleanup() { rm -f "$tmpfile"; }
34
 
 
35
 
# check if we have a list file or sources.list that needs checking
36
 
if [ -e "$stamp" ]; then
37
 
    if [ "$(find "/$StateDir/$ListDir" "/$EtcDir/$SourceList" "/$DpkgStatus" -type f -newer "$stamp" -print -quit)" ]; then
38
 
        NEED_UPDATE_CHECK=yes
39
 
    fi
40
 
else
41
 
    if [ "$(find "/$StateDir/$ListDir" "/$EtcDir/$SourceList" -type f -print -quit)" ]; then
42
 
        NEED_UPDATE_CHECK=yes
43
 
    fi
44
 
fi
45
 
 
46
 
tmpfile=""
47
 
trap cleanup EXIT
48
 
tmpfile=$(mktemp -p $(dirname "$stamp"))
49
 
 
50
 
# output something for update-motd
51
 
if [ "$NEED_UPDATE_CHECK" = "yes" ]; then
52
 
    {
53
 
 
54
 
        echo ""
55
 
        /usr/lib/update-notifier/apt-check --human-readable
56
 
        echo ""
57
 
    } > "$tmpfile"
58
 
    mv "$tmpfile" "$stamp"
59
 
    chmod +r "$stamp"
60
 
fi