#!/bin/sh

. /etc/control.d/functions

SPOOL_DIRECTORY=/var/spool/gosa
CONFIG_DIRECTORY=/etc/gosa

new_summary "Web Based LDAP Administration Program"

new_fmode spooldir_apache 1770 root apache
new_fmode spooldir_apache2 1770 root apache2
new_fmode spooldir_lighttpd 1770 root lighttpd

new_fmode confdir_apache 0750 root apache
new_fmode confdir_apache2 0750 root apache2
new_fmode confdir_lighttpd 0750 root lighttpd

new_help spooldir_apache "Set up gosa spool directory permissions for apache"
new_help spooldir_apache2 "Set up gosa spool directory permissions for apache2"
new_help spooldir_lighttpd "Set up gosa spool directory permissions for lighttpd"

new_help confdir_apache "Set up gosa config directory permissions for apache"
new_help confdir_apache2 "Set up gosa config directory permissions for apache2"
new_help confdir_lighttpd "Set up gosa config directory permissions for lighttpd"
case "$*" in

status|'')
    STATUS_DIRECTORY="`control_fmode "$SPOOL_DIRECTORY" status`" || exit 1
        if [ $STATUS_DIRECTORY = "spooldir_apache" ]; then
                STATUS=apache
        elif [ $STATUS_DIRECTORY = "spooldir_apache2" ]; then
                STATUS=apache2
        elif [ $STATUS_DIRECTORY = "spooldir_lighttpd" ]; then
                STATUS=lighttpd
        fi
        test -z "$STATUS" || echo "$STATUS"
    ;;
apache)
    control_fmode "$SPOOL_DIRECTORY" spooldir_apache || exit 1
    control_fmode "$CONFIG_DIRECTORY" confdir_apache || exit 1
    ;;
apache2)
    control_fmode "$SPOOL_DIRECTORY" spooldir_apache2 || exit 1
    control_fmode "$CONFIG_DIRECTORY" confdir_apache2 || exit 1
    ;;
lighttpd)
    control_fmode "$SPOOL_DIRECTORY" spooldir_lighttpd || exit 1
    control_fmode "$CONFIG_DIRECTORY" confdir_lighttpd || exit 1
    ;;

*)
    control_fmode "$SPOOL_DIRECTORY" "$*" || exit 1
    control_fmode "$CONFIG_DIRECTORY" "$*" || exit 1
    ;;
esac

