mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-03 01:24:52 +02:00
Script to update users password, made test and updated setup.sh (#413)
* Added script to update users password, made test and updated setup.sh * Moved update password test to tests.bat * Fixed test for update password
This commit is contained in:
parent
68e7e46308
commit
83c0095e00
3 changed files with 66 additions and 0 deletions
29
target/bin/updatemailuser
Executable file
29
target/bin/updatemailuser
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
|
||||
DATABASE=/tmp/docker-mailserver/postfix-accounts.cf
|
||||
|
||||
function usage {
|
||||
echo 'Usage: updatemailuser <user@domain.tld> [password]'
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ ! -z "$1" ]; then
|
||||
USER=$1
|
||||
if [ -e "$DATABASE" ] && [ -z "$(grep $USER -i $DATABASE)" ]; then
|
||||
echo "User doesn't exist"
|
||||
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")")
|
||||
sed -i.bak "s%^$USER.*%$ENTRY%g" $DATABASE
|
||||
else
|
||||
usage
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue