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

« back to all changes in this revision

Viewing changes to data/update-motd-hwe-eol

  • 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_EOL_CHECK=yes
9
 
else
10
 
    if type systemd-detect-virt > /dev/null 2>&1  && systemd-detect-virt -q -c; then
11
 
        exit
12
 
    fi
13
 
    NEED_EOL_CHECK=no
14
 
fi
15
 
 
16
 
# check time when we did the last update check
17
 
stamp="/var/lib/update-notifier/hwe-eol"
18
 
 
19
 
# get list dir
20
 
StateDir="/var/lib/apt/"
21
 
ListDir="lists/"
22
 
eval "$(apt-config shell StateDir Dir::State)"
23
 
eval "$(apt-config shell ListDir Dir::State::Lists)"
24
 
 
25
 
# get dpkg status file
26
 
DpkgStatus="/var/lib/dpkg/status"
27
 
eval "$(apt-config shell DpkgStatus Dir::State::status)"
28
 
 
29
 
# get sources.list file
30
 
EtcDir="etc/apt/"
31
 
SourceList="sources.list"
32
 
eval "$(apt-config shell EtcDir Dir::Etc)"
33
 
eval "$(apt-config shell SourceList Dir::Etc::sourcelist)"
34
 
 
35
 
# let the actual update be asynchronous to avoid stalling apt-get
36
 
cleanup() { rm -f "$tmpfile"; }
37
 
 
38
 
# check if we have a list file or sources.list that needs checking
39
 
if [ -e "$stamp" ]; then
40
 
    if [ "$(find "/$StateDir/$ListDir" "/$EtcDir/$SourceList" "/$DpkgStatus" -type f -newer "$stamp" -print -quit 2> /dev/null)" ]; then
41
 
        NEED_EOL_CHECK=yes
42
 
    fi
43
 
else
44
 
    if [ "$(find "/$StateDir/$ListDir" "/$EtcDir/$SourceList" -type f -print -quit 2> /dev/null)" ]; then
45
 
        NEED_EOL_CHECK=yes
46
 
    fi
47
 
fi
48
 
 
49
 
# only print status when running this script as a regular user
50
 
if [ "$(id -u)" != 0 ] ; then
51
 
   [ "$NEED_EOL_CHECK" = "no" ] || /usr/bin/hwe-support-status || true
52
 
   exit
53
 
fi
54
 
 
55
 
tmpfile=""
56
 
trap cleanup EXIT
57
 
tmpfile=$(mktemp -p $(dirname "$stamp"))
58
 
 
59
 
# output something for update-motd
60
 
if [ "$NEED_EOL_CHECK" = "yes" ]; then
61
 
    {
62
 
        # the script may exit with status 10 when a HWE update is needed
63
 
        /usr/bin/hwe-support-status || true
64
 
    } > "$tmpfile"
65
 
    mv "$tmpfile" "$stamp"
66
 
fi
67
 
 
68
 
# output what we have (either cached or newly generated)
69
 
cat "$stamp"