| 1 | #!/bin/sh |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | # summary of how this script can be called: |
| 6 | # * <postinst> `configure' <most-recently-configured-version> |
| 7 | # * <old-postinst> `abort-upgrade' <new version> |
| 8 | # * <conflictor's-postinst> `abort-remove' `in-favour' <package> |
| 9 | # <new-version> |
| 10 | # * <deconfigured's-postinst> `abort-deconfigure' `in-favour' |
| 11 | # <failed-install-package> <version> `removing' |
| 12 | # <conflicting-package> <version> |
| 13 | # for details, see http://www.debian.org/doc/debian-policy/ or |
| 14 | # the debian-policy package |
| 15 | # |
| 16 | # quoting from the policy: |
| 17 | # Any necessary prompting should almost always be confined to the |
| 18 | # post-installation script, and should be protected with a conditional |
| 19 | # so that unnecessary prompting doesn't happen if a package's |
| 20 | # installation fails and the `postinst' is called with `abort-upgrade', |
| 21 | # `abort-remove' or `abort-deconfigure'. |
| 22 | |
| 23 | case "$1" in |
| 24 | configure) |
| 25 | # Add prometheus user |
| 26 | if ! getent passwd prometheus > /dev/null; then |
| 27 | adduser --quiet --system --home /var/lib/prometheus --no-create-home \ |
| 28 | --group --gecos "Prometheus daemon" prometheus || true |
| 29 | fi |
| 30 | # Add prometheus user to libvirt group |
| 31 | if getent group libvirt > /dev/null; then |
| 32 | usermod -a -G libvirt prometheus |
| 33 | else |
| 34 | echo "Group libvirt does not exist." |
| 35 | fi |
| 36 | |
| 37 | chown prometheus:prometheus /var/lib/prometheus || true |
| 38 | |
| 39 | ;; |
| 40 | |
| 41 | abort-upgrade|abort-remove|abort-deconfigure) |
| 42 | : |
| 43 | ;; |
| 44 | |
| 45 | *) |
| 46 | echo "postinst called with unknown argument \`$1'" >&2 |
| 47 | exit 1 |
| 48 | ;; |
| 49 | esac |
| 50 | |
| 51 | # dh_installdeb will replace this with shell code automatically |
| 52 | # generated by other debhelper scripts. |
| 53 | |
| 54 | #DEBHELPER# |
| 55 | |
| 56 | exit 0 |