2016-12-30 19:06:44 +00:00
|
|
|
#! /bin/bash
|
2016-08-29 11:44:36 +00:00
|
|
|
|
2016-12-30 19:06:44 +00:00
|
|
|
DATABASE=${DATABASE:-/tmp/docker-mailserver/postfix-accounts.cf}
|
2016-08-29 11:44:36 +00:00
|
|
|
|
2016-12-30 19:06:44 +00:00
|
|
|
errex() {
|
|
|
|
echo "$@" 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
2016-08-29 11:44:36 +00:00
|
|
|
|
2016-12-30 19:06:44 +00:00
|
|
|
[ -f $DATABASE ] || errex "No postfix-accounts.cf file"
|
|
|
|
[ -s $DATABASE ] || errex "Empty postfix-accounts.cf - no users have been added"
|
2016-08-29 11:44:36 +00:00
|
|
|
|
2019-08-01 17:39:25 +00:00
|
|
|
# Lock database even though we are only reading
|
|
|
|
(
|
|
|
|
flock -e 200
|
2020-05-06 17:26:47 +00:00
|
|
|
(grep -v "^\s*$\|^\s*\#" "$DATABASE" || true) | awk -F '|' '{ print $1; }'
|
2019-08-01 17:39:25 +00:00
|
|
|
) 200<$DATABASE
|
|
|
|
|