2020-11-06 13:04:23 +00:00
|
|
|
|
#! /bin/bash
|
2016-08-28 19:10:25 +00:00
|
|
|
|
|
2021-01-16 09:16:05 +00:00
|
|
|
|
# version v0.2.4 stable
|
|
|
|
|
# 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
|
2020-10-04 17:34:15 +00:00
|
|
|
|
trap '__log_err ${FUNCNAME[0]:-"?"} ${_:-"?"} ${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
|
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=
|
|
|
|
|
CONTAINER_NAME='mail'
|
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
|
|
|
|
{
|
2020-12-22 17:09:03 +00:00
|
|
|
|
echo "${SCRIPT:-${0}} Bootstrapping Script
|
2020-10-04 17:34:15 +00:00
|
|
|
|
|
|
|
|
|
Usage: ${0} [-i IMAGE_NAME] [-c CONTAINER_NAME] <subcommand> <subcommand> [args]
|
2016-09-01 10:10:23 +00:00
|
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
|
|
|
|
|
|
-i IMAGE_NAME The name of the docker-mailserver image, by default
|
2021-01-16 09:16:05 +00:00
|
|
|
|
'mailserver/docker-mailserver:latest' for docker, and
|
|
|
|
|
'docker.io/mailserver/docker-mailserver:latest' for podman.
|
2019-11-22 14:42:25 +00:00
|
|
|
|
|
2016-09-01 10:10:23 +00:00
|
|
|
|
-c CONTAINER_NAME The name of the running container.
|
2016-08-28 19:10:25 +00:00
|
|
|
|
|
2020-10-06 12:45:55 +00:00
|
|
|
|
-p PATH Config folder path (default: ${CDIR}/config)
|
|
|
|
|
|
|
|
|
|
-h Show this help dialogue
|
2018-02-11 17:26:46 +00:00
|
|
|
|
|
2020-10-30 15:43:31 +00:00
|
|
|
|
-z Allow container access to the bind mount content
|
|
|
|
|
that is shared among multiple containers
|
|
|
|
|
on a SELinux-enabled host.
|
|
|
|
|
|
|
|
|
|
-Z Allow container access to the bind mount content
|
|
|
|
|
that is private and unshared with other containers
|
|
|
|
|
on a SELinux-enabled host.
|
|
|
|
|
|
2016-08-28 19:10:25 +00:00
|
|
|
|
SUBCOMMANDS:
|
|
|
|
|
|
|
|
|
|
email:
|
|
|
|
|
|
2020-09-06 10:27:40 +00:00
|
|
|
|
${0} email add <email> [<password>]
|
|
|
|
|
${0} email update <email> [<password>]
|
|
|
|
|
${0} email del <email>
|
|
|
|
|
${0} email restrict <add|del|list> <send|receive> [<email>]
|
|
|
|
|
${0} email list
|
2016-08-28 19:10:25 +00:00
|
|
|
|
|
2017-04-17 16:27:28 +00:00
|
|
|
|
alias:
|
2020-09-06 10:27:40 +00:00
|
|
|
|
${0} alias add <email> <recipient>
|
|
|
|
|
${0} alias del <email> <recipient>
|
|
|
|
|
${0} alias list
|
2017-04-17 16:27:28 +00:00
|
|
|
|
|
2020-04-24 12:55:32 +00:00
|
|
|
|
quota:
|
2020-09-06 10:27:40 +00:00
|
|
|
|
${0} quota set <email> [<quota>]
|
|
|
|
|
${0} quota del <email>
|
2020-04-24 12:55:32 +00:00
|
|
|
|
|
2016-08-28 19:10:25 +00:00
|
|
|
|
config:
|
|
|
|
|
|
2020-09-06 10:27:40 +00:00
|
|
|
|
${0} config dkim <keysize> (default: 2048)
|
|
|
|
|
${0} config ssl <fqdn>
|
2016-08-28 19:10:25 +00:00
|
|
|
|
|
2018-04-02 08:45:58 +00:00
|
|
|
|
relay:
|
|
|
|
|
|
2020-09-06 10:27:40 +00:00
|
|
|
|
${0} relay add-domain <domain> <host> [<port>]
|
|
|
|
|
${0} relay add-auth <domain> <username> [<password>]
|
|
|
|
|
${0} relay exclude-domain <domain>
|
2018-04-02 08:45:58 +00:00
|
|
|
|
|
2016-08-28 19:10:25 +00:00
|
|
|
|
debug:
|
|
|
|
|
|
2020-09-06 10:27:40 +00:00
|
|
|
|
${0} debug fetchmail
|
|
|
|
|
${0} debug fail2ban [<unban> <ip-address>]
|
|
|
|
|
${0} debug show-mail-logs
|
|
|
|
|
${0} debug inspect
|
|
|
|
|
${0} debug login <commands>
|
2020-09-04 06:42:12 +00:00
|
|
|
|
|
2020-10-06 12:45:55 +00:00
|
|
|
|
help: Show this help dialogue
|
|
|
|
|
|
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 \
|
2020-10-30 15:43:31 +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-16 09:16:05 +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
|
|
|
|
|
|
|
|
|
|
email)
|
|
|
|
|
shift ; case ${1:-} in
|
2020-09-06 10:27:40 +00:00
|
|
|
|
add ) shift ; _docker_image addmailuser "${@}" ;;
|
|
|
|
|
update ) shift ; _docker_image updatemailuser "${@}" ;;
|
|
|
|
|
del ) shift ; _docker_image delmailuser "${@}" ;;
|
|
|
|
|
restrict ) shift ; _docker_container restrict-access "${@}" ;;
|
2020-09-04 06:42:12 +00:00
|
|
|
|
list ) _docker_image listmailuser ;;
|
|
|
|
|
* ) _usage ;;
|
|
|
|
|
esac
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
alias)
|
|
|
|
|
shift ; case ${1:-} in
|
2020-09-09 09:19:57 +00:00
|
|
|
|
add ) shift ; _docker_image addalias "${1}" "${2}" ;;
|
|
|
|
|
del ) shift ; _docker_image delalias "${1}" "${2}" ;;
|
|
|
|
|
list ) shift ; _docker_image listalias ;;
|
2020-09-04 06:42:12 +00:00
|
|
|
|
* ) _usage ;;
|
|
|
|
|
esac
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
quota)
|
|
|
|
|
shift ; case ${1:-} in
|
2020-09-06 10:27:40 +00:00
|
|
|
|
set ) shift ; _docker_image setquota "${@}" ;;
|
|
|
|
|
del ) shift ; _docker_image delquota "${@}" ;;
|
2020-09-04 06:42:12 +00:00
|
|
|
|
* ) _usage ;;
|
|
|
|
|
esac
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
config)
|
|
|
|
|
shift ; case ${1:-} in
|
|
|
|
|
dkim ) _docker_image generate-dkim-config "${2:-2048}" ;;
|
2020-09-06 10:27:40 +00:00
|
|
|
|
ssl ) _docker_image generate-ssl-certificate "${2}" ;;
|
2020-09-04 06:42:12 +00:00
|
|
|
|
* ) _usage ;;
|
|
|
|
|
esac
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
relay)
|
|
|
|
|
shift ; case ${1:-} in
|
2020-09-06 10:27:40 +00:00
|
|
|
|
add-domain ) shift ; _docker_image addrelayhost "${@}" ;;
|
|
|
|
|
add-auth ) shift ; _docker_image addsaslpassword "${@}" ;;
|
|
|
|
|
exclude-domain ) shift ; _docker_image excluderelaydomain "${@}" ;;
|
2020-09-04 06:42:12 +00:00
|
|
|
|
* ) _usage ;;
|
|
|
|
|
esac
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
debug)
|
|
|
|
|
shift ; case ${1:-} in
|
|
|
|
|
fetchmail ) _docker_image debug-fetchmail ;;
|
2020-09-06 10:27:40 +00:00
|
|
|
|
fail2ban ) shift ; _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 )
|
2020-04-24 12:55:32 +00:00
|
|
|
|
shift
|
2020-09-04 06:42:12 +00:00
|
|
|
|
if [[ -z ${1:-''} ]]
|
|
|
|
|
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
|
|
|
|
;;
|
2020-10-21 16:16:32 +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 "${@}"
|