hi,

Here is a short script that creates a user,this includes his /Maildir/ and
user/assign. It doesn't use maildirmake and a temporary file for users/assign
creation.
Think it will be helpfull for you. If you want add at the end qmail-newu. 
Before use change it to sweet your needs.
Here goes :
==============================
#! /bin/bash
# Make a mail box (maildir) for a user (QMAIL)
# $1 - user
# $2 - domain
# $3 - owner
# The format is : makeuser UserName DomainName OwnerOfDir
# Example : makeuser john domain-com popuser 
# The domain directory must exists.
#
# Created by iVAN Georgiev ([EMAIL PROTECTED])
#

[ ! $1 ] && { echo "User name not entered !!!" ; exit }

 # Here are defaults. Change them to sweet your needs  
TOPDIR="/mail/"
OWNER="popuser"
DOMAIN="digicom-bg"

[ $2 ] && DOMAIN=$2 ; MAILDIR="$TOPDIR$DOMAIN"
[ $3 ] && OWNER=$3

[ ! -d $MAILDIR ] && { echo "$MAILDIR doesn't exist. Please create it first"; exit }
# Create maildir
mkdir $MAILDIR/$1
mkdir $MAILDIR/$1/{cur,new,tmp}

# Change the owner
chown $OWNER.$OWNER $MAILDIR/$1
chown $OWNER.$OWNER $MAILDIR/$1/{cur,new,tmp}

# Adjust access to files
chmod 700 $MAILDIR/$1
chmod 700 $MAILDIR/$1/{cur,new,tmp}

# Creating .qmail file
echo "../$1/" > $MAILDIR/$1/.qmail

# Add the user to the user/assign
ASSIGN="/var/qmail/users/assign"
OUID="500"
OGID="500"
RULE="=$DOMAIN-$1:$OUID:$OGID:$MAILDIR/$1:::"
cat $ASSIGN | sed -e '$i\' -e "$RULE" > $ASSIGN 

echo "User : $1 created in dir. $MAILDIR/$1"

==================
HtH
=====
[EMAIL PROTECTED]
=====

Reply via email to