Skip to content

Commit

Permalink
Fix failing when the sole dovecot user is updated.
Browse files Browse the repository at this point in the history
When a single dovecot user exists and their password is updated,
the `grep -v` command intended to remove the user's old password
will not match any lines and fail, causing the entire script to fail.
  • Loading branch information
erjoalgo committed Oct 29, 2023
1 parent a4d7e8f commit b556f70
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions docker/add-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ ENCPASS=$(doveadm pw -u "${EMAIL}" -p "${PASSWORD}")
# Edit dovecot users: remove user if it exits.
mkdir -p /data/dovecot
touch /data/dovecot/users
if grep -q "^${EMAIL}:" /data/dovecot/users; then
cp /data/dovecot/users /data/dovecot/users.old
grep -v "^${EMAIL}:" /data/dovecot/users.old \
> /data/dovecot/users
fi
sed -i "/^${EMAIL}/d" /data/dovecot/users

# Edit dovecot users: add user.
echo "${EMAIL}:${ENCPASS}::::" >> /data/dovecot/users
Expand Down

0 comments on commit b556f70

Please sign in to comment.