#!/bin/sh
# postinst script for cmsimplexh-templates-bracksiek
#
# 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

pkgpath="/usr/share/cmsimplexh"
owner="www-data:www-data"
dirrights="775"
filerights="664"


case "$1" in
    configure)
    # owner is www-data on debian systems
    find ${pkgpath} -exec chown ${owner} {} \;

    # directory read-write
    find ${pkgpath}/downloads -type d -exec chmod ${dirrights} {} \;
    find ${pkgpath}/images -type d -exec chmod ${dirrights} {} \;
    find ${pkgpath}/templates -type d -exec chmod ${dirrights} {} \;
    find ${pkgpath}/logs -type d -exec chmod ${dirrights} {} \;
    find ${pkgpath}/cmsimple/languages -type d -exec chmod ${dirrights} {} \;

    #  file read-write
    find ${pkgpath}/config/*.php -type f -exec chmod ${filerights} {} \;
    find ${pkgpath}/content/*.php -type f -exec chmod ${filerights} {} \;
    find ${pkgpath}/content/*.htm -type f -exec chmod ${filerights} {} \;
    find ${pkgpath}/css/*.css -type f -exec chmod ${filerights} {} \;
    find ${pkgpath}/cmsimple/languages/*.php -type f -exec chmod ${filerights} {} \;
    find ${pkgpath}/logs/*.txt -type f -exec chmod ${filerights} {} \;
    find ${pkgpath}/templates/*/*.css -type f -exec chmod ${filerights} {} \;
    find ${pkgpath}/templates/*/*.htm -type f -exec chmod ${filerights} {} \;
    ;;

    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
