#!/bin/sh
# Script to add users to sites
#
# 30 03 2009
# changed for apache2
#
# 15 09 2006
# Useage ./adduser.sh sitename.ext user pass
# NB NO WWW before sitename.ext!!!
# NB2 This script doesn't add the user to /etc/postfix/virtual
#
# 22 04 2009
# Creates empty files with the right permissions in /home/spool/mail
SITENAME=$1
USER=$2
PASS=$3
GROUPNAME=`grep $SITENAME /etc/apache2/listvirts | awk -F '- ' '{ print $2}'`
/usr/sbin/useradd -s /bin/false -g $GROUPNAME -m -d /home/sites/www.$SITENAME/users/$USER $USER
echo "$USER:$PASS" > userpasslist
cat ./userpasslist | /usr/sbin/chpasswd
cat /dev/null > userpasslist
touch /var/spool/mail/$USER
chown $USER:$GROUPNAME /var/spool/mail/$USER
exit