Wenn das System nur zur Verwaltung der Konten eingesetzt wird, würde ich auf etwas zurückgreifen, das in der Art wie Confixx die passwd/shadow-Kombi setzt.
Grund: fällt der db-server aus, gehen weder Mails rein noch raus.
Zu den ziemlich eintönigen Schritten User anlegen, Postfach anlegen und Passwort setzen habe ich mit mittlerweile ein Script geschrieben, das ist aber noch nicht hundertprozentig und gerade mal so, daß es funktioniert.
Code: Select all
#!/bin/bash
echo "###################################"
echo "## Mailbox creation "
echo "## "
if [ -z "${1}" ]; then
echo "## ERROR: Username is missing"
exit 1
fi
NEWPASS=`pwgen -n -s -1 | tail -1`
POSTBOXCT=`grep "^${1}p" /etc/passwd | wc -l`
#if [ $POSTBOXCT -gt 0 ]; then
# LASTBOX=`grep "^${1}p" /etc/passwd | awk -F':' '{ print $1}' | sort | tail -1 | awk -F'p' '{ print $2 }'`
#else
# LASTBOX=0
#fi;
NEWBOX=$(($POSTBOXCT+1))
NEWBOXNAME="${1}p${NEWBOX}"
NEWBOXVALID=`grep "^${NEWBOXNAME}" /etc/passwd | wc -l`
echo "###############################"
echo "## User Information:"
echo "## Postbox: ${NEWBOXNAME}"
echo "## Password: $NEWPASS"
echo "## User has $POSTBOXCT mailboxes"
echo "## Last Mailbox was ${1}p${LASTBOX}"
if [ $NEWBOXVALID -eq 0 ]; then
echo "## Newbox is valid"
else
echo "## Newbox is not valid - User exists"
echo "###############################"
exit 1
fi
echo "###############################"
echo "## INFO: creating user"
adduser --home /XnirvanaX
--quiet
--shell /bin/false
--disabled-login
--gecos ""
--no-create-home
--gid 104
--firstuid 1000
--lastuid 30000
${NEWBOXNAME}
echo "## INFO: changing password"
echo "${NEWBOXNAME}:${NEWPASS}" | chpasswd
echo "## INFO: creating IMAP-Mailbox"
/root/scripts/cyr_add.pl ${NEWBOXNAME}
echo "##"
echo "## finished"
echo "###############################"
Code: Select all
#!/usr/bin/perl -w
#
# This will create a new mailbox and set a quota on the new user. Just be
# sure that you installed the Cyrus::IMAP perl module. If you did
# 'make all && make install' or installed Cyrus using the FreeBSD ports you
# don't have to do anything at all.
#
# Change the params below to match your mailserver settins, and
# your good to go!
#
# Author: amram@manhattanprojects.com
#
# modified by Tom Lazar tom@tomster.org on 2003-08-26 to use
# a tab separated user - passwd inputfile instead of the standardpassword
use Cyrus::IMAP::Admin;
#
# CONFIGURATION PARAMS
#
my $cyrus_server = "localhost";
my $cyrus_user = "cyrus";
my $cyrus_pass = "-------";
# 100 Megs
my $quota_size = "1000000";
my $mechanism = "login";
#
# EOC
#
if (!$ARGV[0]) {
die "Usage: $0 [user to add] passwd n";
} else {
$newuser = "$ARGV[0]";
}
sub createMailbox {
my ($user, $subfolder) = @_;
my $cyrus = Cyrus::IMAP::Admin->new($cyrus_server);
$cyrus->authenticate($mechanism,'imap','',$cyrus_user,'0','10000',$cyrus_pass);
if ($subfolder eq "INBOX") {
$mailbox = "user.". $user;
} else {
$mailbox = "user.". $user .".". $subfolder;
}
$cyrus->create($mailbox);
if ($cyrus->error) {
print STDERR "Error: ", $mailbox," ", $cyrus->error, "n";
} else {
print "Created Mailbox: $mailbox n";
}
}
sub setQuota {
my ($user) = @_;
my $cyrus = Cyrus::IMAP::Admin->new($cyrus_server);
$cyrus->authenticate($mechanism,'imap','',$cyrus_user,'0','10000',$cyrus_pass);
$mailbox = "user.". $user;
$cyrus->setquota($mailbox,"STORAGE",$quota_size);
if ($cyrus->error) {
print STDERR "Error: ", $mailbox," ", $cyrus->error, "n";
} else {
print "Setting Quota: $mailbox at $quota_size n";
}
}
print "Adding User: ", $newuser, "n";
createMailbox($newuser,'INBOX');
createMailbox($newuser,'Sent');
createMailbox($newuser,'Trash');
createMailbox($newuser,'Drafts');
createMailbox($newuser,'Junk');
createMailbox($newuser,'NOSPAM');
createMailbox($newuser,'SPAM');
setQuota($newuser);
Das letztere ist dann das Perl-Programm zum eigentlichen Mailboxen anlegen.
Bei einem Kunden setze ich Cyrus mit Auth per pam_winbind ein - das funktioniert gut.