Merge branch 'crunch-job_finds_newer_docker_hashes' of https://github.com/tmooney...
[arvados.git] / build / go-python-package-scripts / prerm
1 #!/bin/sh
2
3 set -e
4
5 # NOTE: This package name detection will only work on Debian.
6 # If this prerm script ever starts doing work on Red Hat,
7 # we'll need to adapt this code accordingly.
8 script="$(basename "${0}")"
9 pkg="${script%.prerm}"
10 systemd_unit="${pkg}.service"
11
12 case "${1}" in
13     remove)
14         if [ -e /run/systemd/system ]; then
15             systemctl stop "${systemd_unit}" || true
16             systemctl disable "${systemd_unit}" || true
17         fi
18
19         # Unit files from Python packages get installed by postinst so
20         # we have to remove them explicitly here.
21         py_unit="/usr/share/doc/${pkg}/${pkg}.service"
22         if [ -e "${py_unit}" ]
23         then
24             rm "/lib/systemd/system/${pkg}.service" || true
25         fi
26         ;;
27 esac