15370: Fix flaky test.
[arvados.git] / build / go-python-package-scripts / prerm
1 #!/bin/sh
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 set -e
7
8 # Detect rpm-based systems: the exit code of the following command is zero
9 # on rpm-based systems
10 if /usr/bin/rpm -q -f /usr/bin/rpm >/dev/null 2>&1; then
11     # Red Hat ("%{...}" is interpolated at package build time)
12     pkg="%{name}"
13     pkgtype=rpm
14     prefix="${RPM_INSTALL_PREFIX}"
15 else
16     # Debian
17     script="$(basename "${0}")"
18     pkg="${script%.prerm}"
19     pkgtype=deb
20     prefix=/usr
21 fi
22
23 case "${pkgtype}-${1}" in
24     deb-remove | rpm-0)
25         if [ -e /run/systemd/system ]; then
26             systemctl stop "${pkg}" || true
27             systemctl disable "${pkg}" || true
28         fi
29         if [ -e "${prefix}/share/doc/${pkg}/${pkg}.service" ]; then
30             # Unit files from Python packages get installed by
31             # postinst so we have to remove them explicitly here.
32             rm "/lib/systemd/system/${pkg}/${pkg}.service" || true
33         fi
34         ;;
35 esac