Skip to content

Commit

Permalink
docker/add-user.sh: Don't crash on updating when there is a single user
Browse files Browse the repository at this point in the history
When a single dovecot user exists and their password is being updated via
docker/add-user.sh, the `grep -v` command intended to remove the user's
old password will not match any lines and exit with error code 1, causing
the entire script to fail.

This patch fixes it by replacing the if-grep logic with a simpler sed
invocation.

#43

Amended-by: Alberto Bertogli <[email protected]>
  Minor edits to the commit message.
  • Loading branch information
erjoalgo authored and albertito committed Oct 29, 2023
1 parent 0ce84a3 commit a0f0930
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 @@ -34,11 +34,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 --in-place=.old "/^${EMAIL}:/d" /data/dovecot/users

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

0 comments on commit a0f0930

Please sign in to comment.