github.com/meulengracht/snapd@v0.0.0-20210719210640-8bde69bcc84e/packaging/debian-sid/snapd.postinst (about)

     1  #!/bin/sh
     2  
     3  set -e
     4  
     5  
     6  case "$1" in
     7      configure)
     8          # ensure /var/lib/snapd/lib/gl is cleared
     9          if dpkg --compare-versions "$2" lt-nl "2.0.7"; then
    10              ldconfig
    11          fi
    12  
    13          # Ensure that we undo the damage done by the snap.mount unit that was present
    14          # in snapd 2.31.
    15          #
    16          # We found that update scripts make systemd stop inactive mount units and this
    17          # in turn stops all the units that depend on it so when the snap.mount unit is
    18          # stopped all the per-snap mount units gets stopped along with them.  The 2.31
    19          # release was only out briefly in xenial-proposed and bionic but to keep the
    20          # affected users safe let's start all the per-snap mount units so that snaps no
    21          # longer appear as broken after update.
    22          if dpkg --compare-versions "$2" ge-nl "2.31" && \
    23                  dpkg --compare-versions "$2" lt-nl "2.32"; then
    24              units=$(systemctl list-unit-files --full | grep '^snap[-.]' | cut -f1 -d ' ' | grep -vF snap.mount.service || true)
    25              mounts=$(echo "$units" | grep '^snap[-.].*\.mount$' || true)
    26              for unit in $mounts; do
    27                  # ensure its really a snap mount unit or systemd unit
    28                  if ! grep -q 'What=/var/lib/snapd/snaps/' "/etc/systemd/system/$unit" && ! grep -q 'X-Snappy=yes' "/etc/systemd/system/$unit"; then
    29                      echo "Skipping non-snapd systemd unit $unit"
    30                      continue
    31                  fi
    32  
    33                  echo "Starting $unit"
    34                  deb-systemd-invoke start "$unit" || true
    35              done
    36          fi
    37          # Ensure that the void directory has correct permissions.
    38          chmod 111 /var/lib/snapd/void
    39  esac
    40  
    41  #DEBHELPER#