7 messages in net.sourceforge.lists.courier-usersRe: [courier-users] Adding mail accou...
FromSent OnAttachments
David OxleyJul 24, 2002 4:16 am 
Hannes GruberJul 24, 2002 4:53 am 
Mark ConstableJul 24, 2002 5:36 am 
Lukas VeselyJul 24, 2002 6:29 am 
Carey JungJul 24, 2002 7:33 am 
Vlad SedovJul 24, 2002 8:16 am 
Anand BuddhdevJul 24, 2002 8:35 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [courier-users] Adding mail accounts into MySQL DBActions...
From:Mark Constable (mar@renta.net)
Date:Jul 24, 2002 5:36:48 am
List:net.sourceforge.lists.courier-users

David Oxley wrote:

Is there a script to add Email accounts into the MySQL Database and create the necessary directories? If not can anyone supply some sample ...

There probably should be standard simple shell scripts in the main tarball but then again maybe everyones situation is so different. This might be useful to someone and make a useful addition to the mailing-list archive, perhaps.

Shell script snippet. Some vars need to be set first, or dynamically. It creates the homedir, makes the mailbox and adds two users to the MySQL tables. My system provides a sub-domain for each client so the whole script is useless to most people.

***

MYUSER=`echo "select $AUTHFIELD from $AUTHTABLE where $AUTHFIELD = '$1'" | mysql $AUTHDBASE | tail +2` [ ! "x$MYUSER" = "x" ] && echo "User $1 already exists in $AUTHTABLE table" && exit 1

echo "Adding $1/$PASSWD to $SYS"

mkdir -p "${VPATH}admin" "${VPATH}admin/log" "${VPATH}www" maildirmake.courier ${VPATH}admin/Maildir

echo "Created directories in $VPATH"

# add the user to couriers mail table

cat << EOM | mysql $AUTHDBASE INSERT INTO $AUTHTABLE ( id,crypt,clear,uid,gid,home,maildir,quota ) VALUES ( '$1',ENCRYPT('$PASSWD'),'','1','1','${VPATH}admin','','') EOM

echo "Added $1 to $AUTHDBASE.$AUTHTABLE"

# add wildcard mail alias to couriers mail table

cat << EOM | mysql $AUTHDBASE INSERT INTO $AUTHTABLE ( id,crypt,clear,uid,gid,home,maildir,quota ) VALUES ( 'alias@$FQDN',ENCRYPT('$PASSWD'),'','1','1','${VPATH}admin','','') EOM

echo "Added alias@$FQDN to $AUTHDBASE.$AUTHTABLE"

--markc