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