#!/bin/sh 

set -e
set -x

umask 022

doit() 
{
	if [ -f /usr/share/bugzilla3/lib/collectstats.pl \
        	-a -f /usr/share/bugzilla3/lib/whineatnews.pl ] ; then
	            su www-data -c /usr/share/bugzilla3/lib/collectstats.pl
	            su www-data -c /usr/share/bugzilla3/lib/whineatnews.pl
	fi
}

# process the main configuration: /etc/bugzilla
doit

# then the extra sites: /etc/bugzilla3/sites/*
if [ -d /etc/bugzilla3/sites ]; then
    for site in `cd /etc/bugzilla3/sites && ls`; do
        X_BUGZILLA_SITE="$site" doit
    done
fi

exit 0
