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

set -e

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <overwriter>
#          <overwriter-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
    ;;

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

COMMONCONFFILES="excludedupdatetasks.properties foldercache.properties transport.properties"

for FILE in ${COMMONCONFFILES}; do
    dpkg-maintscript-helper mv_conffile /opt/open-xchange/etc/common/${FILE} \
	/opt/open-xchange/etc/${FILE} 6.20.99 -- "$@"
done

GWCONFFILES="ajp.properties attachment.properties cache.ccf calendar.properties configdb.properties contact.properties event.properties file-logging.properties HTMLEntities.properties imap.properties importerExporter.xml import.properties infostore.properties javamail.properties ldap.properties login.properties mailcache.ccf mail.properties mime.types noipcheck.cnf notification.properties ox-scriptconf.sh participant.properties passwordchange.properties server.properties sessioncache.ccf sessiond.properties smtp.properties system.properties TidyConfiguration.properties TidyMessages.properties user.properties whitelist.properties folder-reserved-names"

for FILE in ${GWCONFFILES}; do
    dpkg-maintscript-helper mv_conffile /opt/open-xchange/etc/groupware/${FILE} \
	/opt/open-xchange/etc/${FILE} 6.20.99 -- "$@"
done

dpkg-maintscript-helper mv_conffile /etc/default/open-xchange-groupware \
    /etc/default/open-xchange 6.20.99 -- "$@"

# SoftwareChange_Request-1094
# -----------------------------------------------------------------------
dpkg-maintscript-helper rm_conffile \
    /opt/open-xchange/etc/groupware/mailjsoncache.properties -- "$@"

# SoftwareChange_Request-1091
dpkg-maintscript-helper rm_conffile \
    /opt/open-xchange/etc/groupware/TidyConfiguration.properties -- "$@"
dpkg-maintscript-helper rm_conffile \
    /opt/open-xchange/etc/groupware/TidyMessages.properties -- "$@"

dpkg-maintscript-helper rm_conffile /etc/init.d/open-xchange-groupware -- "$@"

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

#DEBHELPER#

exit 0
