#!/bin/bash -x
DOMAIN="$1"
ACCESS_FILE="/etc/awstats/awstats.pwd"
STAT_DIR="/home/services/awstats/$DOMAIN/html"
ALS="www.$DOMAIN"

# Create the statistics directory
if [ -d $STAT_DIR ]; then
    echo "Statistics dir already exist"
else
    mkdir -p $STAT_DIR
fi

# Create the virtual host awstats.conf
grep -v '#' awstats.model.conf  | sed '/^$/d' | sed  -e "s/\\\$DOMAIN/$DOMAIN/g" \
				      -e "s/\\\$ALIASES/$ALS/g" > \
"/etc/awstats/awstats.$DOMAIN.conf"

# Add user/password to password file
#if [ -e $ACCESS_FILE ]; then
#    /opt/apache-1.3/bin/htpasswd -bm $ACCESS_FILE $WUSERNAME $PASSWORD
#else
#    /opt/apache-1.3/bin/htpasswd -bm -c $ACCESS_FILE $WUSERNAME $PASSWORD
#fi

