refactoring: split helper functions into smaller scripts (#2420)

This commit is contained in:
Georg Lauterbach 2022-02-21 11:56:57 +01:00 committed by GitHub
parent 2927cc47c7
commit b61dfe1e24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 389 additions and 396 deletions

View file

@ -5,8 +5,8 @@
# ? the same file in the same pipeline", which is a result of ${DATABASE}
# ? being used below. (This disables the message file-wide.)
# shellcheck source=../scripts/helper-functions.sh
. /usr/local/bin/helper-functions.sh
# shellcheck source=../scripts/helpers/index.sh
source /usr/local/bin/helpers/index.sh
DATABASE=${DATABASE:-/tmp/docker-mailserver/postfix-accounts.cf}
ALIAS_DATABASE="/tmp/docker-mailserver/postfix-virtual.cf"
@ -67,14 +67,14 @@ do
* )
__usage
errex "The option ${OPT} is unknown."
_errex "The option ${OPT} is unknown."
;;
esac
done
shift $((OPTIND-1))
[[ -z ${*} ]] && { __usage ; errex "No user specifed" ; }
[[ -z ${*} ]] && { __usage ; _errex "No user specifed" ; }
[[ -s ${DATABASE} ]] || exit 0
if ! ${MAILDEL}
@ -86,7 +86,7 @@ then
fi
fi
create_lock # Protect config file with lock to avoid race conditions
_create_lock # Protect config file with lock to avoid race conditions
for EMAIL in "${@}"
do
@ -97,7 +97,7 @@ do
# ${EMAIL} must not contain /s and other syntactic characters
UNESCAPED_EMAIL="${EMAIL}"
EMAIL=$(escape "${EMAIL}")
EMAIL=$(_escape "${EMAIL}")
if [[ -f ${DATABASE} ]]
then
@ -155,6 +155,6 @@ use 'sudo docker exec mailserver rm -R /var/mail/${DOMAIN}/${USER}'"
ERROR=true
fi
${ERROR} && errex 'See the messages above.'
${ERROR} && _errex 'See the messages above.'
done
exit 0