#!/bin/bash
# postinst script for open-xchange-grizzly
#
# 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='*'

    PFILE=/opt/open-xchange/etc/smtp.properties

    # SoftwareChange_Request-1795
    ox_add_property com.openexchange.smtp.logTransport false /opt/open-xchange/etc/smtp.properties

    # SoftwareChange_Request-1931
    ox_add_property com.openexchange.smtp.ssl.protocols "SSLv3 TLSv1" $PFILE

    # SoftwareChange_Request-2016
    ox_add_property com.openexchange.smtp.ssl.ciphersuites "" $PFILE

    # SoftwareChange_Request-2553
    ox_add_property com.openexchange.smtp.sendPartial false $PFILE
}

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

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

#DEBHELPER#

exit 0
