mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
scripts: Improve error handling, when parameters are missing (#2854)
This commit is contained in:
parent
caf2338201
commit
897d84f0f9
|
@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file. The format
|
|||
|
||||
### Fixed
|
||||
|
||||
- **scripts**: Improve error handling, when parameters are missing ([#2854](https://github.com/docker-mailserver/docker-mailserver/pull/2854))
|
||||
- **scripts**: Fix unbound variable error ([#2849](https://github.com/docker-mailserver/docker-mailserver/pull/2849), [#2853](https://github.com/docker-mailserver/docker-mailserver/pull/2853))
|
||||
- **scripts**: Make fetchmail data persistant ([#2851](https://github.com/docker-mailserver/docker-mailserver/pull/2851))
|
||||
- **scripts**: Run `user-patches.sh` right before starting daemons ([#2817](https://github.com/docker-mailserver/docker-mailserver/pull/2817))
|
||||
|
|
|
@ -5,7 +5,7 @@ source /usr/local/bin/helpers/index.sh
|
|||
|
||||
function _main
|
||||
{
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
_require_n_parameters_or_print_usage 2 "${@}"
|
||||
|
||||
local MAIL_ALIAS="${1}"
|
||||
local RECIPIENT="${2}"
|
||||
|
|
|
@ -5,7 +5,7 @@ source /usr/local/bin/helpers/index.sh
|
|||
|
||||
function _main
|
||||
{
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
_require_n_parameters_or_print_usage 1 "${@}"
|
||||
|
||||
local MAIL_ACCOUNT="${1}"
|
||||
shift
|
||||
|
|
|
@ -5,7 +5,7 @@ source /usr/local/bin/helpers/index.sh
|
|||
|
||||
function _main
|
||||
{
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
_require_n_parameters_or_print_usage 1 "${@}"
|
||||
|
||||
local MAIL_ACCOUNT="${1}"
|
||||
shift
|
||||
|
|
|
@ -5,7 +5,7 @@ source /usr/local/bin/helpers/index.sh
|
|||
|
||||
function _main
|
||||
{
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
_require_n_parameters_or_print_usage 2 "${@}"
|
||||
|
||||
local DOMAIN="${1}"
|
||||
local HOST="${2}"
|
||||
|
|
|
@ -5,7 +5,7 @@ source /usr/local/bin/helpers/index.sh
|
|||
|
||||
function _main
|
||||
{
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
_require_n_parameters_or_print_usage 2 "${@}"
|
||||
|
||||
local DOMAIN="${1}"
|
||||
local RELAY_ACCOUNT="${2}"
|
||||
|
|
|
@ -5,7 +5,7 @@ source /usr/local/bin/helpers/index.sh
|
|||
|
||||
function _main
|
||||
{
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
_require_n_parameters_or_print_usage 2 "${@}"
|
||||
|
||||
local MAIL_ALIAS="${1}"
|
||||
local RECIPIENT="${2}"
|
||||
|
|
|
@ -5,10 +5,7 @@ source /usr/local/bin/helpers/index.sh
|
|||
|
||||
function _main
|
||||
{
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
|
||||
# Validate Parameters:
|
||||
[[ -z ${*} ]] && { __usage ; _exit_with_error 'No account specified' ; }
|
||||
_require_n_parameters_or_print_usage 1 "${@}"
|
||||
|
||||
# Actual command to perform:
|
||||
for MAIL_ACCOUNT in "${@}"
|
||||
|
|
|
@ -5,12 +5,11 @@ source /usr/local/bin/helpers/index.sh
|
|||
|
||||
function _main
|
||||
{
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
_require_n_parameters_or_print_usage 1 "${@}"
|
||||
|
||||
# Tests expect early exit without error if no DB exists:
|
||||
[[ -s ${DATABASE_ACCOUNTS} ]] || return 0
|
||||
|
||||
# Validate Parameters:
|
||||
[[ -z ${*} ]] && { __usage ; _exit_with_error 'No account specified' ; }
|
||||
_maildel_request_if_missing
|
||||
|
||||
# TODO: May want to lock all database files prior to loop? (DATABASE_ACCOUNTS DATABASE_QUOTA DATABASE_VIRTUAL)
|
||||
|
|
|
@ -5,7 +5,7 @@ source /usr/local/bin/helpers/index.sh
|
|||
|
||||
function _main
|
||||
{
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
_require_n_parameters_or_print_usage 1 "${@}"
|
||||
|
||||
local MAIL_ACCOUNT="${1}"
|
||||
|
||||
|
|
|
@ -5,10 +5,9 @@ source /usr/local/bin/helpers/index.sh
|
|||
|
||||
function _main
|
||||
{
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
_require_n_parameters_or_print_usage 1 "${@}"
|
||||
|
||||
local DOMAIN="${1}"
|
||||
[[ -z ${DOMAIN} ]] && { __usage ; _exit_with_error 'No domain specified' ; }
|
||||
|
||||
_exclude_domain_from_relayhosts
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ ${ORANGE}EXIT STATUS${RESET}
|
|||
"
|
||||
}
|
||||
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
_require_n_parameters_or_print_usage 0 "${@}"
|
||||
|
||||
while [[ ${#} -gt 0 ]]
|
||||
do
|
||||
|
|
|
@ -5,7 +5,7 @@ source /usr/local/bin/helpers/index.sh
|
|||
|
||||
function _main
|
||||
{
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
_require_n_parameters_or_print_usage 1 "${@}"
|
||||
|
||||
local MAIL_ACCOUNT="${1}"
|
||||
shift
|
||||
|
|
|
@ -5,7 +5,7 @@ source /usr/local/bin/helpers/index.sh
|
|||
|
||||
function _main
|
||||
{
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
_require_n_parameters_or_print_usage 1 "${@}"
|
||||
|
||||
local MAIL_ACCOUNT="${1}"
|
||||
shift
|
||||
|
|
|
@ -5,7 +5,7 @@ source /usr/local/bin/helpers/index.sh
|
|||
|
||||
function _main
|
||||
{
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
_require_n_parameters_or_print_usage 1 "${@}"
|
||||
|
||||
local MAIL_ACCOUNT="${1}"
|
||||
shift
|
||||
|
|
|
@ -34,3 +34,13 @@ function _chown_var_mail_if_necessary
|
|||
chown -R 5000:5000 /var/mail || return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function _require_n_parameters_or_print_usage
|
||||
{
|
||||
local COUNT
|
||||
COUNT=${1}
|
||||
shift
|
||||
|
||||
[[ ${1:-} == 'help' ]] && { __usage ; exit 0 ; }
|
||||
[[ ${#} -lt ${COUNT} ]] && { __usage ; exit 1 ; }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue