#!/bin/sh

set -e

#EXTRA#
#DEBHELPER#

fixperms() {
    chown -R www-data:www-data \
        /var/cache/kolab-webadmin \
        /var/log/kolab-webadmin
    chmod 750 \
        /var/cache/kolab-webadmin \
        /var/log/kolab-webadmin
}

reload_apache()
{
    if apache2ctl configtest 2>/dev/null; then
        invoke-rc.d apache2 $1 || true
    else
        echo "Your apache2 configuration is broken, so we're not restarting it for you."
    fi
}


case "$1" in
    configure)
        fixperms
        a2enmod rewrite > /dev/null || true
        reload_apache stop
        reload_apache start
    ;;
esac

exit 0
