#!/bin/bash
# postinst script for open-xchange
#
# see: dh_installdeb(1)

set -e

# 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

. /opt/open-xchange/lib/oxfunctions.sh

postFix() {
    local version=${1%-*}
    version=${version//[-.]/}

    # prevent bash from expanding, see bug 13316
    GLOBIGNORE='*'

    # SoftwareChange_Request-3025
    ox_add_property USE_FULL_LOGIN_INFO_FOR_USER_LOOKUP false /opt/open-xchange/etc/imapauth.properties

    # SoftwareChange_Request-3327
    ox_add_property USE_FULL_LOGIN_INFO_FOR_CONTEXT_LOOKUP false /opt/open-xchange/etc/imapauth.properties

    # SoftwareChange_Request-3554
    ox_add_property LOWERCASE_FOR_CONTEXT_USER_LOOKUP false /opt/open-xchange/etc/imapauth.properties
}

case "$1" in
    configure)
        test -n "$2" && {
            # we are in update mode, run postFix to apply fixes
            postFix "$2"
        }
    ;;

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

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

dpkg-maintscript-helper mv_conffile /opt/open-xchange/etc/groupware/imapauth.properties /opt/open-xchange/etc/imapauth.properties 6.20.99 -- "$@"

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

#DEBHELPER#

exit 0
