github.com/stolowski/snapd@v0.0.0-20210407085831-115137ce5a22/packaging/ubuntu-16.04/snapd.prerm (about) 1 #!/bin/sh 2 3 set -e 4 5 # "powerpc" is not supported unfortunately, do nothing here# 6 if [ "$DPKG_MAINTSCRIPT_ARCH" = powerpc ]; then 7 exit 0 8 fi 9 10 systemctl_stop() { 11 unit="$1" 12 13 echo "Stopping unit $unit" 14 systemctl stop -q "$unit" || true 15 16 for i in $(seq 20); do 17 echo "Waiting until unit $unit is stopped [attempt $i]" 18 if ! systemctl is-active -q "$unit"; then 19 echo "$unit is stopped." 20 return 21 fi 22 sleep .1 23 done 24 } 25 26 if [ "$1" = "remove" ]; then 27 units=$(systemctl list-unit-files --full | grep '^snap\.' | cut -f1 -d ' ' | grep -vF snap.mount.service || true) 28 tostop=$(echo "$units" | grep -E '^snap\..*\.(service|timer|socket)$' || true) 29 30 for unit in $tostop; do 31 # ensure it's really a snap mount unit or systemd unit 32 if ! grep -q 'X-Snappy=yes' "/etc/systemd/system/$unit"; then 33 echo "Skipping non-snapd systemd unit $unit" 34 continue 35 fi 36 37 echo "Stopping $unit" 38 systemctl_stop "$unit" 39 done 40 fi 41 42 #DEBHELPER#