2020-11-06 13:04:23 +00:00
|
|
|
|
#! /bin/bash
|
2016-08-28 19:10:25 +00:00
|
|
|
|
|
2021-02-18 09:29:34 +00:00
|
|
|
|
# version v0.2.5 stable
|
2021-01-16 09:16:05 +00:00
|
|
|
|
# executed manually (via Make)
|
|
|
|
|
# task wrapper for various setup scripts
|
2016-09-01 10:10:23 +00:00
|
|
|
|
|
2020-12-22 17:09:03 +00:00
|
|
|
|
SCRIPT='setup.sh'
|
2020-10-04 17:34:15 +00:00
|
|
|
|
|
2020-09-04 06:42:12 +00:00
|
|
|
|
set -euEo pipefail
|
2021-01-28 13:50:28 +00:00
|
|
|
|
trap '__log_err ${FUNCNAME[0]:-"?"} ${BASH_COMMAND:-"?"} ${LINENO:-"?"} ${?:-"?"}' ERR
|
2020-10-21 16:16:32 +00:00
|
|
|
|
trap '_unset_vars || :' EXIT
|
2019-11-22 14:42:25 +00:00
|
|
|
|
|
2020-10-04 17:34:15 +00:00
|
|
|
|
function __log_err
|
2020-09-04 06:42:12 +00:00
|
|
|
|
{
|
2020-10-04 17:34:15 +00:00
|
|
|
|
printf "\n––– \e[1m\e[31mUNCHECKED ERROR\e[0m\n%s\n%s\n%s\n%s\n\n" \
|
2020-12-22 17:09:03 +00:00
|
|
|
|
" – script = ${SCRIPT:-${0}}" \
|
2021-01-16 09:16:05 +00:00
|
|
|
|
" – function = ${1} / ${2}" \
|
|
|
|
|
" – line = ${3}" \
|
|
|
|
|
" – exit code = ${4}" >&2
|
2021-02-19 09:29:26 +00:00
|
|
|
|
|
|
|
|
|
printf "Make sure you use a version of this script that matches
|
|
|
|
|
the version / tag of docker-mailserver. Please read the
|
|
|
|
|
'Get the tools' section in the README on GitHub carefully.\n" >&2
|
2019-11-22 14:42:25 +00:00
|
|
|
|
}
|
2019-11-22 15:10:42 +00:00
|
|
|
|
|
2020-09-26 13:11:52 +00:00
|
|
|
|
function _unset_vars
|
2020-09-04 06:42:12 +00:00
|
|
|
|
{
|
|
|
|
|
unset CDIR CRI INFO IMAGE_NAME CONTAINER_NAME DEFAULT_CONFIG_PATH
|
|
|
|
|
unset USE_CONTAINER WISHED_CONFIG_PATH CONFIG_PATH VOLUME USE_TTY
|
2020-10-30 15:43:31 +00:00
|
|
|
|
unset SCRIPT USING_SELINUX
|
2020-09-04 06:42:12 +00:00
|
|
|
|
}
|
2016-09-01 10:10:23 +00:00
|
|
|
|
|
2020-09-26 13:11:52 +00:00
|
|
|
|
function _get_current_directory
|
2020-09-06 10:27:40 +00:00
|
|
|
|
{
|
|
|
|
|
if dirname "$(readlink -f "${0}")" &>/dev/null
|
|
|
|
|
then
|
2020-12-22 17:09:03 +00:00
|
|
|
|
CDIR="$(dirname "$(readlink -f "${0}")")"
|
2020-09-06 10:27:40 +00:00
|
|
|
|
elif realpath -e -L "${0}" &>/dev/null
|
|
|
|
|
then
|
|
|
|
|
CDIR="$(realpath -e -L "${0}")"
|
|
|
|
|
CDIR="${CDIR%/setup.sh}"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-08 17:49:19 +00:00
|
|
|
|
CDIR="$(pwd)"
|
|
|
|
|
_get_current_directory
|
|
|
|
|
|
2020-09-04 06:42:12 +00:00
|
|
|
|
CRI=
|
|
|
|
|
INFO=
|
|
|
|
|
IMAGE_NAME=
|
2021-01-27 17:42:31 +00:00
|
|
|
|
CONTAINER_NAME=
|
2020-09-06 10:27:40 +00:00
|
|
|
|
DEFAULT_CONFIG_PATH="${CDIR}/config"
|
2019-07-28 12:33:52 +00:00
|
|
|
|
USE_CONTAINER=false
|
2020-09-04 06:42:12 +00:00
|
|
|
|
WISHED_CONFIG_PATH=
|
|
|
|
|
CONFIG_PATH=
|
|
|
|
|
VOLUME=
|
|
|
|
|
USE_TTY=
|
2020-10-30 15:43:31 +00:00
|
|
|
|
USING_SELINUX=
|
2020-09-04 06:42:12 +00:00
|
|
|
|
|
2020-09-26 13:11:52 +00:00
|
|
|
|
function _check_root
|
2020-09-04 06:42:12 +00:00
|
|
|
|
{
|
2020-09-06 10:27:40 +00:00
|
|
|
|
if [[ ${EUID} -ne 0 ]]
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
|
|
|
|
echo "Curently docker-mailserver doesn't support podman's rootless mode, please run this script as root user."
|
2021-01-16 09:16:05 +00:00
|
|
|
|
exit 1
|
2020-09-04 06:42:12 +00:00
|
|
|
|
fi
|
|
|
|
|
}
|
2018-04-28 08:27:42 +00:00
|
|
|
|
|
2020-09-26 13:11:52 +00:00
|
|
|
|
function _update_config_path
|
2020-09-04 06:42:12 +00:00
|
|
|
|
{
|
2020-09-06 10:27:40 +00:00
|
|
|
|
if [[ -n ${CONTAINER_NAME} ]]
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
2020-09-09 20:36:00 +00:00
|
|
|
|
VOLUME=$(${CRI} inspect "${CONTAINER_NAME}" \
|
2019-12-22 08:37:58 +00:00
|
|
|
|
--format="{{range .Mounts}}{{ println .Source .Destination}}{{end}}" | \
|
|
|
|
|
grep "/tmp/docker-mailserver$" 2>/dev/null)
|
|
|
|
|
fi
|
2018-04-28 08:27:42 +00:00
|
|
|
|
|
2020-09-06 10:27:40 +00:00
|
|
|
|
if [[ -n ${VOLUME} ]]
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
2020-09-06 10:27:40 +00:00
|
|
|
|
CONFIG_PATH=$(echo "${VOLUME}" | awk '{print $1}')
|
2018-04-28 08:27:42 +00:00
|
|
|
|
fi
|
|
|
|
|
}
|
2016-08-28 19:10:25 +00:00
|
|
|
|
|
2020-09-26 13:11:52 +00:00
|
|
|
|
function _inspect
|
2020-09-04 06:42:12 +00:00
|
|
|
|
{
|
2020-09-06 10:27:40 +00:00
|
|
|
|
if _docker_image_exists "${IMAGE_NAME}"
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
2020-09-06 10:27:40 +00:00
|
|
|
|
echo "Image: ${IMAGE_NAME}"
|
2016-09-01 10:10:23 +00:00
|
|
|
|
else
|
2020-09-06 10:27:40 +00:00
|
|
|
|
echo "Image: '${IMAGE_NAME}' can’t be found."
|
2016-09-01 10:10:23 +00:00
|
|
|
|
fi
|
2020-09-04 06:42:12 +00:00
|
|
|
|
|
2020-09-06 10:27:40 +00:00
|
|
|
|
if [[ -n ${CONTAINER_NAME} ]]
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
2020-09-06 10:27:40 +00:00
|
|
|
|
echo "Container: ${CONTAINER_NAME}"
|
|
|
|
|
echo "Config mount: ${CONFIG_PATH}"
|
2016-09-01 10:10:23 +00:00
|
|
|
|
else
|
|
|
|
|
echo "Container: Not running, please start docker-mailserver."
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-26 13:11:52 +00:00
|
|
|
|
function _usage
|
2020-09-04 06:42:12 +00:00
|
|
|
|
{
|
2021-02-18 10:09:29 +00:00
|
|
|
|
# shellcheck disable=SC2059
|
|
|
|
|
printf "\e[35mSETUP\e[31m(\e[93m1\e[31m)
|
|
|
|
|
|
|
|
|
|
\e[38;5;214mNAME\e[39m
|
|
|
|
|
${SCRIPT:-${0}} - docker-mailserver administration script
|
|
|
|
|
|
|
|
|
|
\e[38;5;214mSYNOPSIS\e[39m
|
|
|
|
|
./${SCRIPT:-${0}} [ OPTIONS\e[31m...\e[39m ] COMMAND [ help \e[31m|\e[39m ARGUMENTS\e[31m...\e[39m ]
|
|
|
|
|
|
|
|
|
|
COMMAND \e[31m:=\e[39m { email \e[31m|\e[39m alias \e[31m|\e[39m quota \e[31m|\e[39m config \e[31m|\e[39m relay \e[31m|\e[39m debug } SUBCOMMAND
|
|
|
|
|
|
|
|
|
|
\e[38;5;214mDESCRIPTION\e[39m
|
|
|
|
|
This is the main administration script that you use for all interactions with your
|
|
|
|
|
mail server. Setup, configuration and much more is done with this script.
|
|
|
|
|
|
|
|
|
|
Please note that the script executes most of the commands inside the container itself.
|
|
|
|
|
If the image was not found, this script will pull the \e[37m:latest\e[39m tag of
|
|
|
|
|
\e[37mmailserver/docker-mailserver\e[39m. This tag refers to the latest release,
|
|
|
|
|
see the tagging convention in the README under
|
|
|
|
|
\e[34mhttps://github.com/docker-mailserver/docker-mailserver/blob/master/README.md\e[39m
|
|
|
|
|
|
|
|
|
|
You will be able to see detailed information about the script you're invoking and
|
|
|
|
|
its arguments by appending \e[37mhelp\e[39m after your command. Currently, this
|
|
|
|
|
does not work with all scripts.
|
|
|
|
|
|
2021-02-19 09:29:26 +00:00
|
|
|
|
\e[38;5;214mVERSION\e[39m
|
|
|
|
|
The current version of this script is backwards compatible with versions of
|
|
|
|
|
\e[37mdocker-mailserver\e[39m \e[1mafter\e[0m \e[34m8.0.1\e[0m. In case that there is not a more recent release,
|
|
|
|
|
this script is currently only working with the \e[37m:edge\e[0m tag.
|
|
|
|
|
|
|
|
|
|
You can download the script for your release by substituting TAG from the
|
|
|
|
|
following URL, where TAG looks like 'vX.X.X':
|
|
|
|
|
https://raw.githubusercontent.com/docker-mailserver/docker-mailserver/TAG/setup.sh
|
|
|
|
|
|
2021-02-18 10:09:29 +00:00
|
|
|
|
\e[38;5;214mOPTIONS\e[39m
|
|
|
|
|
\e[94mConfig path, container or image adjustments\e[39m
|
|
|
|
|
-i IMAGE_NAME
|
|
|
|
|
Provides the name of the docker-mailserver image. The default value is
|
|
|
|
|
\e[37mdocker.io/mailserver/docker-mailserver:latest\e[39m
|
|
|
|
|
|
|
|
|
|
-c CONTAINER_NAME
|
|
|
|
|
Provides the name of the running container.
|
|
|
|
|
|
|
|
|
|
-p PATH
|
|
|
|
|
Provides the config folder path. The default is
|
|
|
|
|
\e[37m${CDIR}/config/\e[39m
|
|
|
|
|
|
|
|
|
|
\e[94mSELinux\e[39m
|
|
|
|
|
-z
|
|
|
|
|
Allows container access to the bind mount content that is shared among
|
|
|
|
|
multiple containers on a SELinux-enabled host.
|
|
|
|
|
|
|
|
|
|
-Z
|
|
|
|
|
Allows container access to the bind mount content that is private and
|
|
|
|
|
unshared with other containers on a SELinux-enabled host.
|
|
|
|
|
|
|
|
|
|
\e[94mOthers\e[39m
|
|
|
|
|
-h \e[31m|\e[39m help
|
|
|
|
|
Shows this help dialogue.
|
|
|
|
|
|
|
|
|
|
\e[31m[\e[38;5;214mSUB\e[31m]\e[38;5;214mCOMMANDS\e[39m
|
|
|
|
|
\e[94mCOMMAND\e[39m email \e[31m:=\e[39m
|
|
|
|
|
${0} email add <EMAIL ADDRESS> [<PASSWORD>]
|
|
|
|
|
${0} email update <EMAIL ADDRESS> [<PASSWORD>]
|
|
|
|
|
${0} email del [ OPTIONS\e[31m...\e[39m ] <EMAIL ADDRESS>
|
|
|
|
|
${0} email restrict <add\e[31m|\e[39mdel\e[31m|\e[39mlist> <send\e[31m|\e[39mreceive> [<EMAIL ADDRESS>]
|
|
|
|
|
${0} email list
|
|
|
|
|
|
|
|
|
|
\e[94mCOMMAND\e[39m alias \e[31m:=\e[39m
|
|
|
|
|
${0} alias add <EMAIL ADDRESS> <RECIPIENT>
|
|
|
|
|
${0} alias del <EMAIL ADDRESS> <RECIPIENT>
|
|
|
|
|
${0} alias list
|
|
|
|
|
|
|
|
|
|
\e[94mCOMMAND\e[39m quota \e[31m:=\e[39m
|
|
|
|
|
${0} quota set <EMAIL ADDRESS> [<QUOTA>]
|
|
|
|
|
${0} quota del <EMAIL ADDRESS>
|
|
|
|
|
|
|
|
|
|
\e[94mCOMMAND\e[39m config \e[31m:=\e[39m
|
|
|
|
|
${0} config dkim [ ARGUMENTS\e[31m...\e[39m ]
|
|
|
|
|
${0} config ssl <FQDN> (\e[96mATTENTION\e[39m: This is deprecated and will be removed soon.)
|
|
|
|
|
|
|
|
|
|
\e[94mCOMMAND\e[39m relay \e[31m:=\e[39m
|
|
|
|
|
${0} relay add-domain <DOMAIN> <HOST> [<PORT>]
|
|
|
|
|
${0} relay add-auth <DOMAIN> <USERNAME> [<PASSWORD>]
|
|
|
|
|
${0} relay exclude-domain <DOMAIN>
|
|
|
|
|
|
|
|
|
|
\e[94mCOMMAND\e[39m debug \e[31m:=\e[39m
|
|
|
|
|
${0} debug fetchmail
|
|
|
|
|
${0} debug fail2ban [unban <IP>]
|
|
|
|
|
${0} debug show-mail-logs
|
|
|
|
|
${0} debug inspect
|
|
|
|
|
${0} debug login <COMMANDS>
|
|
|
|
|
|
|
|
|
|
\e[38;5;214mEXAMPLES\e[39m
|
|
|
|
|
\e[37m./setup.sh email add test@domain.tld\e[39m
|
|
|
|
|
Add the email account \e[37mtest@domain.tld\e[39m. You will be prompted
|
|
|
|
|
to input a password afterwards since no password was supplied.
|
|
|
|
|
|
|
|
|
|
\e[37m./setup.sh config dkim size 2048 domain 'whoami.com,whoareyou.org'\e[39m
|
|
|
|
|
Creates keys of length 2048 but in an LDAP setup where domains are not known to
|
|
|
|
|
Postfix by default, so you need to provide them yourself in a comma-separated list.
|
|
|
|
|
|
|
|
|
|
\e[37m./setup.sh config dkim help\e[39m
|
|
|
|
|
This will provide you with a detailed explanation on how to use the \e[37m
|
|
|
|
|
config dkim\e[39m command, showing what arguments can be passed and what they do.
|
|
|
|
|
|
|
|
|
|
\e[38;5;214mEXIT STATUS\e[39m
|
|
|
|
|
Exit status is 0 if the command was successful. If there was an unexpected error, an error
|
|
|
|
|
message is shown describing the error. In case of an error, the script will exit with exit
|
|
|
|
|
status 1.
|
2020-10-06 12:45:55 +00:00
|
|
|
|
|
2020-09-06 10:27:40 +00:00
|
|
|
|
"
|
2016-08-28 19:10:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-26 13:11:52 +00:00
|
|
|
|
function _docker_image_exists
|
2020-09-04 06:42:12 +00:00
|
|
|
|
{
|
2021-01-16 09:16:05 +00:00
|
|
|
|
${CRI} history -q "${1}" &>/dev/null
|
|
|
|
|
return ${?}
|
2016-09-01 10:10:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-26 13:11:52 +00:00
|
|
|
|
function _docker_image
|
2020-09-04 06:42:12 +00:00
|
|
|
|
{
|
2020-09-06 10:27:40 +00:00
|
|
|
|
if ${USE_CONTAINER}
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
|
|
|
|
# reuse existing container specified on command line
|
2020-09-06 10:27:40 +00:00
|
|
|
|
${CRI} exec "${USE_TTY}" "${CONTAINER_NAME}" "${@}"
|
2019-07-28 12:33:52 +00:00
|
|
|
|
else
|
2020-09-04 06:42:12 +00:00
|
|
|
|
# start temporary container with specified image
|
2020-09-06 10:27:40 +00:00
|
|
|
|
if ! _docker_image_exists "${IMAGE_NAME}"
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
2020-09-06 10:27:40 +00:00
|
|
|
|
echo "Image '${IMAGE_NAME}' not found. Pulling ..."
|
|
|
|
|
${CRI} pull "${IMAGE_NAME}"
|
2019-07-28 12:33:52 +00:00
|
|
|
|
fi
|
|
|
|
|
|
2020-09-04 06:42:12 +00:00
|
|
|
|
${CRI} run --rm \
|
2021-02-17 11:12:51 +00:00
|
|
|
|
-v "${CONFIG_PATH}:/tmp/docker-mailserver${USING_SELINUX}" \
|
2020-09-06 10:27:40 +00:00
|
|
|
|
"${USE_TTY}" "${IMAGE_NAME}" "${@}"
|
2019-07-28 12:33:52 +00:00
|
|
|
|
fi
|
2016-08-28 19:10:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-26 13:11:52 +00:00
|
|
|
|
function _docker_container
|
2020-09-04 06:42:12 +00:00
|
|
|
|
{
|
2020-09-06 10:27:40 +00:00
|
|
|
|
if [[ -n ${CONTAINER_NAME} ]]
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
2020-09-06 10:27:40 +00:00
|
|
|
|
${CRI} exec "${USE_TTY}" "${CONTAINER_NAME}" "${@}"
|
2016-09-01 10:10:23 +00:00
|
|
|
|
else
|
2021-01-16 09:16:05 +00:00
|
|
|
|
echo "The mailserver is not running!"
|
|
|
|
|
exit 1
|
2016-09-01 10:10:23 +00:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-26 13:11:52 +00:00
|
|
|
|
function _main
|
2020-09-04 06:42:12 +00:00
|
|
|
|
{
|
2021-01-16 09:16:05 +00:00
|
|
|
|
if command -v docker &>/dev/null
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
|
|
|
|
CRI=docker
|
2021-01-16 09:16:05 +00:00
|
|
|
|
elif command -v podman &>/dev/null
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
|
|
|
|
CRI=podman
|
|
|
|
|
_check_root
|
|
|
|
|
else
|
|
|
|
|
echo "No supported Container Runtime Interface detected."
|
2020-09-05 14:19:12 +00:00
|
|
|
|
exit 10
|
2018-04-28 08:27:42 +00:00
|
|
|
|
fi
|
|
|
|
|
|
2021-01-16 09:16:05 +00:00
|
|
|
|
INFO=$(${CRI} ps --no-trunc --format "{{.Image}};{{.Names}}" --filter \
|
|
|
|
|
label=org.opencontainers.image.title="docker-mailserver" | tail -1)
|
2020-09-04 06:42:12 +00:00
|
|
|
|
|
|
|
|
|
IMAGE_NAME=${INFO%;*}
|
|
|
|
|
CONTAINER_NAME=${INFO#*;}
|
|
|
|
|
|
2020-09-06 10:27:40 +00:00
|
|
|
|
if [[ -z ${IMAGE_NAME} ]]
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
2021-01-18 19:51:56 +00:00
|
|
|
|
IMAGE_NAME=${NAME:-docker.io/mailserver/docker-mailserver:latest}
|
2020-09-04 06:42:12 +00:00
|
|
|
|
fi
|
2016-09-01 10:10:23 +00:00
|
|
|
|
|
2021-01-16 09:16:05 +00:00
|
|
|
|
if test -t 0
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
|
|
|
|
USE_TTY="-ti"
|
2021-01-16 09:16:05 +00:00
|
|
|
|
else
|
|
|
|
|
# GitHub Actions will fail (or really anything else
|
|
|
|
|
# lacking an interactive tty) if we don't set a
|
|
|
|
|
# value here; "-t" alone works for these cases.
|
|
|
|
|
USE_TTY="-t"
|
2020-09-04 06:42:12 +00:00
|
|
|
|
fi
|
2016-08-28 19:10:25 +00:00
|
|
|
|
|
2020-09-04 06:42:12 +00:00
|
|
|
|
local OPTIND
|
2020-10-30 15:43:31 +00:00
|
|
|
|
while getopts ":c:i:p:hzZ" OPT
|
2020-09-04 06:42:12 +00:00
|
|
|
|
do
|
2020-09-06 10:27:40 +00:00
|
|
|
|
case ${OPT} in
|
2020-11-06 13:04:23 +00:00
|
|
|
|
i ) IMAGE_NAME="${OPTARG}" ;;
|
|
|
|
|
z ) USING_SELINUX=":z" ;;
|
|
|
|
|
Z ) USING_SELINUX=":Z" ;;
|
|
|
|
|
c )
|
|
|
|
|
# container specified, connect to running instance
|
|
|
|
|
CONTAINER_NAME="${OPTARG}"
|
|
|
|
|
USE_CONTAINER=true
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
h )
|
|
|
|
|
_usage
|
|
|
|
|
return
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
p )
|
2020-09-06 10:27:40 +00:00
|
|
|
|
case "${OPTARG}" in
|
2020-11-06 13:04:23 +00:00
|
|
|
|
/* ) WISHED_CONFIG_PATH="${OPTARG}" ;;
|
|
|
|
|
* ) WISHED_CONFIG_PATH="${CDIR}/${OPTARG}" ;;
|
2020-09-04 06:42:12 +00:00
|
|
|
|
esac
|
|
|
|
|
|
2020-09-06 10:27:40 +00:00
|
|
|
|
if [[ ! -d ${WISHED_CONFIG_PATH} ]]
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
|
|
|
|
echo "Directory doesn't exist"
|
|
|
|
|
_usage
|
2020-09-06 10:27:40 +00:00
|
|
|
|
exit 40
|
2020-09-04 06:42:12 +00:00
|
|
|
|
fi
|
2016-08-28 19:10:25 +00:00
|
|
|
|
;;
|
2020-11-06 13:04:23 +00:00
|
|
|
|
|
|
|
|
|
* )
|
|
|
|
|
echo "Invalid option: -${OPTARG}" >&2
|
|
|
|
|
;;
|
|
|
|
|
|
2016-08-28 19:10:25 +00:00
|
|
|
|
esac
|
2020-09-04 06:42:12 +00:00
|
|
|
|
done
|
2020-11-06 13:04:23 +00:00
|
|
|
|
|
|
|
|
|
shift $(( OPTIND - 1 ))
|
2016-08-28 19:10:25 +00:00
|
|
|
|
|
2020-09-06 10:27:40 +00:00
|
|
|
|
if [[ -z ${WISHED_CONFIG_PATH} ]]
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
|
|
|
|
# no wished config path
|
|
|
|
|
_update_config_path
|
2017-04-17 16:27:28 +00:00
|
|
|
|
|
2020-09-06 10:27:40 +00:00
|
|
|
|
if [[ -z ${CONFIG_PATH} ]]
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
2020-09-06 10:27:40 +00:00
|
|
|
|
CONFIG_PATH=${DEFAULT_CONFIG_PATH}
|
2020-09-04 06:42:12 +00:00
|
|
|
|
fi
|
|
|
|
|
else
|
2020-09-06 10:27:40 +00:00
|
|
|
|
CONFIG_PATH=${WISHED_CONFIG_PATH}
|
2020-09-04 06:42:12 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case ${1:-} in
|
|
|
|
|
|
2021-02-18 09:29:34 +00:00
|
|
|
|
email )
|
|
|
|
|
case ${2:-} in
|
|
|
|
|
add ) shift 2 ; _docker_image addmailuser "${@}" ;;
|
|
|
|
|
update ) shift 2 ; _docker_image updatemailuser "${@}" ;;
|
|
|
|
|
del ) shift 2 ; _docker_image delmailuser "${@}" ;;
|
|
|
|
|
restrict ) shift 2 ; _docker_container restrict-access "${@}" ;;
|
2020-09-04 06:42:12 +00:00
|
|
|
|
list ) _docker_image listmailuser ;;
|
|
|
|
|
* ) _usage ;;
|
|
|
|
|
esac
|
|
|
|
|
;;
|
|
|
|
|
|
2021-02-18 09:29:34 +00:00
|
|
|
|
alias )
|
|
|
|
|
case ${2:-} in
|
|
|
|
|
add ) shift 2 ; _docker_image addalias "${1}" "${2}" ;;
|
|
|
|
|
del ) shift 2 ; _docker_image delalias "${1}" "${2}" ;;
|
|
|
|
|
list ) shift 2 ; _docker_image listalias ;;
|
2020-09-04 06:42:12 +00:00
|
|
|
|
* ) _usage ;;
|
|
|
|
|
esac
|
|
|
|
|
;;
|
|
|
|
|
|
2021-02-18 09:29:34 +00:00
|
|
|
|
quota )
|
2020-09-04 06:42:12 +00:00
|
|
|
|
shift ; case ${1:-} in
|
2020-09-06 10:27:40 +00:00
|
|
|
|
set ) shift ; _docker_image setquota "${@}" ;;
|
|
|
|
|
del ) shift ; _docker_image delquota "${@}" ;;
|
2021-01-27 13:09:24 +00:00
|
|
|
|
* ) _usage ;;
|
2020-09-04 06:42:12 +00:00
|
|
|
|
esac
|
|
|
|
|
;;
|
|
|
|
|
|
2021-02-18 09:29:34 +00:00
|
|
|
|
config )
|
|
|
|
|
case ${2:-} in
|
|
|
|
|
dkim ) shift 2 ; _docker_image open-dkim "${@}" ;;
|
|
|
|
|
ssl ) shift 2 ; _docker_image generate-ssl-certificate "${1}" ;;
|
2020-09-04 06:42:12 +00:00
|
|
|
|
* ) _usage ;;
|
|
|
|
|
esac
|
|
|
|
|
;;
|
|
|
|
|
|
2021-02-18 09:29:34 +00:00
|
|
|
|
relay )
|
|
|
|
|
case ${2:-} in
|
|
|
|
|
add-domain ) shift 2 ; _docker_image addrelayhost "${@}" ;;
|
|
|
|
|
add-auth ) shift 2 ; _docker_image addsaslpassword "${@}" ;;
|
|
|
|
|
exclude-domain ) shift 2 ; _docker_image excluderelaydomain "${@}" ;;
|
2020-09-04 06:42:12 +00:00
|
|
|
|
* ) _usage ;;
|
|
|
|
|
esac
|
|
|
|
|
;;
|
|
|
|
|
|
2021-02-18 09:29:34 +00:00
|
|
|
|
debug )
|
|
|
|
|
case ${2:-} in
|
2020-09-04 06:42:12 +00:00
|
|
|
|
fetchmail ) _docker_image debug-fetchmail ;;
|
2021-02-18 09:29:34 +00:00
|
|
|
|
fail2ban ) shift 2 ; _docker_container fail2ban "${@}" ;;
|
2020-09-04 06:42:12 +00:00
|
|
|
|
show-mail-logs ) _docker_container cat /var/log/mail/mail.log ;;
|
|
|
|
|
inspect ) _inspect ;;
|
|
|
|
|
login )
|
2021-02-18 09:29:34 +00:00
|
|
|
|
shift 2
|
|
|
|
|
if [[ -z ${1:-} ]]
|
2020-09-04 06:42:12 +00:00
|
|
|
|
then
|
|
|
|
|
_docker_container /bin/bash
|
|
|
|
|
else
|
2020-09-06 10:27:40 +00:00
|
|
|
|
_docker_container /bin/bash -c "${@}"
|
2020-09-04 06:42:12 +00:00
|
|
|
|
fi
|
2020-04-24 12:55:32 +00:00
|
|
|
|
;;
|
2021-02-18 09:29:34 +00:00
|
|
|
|
* ) _usage ; exit 1 ;;
|
2020-09-04 06:42:12 +00:00
|
|
|
|
esac
|
|
|
|
|
;;
|
2018-04-02 08:45:58 +00:00
|
|
|
|
|
2020-10-21 16:16:32 +00:00
|
|
|
|
help ) _usage ;;
|
|
|
|
|
* ) _usage ; exit 1 ;;
|
2020-09-04 06:42:12 +00:00
|
|
|
|
esac
|
|
|
|
|
}
|
2016-08-28 19:10:25 +00:00
|
|
|
|
|
2020-09-06 10:27:40 +00:00
|
|
|
|
_main "${@}"
|