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