#!/bin/sh
# postinst script for test-0.1
#
# see: dh_installdeb(1)

set -e
set -x

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    configure)

    chown -R www-data: /var/log/yandex/autofill-frontend
    chown -R www-data: /usr/lib/yandex/autofill-frontend
    chown -R statbox:statbox /var/lib/push-client-autofill-frontend
    chmod 0755 /var/lib/push-client-autofill-frontend
    chmod 0755 /var/log/yandex/autofill-frontend

    rm -f /etc/yandex/passport-tvm-keyring/conf-enabled/yandex_autofill_frontend

    # if deb is installed by admin
    yav-deploy -c /etc/yandex/yav-deploy/pkg/autofill-frontend/ || /bin/true
    # if deb is installed by conductor
    yav-deploy --rsa-login robot-passport-front --rsa-private-key /usr/lib/yandex/autofill-frontend/robot-passport-front-private-key -c /etc/yandex/yav-deploy/pkg/autofill-frontend/ || /bin/true  
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

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

#DEBHELPER#

exit 0
