#!/bin/sh
# postinst script for z-push
#
# see: dh_installdeb(1)

case "$1" in
    configure)
        /usr/sbin/z-push-admin -a fixstates-upgrade
        if [ $? -ne 0 ]; then
            YELLOW='\033[0;33m'
            NC='\033[0m' # No Color
            echo -e "${YELLOW}When upgrading from an earlier version you need to run 'z-push-admin -a fixstates'.\n
It seems the execution on setup has failed (see error above). Please fix the issue and run the command manually.\n
More information at https://wiki.z-hub.io/x/R4Ea${NC}\n"
        fi
    ;;

    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
