]> git.arvados.org - arvados.git/blob - build/python-package-scripts/postinst
9953: Add systemd unit file for arvados-docker-cleaner.
[arvados.git] / build / python-package-scripts / postinst
1 #!/bin/sh
2
3 set -e
4
5 # NOTE: This package name detection will only work on Debian.
6 # If this postinst script ever starts doing work on Red Hat,
7 # we'll need to adapt this code accordingly.
8 script="$(basename "${0}")"
9 pkg="${script%.postinst}"
10 systemd_unit="${pkg}.service"
11
12 case "${1}" in
13     configure)
14         if [ -e /run/systemd/system ]; then
15             cp "/usr/share/doc/${pkg}/${pkg}.service" /lib/systemd/system/
16             eval "$(systemctl -p UnitFileState show "${systemd_unit}")"
17             case "${UnitFileState}" in
18                 disabled)
19                     # Failing to enable or start the service is not a
20                     # package error, so don't let errors here
21                     # propagate up.
22                     systemctl enable "${systemd_unit}" || true
23                     systemctl start "${systemd_unit}" || true
24                     ;;
25                 enabled)
26                     systemctl daemon-reload || true
27                     systemctl reload-or-try-restart "${systemd_unit}" || true
28                     ;;
29             esac
30         fi
31         ;;
32 esac