mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-18 14:47:03 +00:00
docker/add-user.sh: Don't crash on updating when there is a single user
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. https://github.com/albertito/chasquid/pull/43 Amended-by: Alberto Bertogli <albertito@blitiri.com.ar> Minor edits to the commit message.
This commit is contained in:
committed by
Alberto Bertogli
parent
0ce84a3b5d
commit
a0f09308ed
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user