mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
basic user management
This commit is contained in:
parent
a267af5efe
commit
3b2ae0f1c8
29
target/addmailuser
Executable file
29
target/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
|
15
target/delmailuser
Executable file
15
target/delmailuser
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
DATABASE=/tmp/docker-mailserver/postfix-accounts.cf
|
||||
|
||||
function usage {
|
||||
echo Usage: delmailuser <user@domain.tld>
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ ! -z "$1" ]; then
|
||||
ENTRIES=$(grep "$USER" -vi $DATABASE)
|
||||
echo $ENTRIES > $DATABASE
|
||||
else
|
||||
usage
|
||||
fi
|
Loading…
Reference in a new issue