1
1
mirror of https://github.com/docker-mailserver/docker-mailserver synced 2024-10-18 19:29:45 +02:00

Merge pull request #211 from Crafter6432/usermanagement

Usermanagement
This commit is contained in:
Thomas VIAL 2016-06-20 12:18:15 +02:00 committed by GitHub
commit 1d942fa4d2
4 changed files with 66 additions and 1 deletions

@ -71,7 +71,7 @@ RUN curl -s https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem > /et
curl -s https://letsencrypt.org/certs/lets-encrypt-x2-cross-signed.pem > /etc/ssl/certs/lets-encrypt-x2-cross-signed.pem
# Start-mailserver script
ADD target/bin/generate-ssl-certificate target/bin/generate-dkim-config target/start-mailserver.sh /usr/local/bin/
ADD target/bin/generate-ssl-certificate target/bin/generate-dkim-config target/bin/addmailuser target/bin/delmailuser target/start-mailserver.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/*
EXPOSE 25 587 143 993 110 995 4190

29
target/bin/addmailuser Executable file

@ -0,0 +1,29 @@
#!/bin/bash
DATABASE=/tmp/docker-mailserver/postfix-accounts.cf
function usage {
echo Usage: addmailuser <user@domain.tld> [password]
exit 1
}
if [ ! -z "$1" ]; then
USER=$1
if [ ! -z "$(grep $USER -i $DATABASE)" ]; then
echo "User already exists"
exit 1
fi
if [ ! -z "$2" ]; then
PASS=$2
else
read -s -p "Enter Password: " PASS
if [ -z "$PASS" ]; then
echo "Password can't be empty"
exit 1
fi
fi
ENTRY=$(echo "$USER|$(doveadm pw -s SHA512-CRYPT -u $USER -p $PASS)")
echo "$ENTRY" >> $DATABASE
else
usage
fi

16
target/bin/delmailuser Executable file

@ -0,0 +1,16 @@
#!/bin/bash
DATABASE=/tmp/docker-mailserver/postfix-accounts.cf
function usage {
echo "Usage: delmailuser <user@domain.tld>"
exit 1
}
if [ ! -z "$1" ]; then
USER=$1
ENTRIES=$(grep "$USER" -vi $DATABASE)
echo "$ENTRIES" > $DATABASE
else
usage
fi

@ -466,3 +466,23 @@
run docker exec mail_pop3 /bin/bash -c "nc -z 0.0.0.0 4190"
[ "$status" -ne 0 ]
}
#
# accounts
#
@test "checking accounts: user3 should have been added to /tmp/docker-mailserver/postfix-accounts.cf" {
docker exec mail /bin/sh -c "addmailuser user3@domain.tld mypassword"
run docker exec mail /bin/sh -c "grep user3@domain.tld -i /tmp/docker-mailserver/postfix-accounts.cf"
[ "$status" -eq 0 ]
[ ! -z "$output" ]
}
@test "checking accounts: user3 should have been removed from /tmp/docker-mailserver/postfix-accounts.cf" {
docker exec mail /bin/sh -c "delmailuser user3@domain.tld"
run docker exec mail /bin/sh -c "grep user3@domain.tld -i /tmp/docker-mailserver/postfix-accounts.cf"
[ "$status" -eq 1 ]
[ -z "$output" ]
}