#!/bin/sh

. /etc/control.d/functions

TARGET_DIRECTORY=/var/lib/mailgraph/tmp

new_summary "Simple mail statistics for Postfix"

new_fmode apache 1770 root apache
new_fmode apache2 1770 root apache2
new_fmode lighttpd 1770 root lighttpd
new_fmode nginx 1770 root _nginx

new_help apache "Set up directory permissions for apache"
new_help apache2 "Set up directory permissions for apache2"
new_help lighttpd "Set up directory permissions for lighttpd"
new_help nginx "Set up directory permissions for nginx"

case "$*" in
status|'')
    STATUS="`control_fmode "$TARGET_DIRECTORY" status`" || exit 1
        test -z "$STATUS" || echo "$STATUS"
    ;;
apache)
    control_fmode "$TARGET_DIRECTORY" apache || exit 1
    ;;
apache2)
    control_fmode "$TARGET_DIRECTORY" apache2 || exit 1
    ;;
lighttpd)
    control_fmode "$TARGET_DIRECTORY" lighttpd || exit 1
    ;;
nginx)
    control_fmode "$TARGET_DIRECTORY" nginx || exit 1
    ;;

*)
    control_fmode "$TARGET_DIRECTORY" "$*" || exit 1
    ;;
esac
