#! /bin/sh
# postrm script for apcupsd
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
# for details, see /usr/share/doc/packaging-manual/

case "$1" in
    purge)

        service yandex-passport-logbroker-client-xiva stop

        if [ -f "/etc/yandex/yasmagent/instances.d/lbc-xiva" ]; then
            rm -f "/etc/yandex/yasmagent/instances.d/lbc-xiva" || /bin/true
        fi

        invoke-rc.d yasmagent restart || true

        if [ -x /bin/systemctl ]; then
            deb-systemd-invoke stop yandex-passport-xunistater@lbc-xiva || true
            systemctl disable yandex-passport-xunistater@lbc-xiva || true
        else
            invoke-rc.d yandex-passport-xunistater stop lbc-xiva || true
        fi

        if [ -f "/etc/yandex/logbroker-client/xiva/logrotate.ping" ]; then
            rm -f "/etc/yandex/logbroker-client/xiva/logrotate.ping" || /bin/true
        fi

    ;;

    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 0

esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
