blob: 6ccdead4aebd081c7b3604e43e3b0cbc7f95dc23 (
plain) (
blame)
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
|
#!/bin/sh
set -e
# A node left running once its package is gone serves from deleted code, and
# keeps writing bytecode into the shared venv. Every instance stops here: the
# system ones, and the user service in each running user manager. Not on
# upgrade: the postinst restarts the node onto new code.
stop_user_nodes() {
for bus in /run/user/*/systemd/private; do
[ -S "$bus" ] || continue
uid=$(basename "$(dirname "$(dirname "$bus")")")
user=$(id -nu "$uid" 2>/dev/null) || continue
systemctl --user -M "$user@" stop meshbay-node.service 2>/dev/null || true
done
}
case "$1" in
remove|deconfigure)
if [ -d /run/systemd/system ]; then
systemctl stop 'meshbay-node@*.service' 2>/dev/null || true
stop_user_nodes
fi
;;
esac
# The node's code lives in meshbay-common's venv, and meshbay-common's own
# cleanup runs only after this package is gone: the bytecode compiled next to
# it is removed here, or dpkg cannot remove the directories it sits in.
case "$1" in
remove|upgrade|deconfigure)
find /opt/meshbay-common/venv/lib/python3.*/site-packages/meshbay_node \
-depth -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
;;
esac
#DEBHELPER#
|