Bump mail server to 10.1.2 #4
|
@ -2,7 +2,7 @@
|
||||||
version: '3.7'
|
version: '3.7'
|
||||||
services:
|
services:
|
||||||
mail:
|
mail:
|
||||||
image: mailserver/docker-mailserver:9.1.0
|
image: mailserver/docker-mailserver:10.1.2
|
||||||
hostname: ${HOSTNAME}
|
hostname: ${HOSTNAME}
|
||||||
domainname: ${DOMAINNAME}
|
domainname: ${DOMAINNAME}
|
||||||
container_name: ${CONTAINER_NAME}
|
container_name: ${CONTAINER_NAME}
|
||||||
|
|
134
mail/setup.sh
134
mail/setup.sh
|
@ -19,15 +19,14 @@ RESET="\e[0m"
|
||||||
|
|
||||||
set -euEo pipefail
|
set -euEo pipefail
|
||||||
trap '__log_err "${FUNCNAME[0]:-?}" "${BASH_COMMAND:-?}" "${LINENO:-?}" "${?:-?}"' ERR
|
trap '__log_err "${FUNCNAME[0]:-?}" "${BASH_COMMAND:-?}" "${LINENO:-?}" "${?:-?}"' ERR
|
||||||
trap '_unset_vars || :' EXIT
|
|
||||||
|
|
||||||
function __log_err
|
function __log_err
|
||||||
{
|
{
|
||||||
printf "\n––– ${BOLD}${RED}UNCHECKED ERROR${RESET}\n%s\n%s\n%s\n%s\n\n" \
|
printf "\n--- ${BOLD}${RED}UNCHECKED ERROR${RESET}\n%s\n%s\n%s\n%s\n\n" \
|
||||||
" – script = ${SCRIPT:-${0}}" \
|
" - script = ${SCRIPT:-${0}}" \
|
||||||
" – function = ${1} / ${2}" \
|
" - function = ${1} / ${2}" \
|
||||||
" – line = ${3}" \
|
" - line = ${3}" \
|
||||||
" – exit code = ${4}" >&2
|
" - exit code = ${4}" >&2
|
||||||
|
|
||||||
printf "Make sure you use a version of this script that matches
|
printf "Make sure you use a version of this script that matches
|
||||||
the version / tag of docker-mailserver. Please read the
|
the version / tag of docker-mailserver. Please read the
|
||||||
|
@ -35,39 +34,38 @@ the version / tag of docker-mailserver. Please read the
|
||||||
ly and use ./setup.sh help and read the VERSION section.\n" >&2
|
ly and use ./setup.sh help and read the VERSION section.\n" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
function _unset_vars
|
function _get_absolute_script_directory
|
||||||
{
|
{
|
||||||
unset CDIR CRI INFO IMAGE_NAME CONTAINER_NAME DEFAULT_CONFIG_PATH
|
if [[ "$(uname)" == "Darwin" ]]
|
||||||
unset USE_CONTAINER WISHED_CONFIG_PATH CONFIG_PATH VOLUME USE_TTY
|
then
|
||||||
unset SCRIPT USING_SELINUX
|
readlink() {
|
||||||
|
greadlink "${@:+$@}" # Requires coreutils
|
||||||
}
|
}
|
||||||
|
fi
|
||||||
function _get_current_directory
|
|
||||||
{
|
|
||||||
if dirname "$(readlink -f "${0}")" &>/dev/null
|
if dirname "$(readlink -f "${0}")" &>/dev/null
|
||||||
then
|
then
|
||||||
CDIR="$(dirname "$(readlink -f "${0}")")"
|
DIR="$(dirname "$(readlink -f "${0}")")"
|
||||||
elif realpath -e -L "${0}" &>/dev/null
|
elif realpath -e -L "${0}" &>/dev/null
|
||||||
then
|
then
|
||||||
CDIR="$(realpath -e -L "${0}")"
|
DIR="$(realpath -e -L "${0}")"
|
||||||
CDIR="${CDIR%/setup.sh}"
|
DIR="${DIR%/setup.sh}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
CDIR="$(pwd)"
|
DIR="$(pwd)"
|
||||||
_get_current_directory
|
_get_absolute_script_directory
|
||||||
|
|
||||||
CRI=
|
CRI=
|
||||||
INFO=
|
|
||||||
IMAGE_NAME=
|
|
||||||
CONTAINER_NAME=
|
|
||||||
DEFAULT_CONFIG_PATH="${CDIR}/config"
|
|
||||||
USE_CONTAINER=false
|
|
||||||
WISHED_CONFIG_PATH=
|
|
||||||
CONFIG_PATH=
|
CONFIG_PATH=
|
||||||
VOLUME=
|
CONTAINER_NAME=
|
||||||
|
DEFAULT_CONFIG_PATH="${DIR}/config"
|
||||||
|
IMAGE_NAME=
|
||||||
|
INFO=
|
||||||
|
USE_CONTAINER=false
|
||||||
USE_TTY=
|
USE_TTY=
|
||||||
USING_SELINUX=
|
USE_SELINUX=
|
||||||
|
VOLUME=
|
||||||
|
WISHED_CONFIG_PATH=
|
||||||
|
|
||||||
function _check_root
|
function _check_root
|
||||||
{
|
{
|
||||||
|
@ -158,7 +156,7 @@ ${ORANGE}OPTIONS${RESET}
|
||||||
|
|
||||||
-p PATH
|
-p PATH
|
||||||
Provides the config folder path. The default is
|
Provides the config folder path. The default is
|
||||||
${WHITE}${CDIR}/config/${RESET}
|
${WHITE}${DIR}/config/${RESET}
|
||||||
|
|
||||||
${LBLUE}SELinux${RESET}
|
${LBLUE}SELinux${RESET}
|
||||||
-z
|
-z
|
||||||
|
@ -171,36 +169,35 @@ ${ORANGE}OPTIONS${RESET}
|
||||||
|
|
||||||
${RED}[${ORANGE}SUB${RED}]${ORANGE}COMMANDS${RESET}
|
${RED}[${ORANGE}SUB${RED}]${ORANGE}COMMANDS${RESET}
|
||||||
${LBLUE}COMMAND${RESET} email ${RED}:=${RESET}
|
${LBLUE}COMMAND${RESET} email ${RED}:=${RESET}
|
||||||
${0} email add <EMAIL ADDRESS> [<PASSWORD>]
|
${0} email ${CYAN}add${RESET} <EMAIL ADDRESS> [<PASSWORD>]
|
||||||
${0} email update <EMAIL ADDRESS> [<PASSWORD>]
|
${0} email ${CYAN}update${RESET} <EMAIL ADDRESS> [<PASSWORD>]
|
||||||
${0} email del [ OPTIONS${RED}...${RESET} ] <EMAIL ADDRESS> [ <EMAIL ADDRESS>${RED}...${RESET} ]
|
${0} email ${CYAN}del${RESET} [ OPTIONS${RED}...${RESET} ] <EMAIL ADDRESS> [ <EMAIL ADDRESS>${RED}...${RESET} ]
|
||||||
${0} email restrict <add${RED}|${RESET}del${RED}|${RESET}list> <send${RED}|${RESET}receive> [<EMAIL ADDRESS>]
|
${0} email ${CYAN}restrict${RESET} <add${RED}|${RESET}del${RED}|${RESET}list> <send${RED}|${RESET}receive> [<EMAIL ADDRESS>]
|
||||||
${0} email list
|
${0} email ${CYAN}list${RESET}
|
||||||
|
|
||||||
${LBLUE}COMMAND${RESET} alias ${RED}:=${RESET}
|
${LBLUE}COMMAND${RESET} alias ${RED}:=${RESET}
|
||||||
${0} alias add <EMAIL ADDRESS> <RECIPIENT>
|
${0} alias ${CYAN}add${RESET} <EMAIL ADDRESS> <RECIPIENT>
|
||||||
${0} alias del <EMAIL ADDRESS> <RECIPIENT>
|
${0} alias ${CYAN}del${RESET} <EMAIL ADDRESS> <RECIPIENT>
|
||||||
${0} alias list
|
${0} alias ${CYAN}list${RESET}
|
||||||
|
|
||||||
${LBLUE}COMMAND${RESET} quota ${RED}:=${RESET}
|
${LBLUE}COMMAND${RESET} quota ${RED}:=${RESET}
|
||||||
${0} quota set <EMAIL ADDRESS> [<QUOTA>]
|
${0} quota ${CYAN}set${RESET} <EMAIL ADDRESS> [<QUOTA>]
|
||||||
${0} quota del <EMAIL ADDRESS>
|
${0} quota ${CYAN}del${RESET} <EMAIL ADDRESS>
|
||||||
|
|
||||||
${LBLUE}COMMAND${RESET} config ${RED}:=${RESET}
|
${LBLUE}COMMAND${RESET} config ${RED}:=${RESET}
|
||||||
${0} config dkim [ ARGUMENTS${RED}...${RESET} ]
|
${0} config ${CYAN}dkim${RESET} [ ARGUMENTS${RED}...${RESET} ]
|
||||||
${0} config ssl <FQDN> (${CYAN}ATTENTION${RESET}: This is deprecated and will be removed soon.)
|
|
||||||
|
|
||||||
${LBLUE}COMMAND${RESET} relay ${RED}:=${RESET}
|
${LBLUE}COMMAND${RESET} relay ${RED}:=${RESET}
|
||||||
${0} relay add-domain <DOMAIN> <HOST> [<PORT>]
|
${0} relay ${CYAN}add-domain${RESET} <DOMAIN> <HOST> [<PORT>]
|
||||||
${0} relay add-auth <DOMAIN> <USERNAME> [<PASSWORD>]
|
${0} relay ${CYAN}add-auth${RESET} <DOMAIN> <USERNAME> [<PASSWORD>]
|
||||||
${0} relay exclude-domain <DOMAIN>
|
${0} relay ${CYAN}exclude-domain${RESET} <DOMAIN>
|
||||||
|
|
||||||
${LBLUE}COMMAND${RESET} debug ${RED}:=${RESET}
|
${LBLUE}COMMAND${RESET} debug ${RED}:=${RESET}
|
||||||
${0} debug fetchmail
|
${0} debug ${CYAN}fetchmail${RESET}
|
||||||
${0} debug fail2ban [unban <IP>]
|
${0} debug ${CYAN}fail2ban${RESET} [unban <IP>]
|
||||||
${0} debug show-mail-logs
|
${0} debug ${CYAN}show-mail-logs${RESET}
|
||||||
${0} debug inspect
|
${0} debug ${CYAN}inspect${RESET}
|
||||||
${0} debug login <COMMANDS>
|
${0} debug ${CYAN}login${RESET} <COMMANDS>
|
||||||
|
|
||||||
${ORANGE}EXAMPLES${RESET}
|
${ORANGE}EXAMPLES${RESET}
|
||||||
${WHITE}./setup.sh email add test@domain.tld${RESET}
|
${WHITE}./setup.sh email add test@domain.tld${RESET}
|
||||||
|
@ -234,7 +231,7 @@ function _docker_image
|
||||||
if ${USE_CONTAINER}
|
if ${USE_CONTAINER}
|
||||||
then
|
then
|
||||||
# reuse existing container specified on command line
|
# reuse existing container specified on command line
|
||||||
${CRI} exec "${USE_TTY}" "${CONTAINER_NAME}" "${@}"
|
${CRI} exec "${USE_TTY}" "${CONTAINER_NAME}" "${@:+$@}"
|
||||||
else
|
else
|
||||||
# start temporary container with specified image
|
# start temporary container with specified image
|
||||||
if ! _docker_image_exists "${IMAGE_NAME}"
|
if ! _docker_image_exists "${IMAGE_NAME}"
|
||||||
|
@ -244,8 +241,8 @@ function _docker_image
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${CRI} run --rm \
|
${CRI} run --rm \
|
||||||
-v "${CONFIG_PATH}:/tmp/docker-mailserver${USING_SELINUX}" \
|
-v "${CONFIG_PATH}:/tmp/docker-mailserver${USE_SELINUX}" \
|
||||||
"${USE_TTY}" "${IMAGE_NAME}" "${@}"
|
"${USE_TTY}" "${IMAGE_NAME}" "${@:+$@}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +250,7 @@ function _docker_container
|
||||||
{
|
{
|
||||||
if [[ -n ${CONTAINER_NAME} ]]
|
if [[ -n ${CONTAINER_NAME} ]]
|
||||||
then
|
then
|
||||||
${CRI} exec "${USE_TTY}" "${CONTAINER_NAME}" "${@}"
|
${CRI} exec "${USE_TTY}" "${CONTAINER_NAME}" "${@:+$@}"
|
||||||
else
|
else
|
||||||
echo "The mailserver is not running!"
|
echo "The mailserver is not running!"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -300,8 +297,8 @@ function _main
|
||||||
do
|
do
|
||||||
case ${OPT} in
|
case ${OPT} in
|
||||||
i ) IMAGE_NAME="${OPTARG}" ;;
|
i ) IMAGE_NAME="${OPTARG}" ;;
|
||||||
z ) USING_SELINUX=":z" ;;
|
z ) USE_SELINUX=":z" ;;
|
||||||
Z ) USING_SELINUX=":Z" ;;
|
Z ) USE_SELINUX=":Z" ;;
|
||||||
c )
|
c )
|
||||||
# container specified, connect to running instance
|
# container specified, connect to running instance
|
||||||
CONTAINER_NAME="${OPTARG}"
|
CONTAINER_NAME="${OPTARG}"
|
||||||
|
@ -311,7 +308,7 @@ function _main
|
||||||
p )
|
p )
|
||||||
case "${OPTARG}" in
|
case "${OPTARG}" in
|
||||||
/* ) WISHED_CONFIG_PATH="${OPTARG}" ;;
|
/* ) WISHED_CONFIG_PATH="${OPTARG}" ;;
|
||||||
* ) WISHED_CONFIG_PATH="${CDIR}/${OPTARG}" ;;
|
* ) WISHED_CONFIG_PATH="${DIR}/${OPTARG}" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ ! -d ${WISHED_CONFIG_PATH} ]]
|
if [[ ! -d ${WISHED_CONFIG_PATH} ]]
|
||||||
|
@ -349,11 +346,11 @@ function _main
|
||||||
|
|
||||||
email )
|
email )
|
||||||
case ${2:-} in
|
case ${2:-} in
|
||||||
add ) shift 2 ; _docker_image addmailuser "${@}" ;;
|
add ) shift 2 ; _docker_image addmailuser "${@:+$@}" ;;
|
||||||
update ) shift 2 ; _docker_image updatemailuser "${@}" ;;
|
update ) shift 2 ; _docker_image updatemailuser "${@:+$@}" ;;
|
||||||
del ) shift 2 ; _docker_container delmailuser "${@}" ;;
|
del ) shift 2 ; _docker_container delmailuser "${@:+$@}" ;;
|
||||||
restrict ) shift 2 ; _docker_container restrict-access "${@}" ;;
|
restrict ) shift 2 ; _docker_container restrict-access "${@:+$@}" ;;
|
||||||
list ) _docker_image listmailuser ;;
|
list ) _docker_container listmailuser ;;
|
||||||
* ) _usage ;;
|
* ) _usage ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
@ -369,25 +366,24 @@ function _main
|
||||||
|
|
||||||
quota )
|
quota )
|
||||||
case ${2:-} in
|
case ${2:-} in
|
||||||
set ) shift 2 ; _docker_image setquota "${@}" ;;
|
set ) shift 2 ; _docker_image setquota "${@:+$@}" ;;
|
||||||
del ) shift 2 ; _docker_image delquota "${@}" ;;
|
del ) shift 2 ; _docker_image delquota "${@:+$@}" ;;
|
||||||
* ) _usage ;;
|
* ) _usage ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
config )
|
config )
|
||||||
case ${2:-} in
|
case ${2:-} in
|
||||||
dkim ) shift 2 ; _docker_image open-dkim "${@}" ;;
|
dkim ) shift 2 ; _docker_image open-dkim "${@:+$@}" ;;
|
||||||
ssl ) shift 2 ; _docker_image generate-ssl-certificate "${1}" ;;
|
|
||||||
* ) _usage ;;
|
* ) _usage ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
relay )
|
relay )
|
||||||
case ${2:-} in
|
case ${2:-} in
|
||||||
add-domain ) shift 2 ; _docker_image addrelayhost "${@}" ;;
|
add-domain ) shift 2 ; _docker_image addrelayhost "${@:+$@}" ;;
|
||||||
add-auth ) shift 2 ; _docker_image addsaslpassword "${@}" ;;
|
add-auth ) shift 2 ; _docker_image addsaslpassword "${@:+$@}" ;;
|
||||||
exclude-domain ) shift 2 ; _docker_image excluderelaydomain "${@}" ;;
|
exclude-domain ) shift 2 ; _docker_image excluderelaydomain "${@:+$@}" ;;
|
||||||
* ) _usage ;;
|
* ) _usage ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
@ -395,7 +391,7 @@ function _main
|
||||||
debug )
|
debug )
|
||||||
case ${2:-} in
|
case ${2:-} in
|
||||||
fetchmail ) _docker_image debug-fetchmail ;;
|
fetchmail ) _docker_image debug-fetchmail ;;
|
||||||
fail2ban ) shift 2 ; _docker_container fail2ban "${@}" ;;
|
fail2ban ) shift 2 ; _docker_container fail2ban "${@:+$@}" ;;
|
||||||
show-mail-logs ) _docker_container cat /var/log/mail/mail.log ;;
|
show-mail-logs ) _docker_container cat /var/log/mail/mail.log ;;
|
||||||
inspect ) _inspect ;;
|
inspect ) _inspect ;;
|
||||||
login )
|
login )
|
||||||
|
@ -404,7 +400,7 @@ function _main
|
||||||
then
|
then
|
||||||
_docker_container /bin/bash
|
_docker_container /bin/bash
|
||||||
else
|
else
|
||||||
_docker_container /bin/bash -c "${@}"
|
_docker_container /bin/bash -c "${@:+$@}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
* ) _usage ; exit 1 ;;
|
* ) _usage ; exit 1 ;;
|
||||||
|
@ -416,4 +412,4 @@ function _main
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
_main "${@}"
|
_main "${@:+$@}"
|
||||||
|
|
Loading…
Reference in New Issue