move addmailuser, delmailuser to target/bin

This commit is contained in:
shim_ 2016-06-15 19:50:01 +02:00
parent 7c63d00d77
commit 94679df291
3 changed files with 1 additions and 1 deletions

29
target/bin/addmailuser Executable file
View 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