2021-01-11 20:25:30 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Example script for dovecot mail-crypt-plugin
|
|
|
|
# https://doc.dovecot.org/configuration_manual/mail_crypt_plugin/
|
|
|
|
|
2021-06-04 15:48:41 +02:00
|
|
|
IFS= read -r -d $'\0' OLD_PASSWORD
|
|
|
|
IFS= read -r -d $'\0' NEW_PASSWORD
|
|
|
|
|
2021-01-11 20:25:30 +01:00
|
|
|
# New user
|
2021-06-04 15:48:41 +02:00
|
|
|
if [ -z "$OLD_PASSWORD" ]; then
|
|
|
|
OLD_PASSWORD="$(openssl rand -hex 16)"
|
|
|
|
doveadm -o plugin/mail_crypt_private_password="$OLD_PASSWORD" mailbox cryptokey generate -u "$1" -U
|
2021-01-11 20:25:30 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Password change
|
2021-06-04 15:48:41 +02:00
|
|
|
printf "%s\n%s\n" "$OLD_PASSWORD" "$NEW_PASSWORD" | doveadm mailbox cryptokey password -u "$1" -N -O ""
|