-
Notifications
You must be signed in to change notification settings - Fork 594
/
Copy pathsnapd.postinst
75 lines (65 loc) · 3.38 KB
/
snapd.postinst
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
set -e
# "powerpc" is not supported unfortunately, do nothing here#
if [ "$DPKG_MAINTSCRIPT_ARCH" = powerpc ]; then
exit 0
fi
case "$1" in
configure)
# ensure /var/lib/snapd/lib/gl is cleared
if dpkg --compare-versions "$2" lt-nl "2.0.7"; then
ldconfig
fi
# Ensure that we undo the damage done by the snap.mount unit that was present
# in snapd 2.31.
#
# We found that update scripts make systemd stop inactive mount units and this
# in turn stops all the units that depend on it so when the snap.mount unit is
# stopped all the per-snap mount units gets stopped along with them. The 2.31
# release was only out briefly in xenial-proposed and bionic but to keep the
# affected users safe let's start all the per-snap mount units so that snaps no
# longer appear as broken after update.
if dpkg --compare-versions "$2" ge-nl "2.31" && \
dpkg --compare-versions "$2" lt-nl "2.32"; then
units=$(systemctl list-unit-files --full | grep '^snap[-.]' | cut -f1 -d ' ' | grep -vF snap.mount.service || true)
mounts=$(echo "$units" | grep '^snap[-.].*\.mount$' || true)
for unit in $mounts; do
# ensure its really a snap mount unit or systemd unit
if ! grep -q 'What=/var/lib/snapd/snaps/' "/etc/systemd/system/$unit" && ! grep -q 'X-Snappy=yes' "/etc/systemd/system/$unit"; then
echo "Skipping non-snapd systemd unit $unit"
continue
fi
echo "Starting $unit"
deb-systemd-invoke start "$unit" || true
done
fi
# In commit 0dce4704a5d (2017-03-28, snapd v2.23.6) we renamed
# /etc/apparmor.d/usr.lib.snap-confine to usr.lib.snap-confine.real
# to fix LP: #1673247 - however some people (developers?) still have
# the old usr.lib.snap-confine file. This seems to be loaded instead
# of the correct usr.lib.snap-confine.real profile. To fix this we
# use the rather blunt approach to rename the file forcefully.
if test -f /etc/apparmor.d/usr.lib.snapd.snap-confine && test -f /etc/apparmor.d/usr.lib.snapd.snap-confine.real; then
mv /etc/apparmor.d/usr.lib.snapd.snap-confine /etc/apparmor.d/usr.lib.snapd.snap-confine.dpkg-bak
fi
# Ensure that the void directory has correct permissions.
chmod 111 /var/lib/snapd/void
# Ubuntu 20.04 had a incorrect seed directory during development.
#
# This was causing hangs in the postinst when systemctl tries to
# start snapd.seeded.service which will wait for snapd to finish
# seeding (which will never happen because seeding is broken).
# See LP: 1868706
# This snippet detect this incorrect seed and disables it.
if [ -e /var/lib/snapd/seed/seed.yaml ] && [ "$(snap debug state --is-seeded /var/lib/snapd/state.json)" = "false" ]; then
if ! snap debug validate-seed /var/lib/snapd/seed/seed.yaml; then
echo "Found incorrect seed, disabling it"
mv /var/lib/snapd/seed /var/lib/snapd/seed.disabled
fi
fi
# ensure "snap userd" is restarted
if dpkg --compare-versions "$2" lt-nl "2.45.2"; then
pkill -f "snap userd" || true
fi
esac
#DEBHELPER#