#!/bin/bash

BASE=/opt/www/passport

set -e

case "$1" in
    configure)
        chmod 775 $BASE

        find $BASE \
            -mindepth 0 -maxdepth 1 \
            -type d \
            -exec chmod g+s {} \; \
            -exec chgrp passpadmin -R {} \;

        mkdir -p $BASE/log
        mkdir -p $BASE/log/arc
        mkdir -p $BASE/log/parse

        find $BASE/log \
            ! -name 'push-client*' \
            -exec chown www-data {} \;

        mkdir -p -m777 /opt/tmp
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

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