#!/bin/bash
# postinst script for open-xchange-parallels
#
# 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

dpkg-maintscript-helper mv_conffile /opt/open-xchange/etc/groupware/parallels.properties \
    /opt/open-xchange/etc/parallels.properties 6.20.99 open-xchange-custom-parallels -- $1 \
    $(dpkg-query -W -f='${Config-Version}' open-xchange-custom-parallels)
dpkg-maintscript-helper mv_conffile /opt/open-xchange/etc/groupware/settings/parallels_gui.properties \
    /opt/open-xchange/etc/settings/parallels-ui.properties 6.20.99 open-xchange-custom-parallels -- $1 \
    $(dpkg-query -W -f='${Config-Version}' open-xchange-custom-parallels)

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

# SoftwareChange_Request-1207
pfile=/opt/open-xchange/etc/parallels.properties
if ox_exists_property com.openexchange.custom.parallels.branding.fallbackurl $pfile; then
    oval=$(ox_read_property com.openexchange.custom.parallels.branding.fallbackurl $pfile)
    ox_remove_property com.openexchange.custom.parallels.branding.fallbackurl $pfile
    ox_set_property com.openexchange.custom.parallels.branding.fallbackhost "$oval" $pfile
fi

# SoftwareChange_Request-1209
pfile=/opt/open-xchange/etc/settings/parallels-ui.properties
if ! ox_exists_property ui/parallels/use_parallels_antispam_features $pfile; then
    ox_set_property ui/parallels/use_parallels_antispam_features true $pfile
fi


case "$1" in
    configure)
    ;;

    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
