|
|
@ -9,7 +9,7 @@ CONTAINER_NAME=
|
|
|
|
CRI=
|
|
|
|
CRI=
|
|
|
|
DEFAULT_CONFIG_PATH=
|
|
|
|
DEFAULT_CONFIG_PATH=
|
|
|
|
DESIRED_CONFIG_PATH=
|
|
|
|
DESIRED_CONFIG_PATH=
|
|
|
|
DIR="$(pwd)"
|
|
|
|
DIR=$(pwd)
|
|
|
|
DMS_CONFIG='/tmp/docker-mailserver'
|
|
|
|
DMS_CONFIG='/tmp/docker-mailserver'
|
|
|
|
IMAGE_NAME=
|
|
|
|
IMAGE_NAME=
|
|
|
|
DEFAULT_IMAGE_NAME='docker.io/mailserver/docker-mailserver:latest'
|
|
|
|
DEFAULT_IMAGE_NAME='docker.io/mailserver/docker-mailserver:latest'
|
|
|
@ -19,14 +19,14 @@ USE_SELINUX=
|
|
|
|
USE_TTY=
|
|
|
|
USE_TTY=
|
|
|
|
VOLUME=
|
|
|
|
VOLUME=
|
|
|
|
|
|
|
|
|
|
|
|
RED="\e[31m\e[1m"
|
|
|
|
RED=$(echo -ne '\e[31m\e[1m')
|
|
|
|
WHITE="\e[37m"
|
|
|
|
WHITE=$(echo -ne '\e[37m')
|
|
|
|
ORANGE="\e[38;5;214m"
|
|
|
|
ORANGE=$(echo -ne '\e[38;5;214m')
|
|
|
|
LBLUE="\e[94m"
|
|
|
|
LBLUE=$(echo -ne '\e[94m')
|
|
|
|
RESET="\e[0m"
|
|
|
|
RESET=$(echo -ne '\e[0m')
|
|
|
|
|
|
|
|
|
|
|
|
set -euEo pipefail
|
|
|
|
set -euEo pipefail
|
|
|
|
shopt -s inherit_errexit
|
|
|
|
shopt -s inherit_errexit 2>/dev/null || true
|
|
|
|
trap '__err "${BASH_SOURCE}" "${FUNCNAME[0]:-?}" "${BASH_COMMAND:-?}" "${LINENO:-?}" "${?:-?}"' ERR
|
|
|
|
trap '__err "${BASH_SOURCE}" "${FUNCNAME[0]:-?}" "${BASH_COMMAND:-?}" "${LINENO:-?}" "${?:-?}"' ERR
|
|
|
|
|
|
|
|
|
|
|
|
function __err
|
|
|
|
function __err
|
|
|
@ -47,7 +47,7 @@ function __err
|
|
|
|
function _show_local_usage
|
|
|
|
function _show_local_usage
|
|
|
|
{
|
|
|
|
{
|
|
|
|
# shellcheck disable=SC2059
|
|
|
|
# shellcheck disable=SC2059
|
|
|
|
printf "${ORANGE}OPTIONS${RESET}
|
|
|
|
printf '%s' "${ORANGE}OPTIONS${RESET}
|
|
|
|
${LBLUE}Config path, container or image adjustments${RESET}
|
|
|
|
${LBLUE}Config path, container or image adjustments${RESET}
|
|
|
|
-i IMAGE_NAME
|
|
|
|
-i IMAGE_NAME
|
|
|
|
Provides the name of the 'docker-mailserver' image. The default value is
|
|
|
|
Provides the name of the 'docker-mailserver' image. The default value is
|
|
|
@ -78,7 +78,7 @@ function _show_local_usage
|
|
|
|
[[ ${1:-} == 'no-exit' ]] && return 0
|
|
|
|
[[ ${1:-} == 'no-exit' ]] && return 0
|
|
|
|
|
|
|
|
|
|
|
|
# shellcheck disable=SC2059
|
|
|
|
# shellcheck disable=SC2059
|
|
|
|
printf "${ORANGE}EXIT STATUS${RESET}
|
|
|
|
printf '%s' "${ORANGE}EXIT STATUS${RESET}
|
|
|
|
Exit status is 0 if the command was successful. If there was an unexpected error, an error
|
|
|
|
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
|
|
|
|
message is shown describing the error. In case of an error, the script will exit with exit
|
|
|
|
status 1.
|
|
|
|
status 1.
|
|
|
@ -88,20 +88,12 @@ function _show_local_usage
|
|
|
|
|
|
|
|
|
|
|
|
function _get_absolute_script_directory
|
|
|
|
function _get_absolute_script_directory
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if [[ "$(uname)" == 'Darwin' ]]
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
readlink() {
|
|
|
|
|
|
|
|
# requires coreutils
|
|
|
|
|
|
|
|
greadlink "${@:+$@}"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if dirname "$(readlink -f "${0}")" &>/dev/null
|
|
|
|
if dirname "$(readlink -f "${0}")" &>/dev/null
|
|
|
|
then
|
|
|
|
then
|
|
|
|
DIR="$(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
|
|
|
|
DIR="$(realpath -e -L "${0}")"
|
|
|
|
DIR=$(realpath -e -L "${0}")
|
|
|
|
DIR="${DIR%/setup.sh}"
|
|
|
|
DIR="${DIR%/setup.sh}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -154,7 +146,7 @@ function _run_in_new_container
|
|
|
|
|
|
|
|
|
|
|
|
${CRI} run --rm "${USE_TTY}" \
|
|
|
|
${CRI} run --rm "${USE_TTY}" \
|
|
|
|
-v "${CONFIG_PATH}:${DMS_CONFIG}${USE_SELINUX}" \
|
|
|
|
-v "${CONFIG_PATH}:${DMS_CONFIG}${USE_SELINUX}" \
|
|
|
|
"${IMAGE_NAME}" "${@:+$@}"
|
|
|
|
"${IMAGE_NAME}" "${@}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function _main
|
|
|
|
function _main
|
|
|
@ -213,7 +205,7 @@ function _main
|
|
|
|
INFO=$(${CRI} ps --no-trunc --format "{{.Image}};{{.Names}}" --filter \
|
|
|
|
INFO=$(${CRI} ps --no-trunc --format "{{.Image}};{{.Names}}" --filter \
|
|
|
|
label=org.opencontainers.image.title="docker-mailserver" | tail -1)
|
|
|
|
label=org.opencontainers.image.title="docker-mailserver" | tail -1)
|
|
|
|
|
|
|
|
|
|
|
|
CONTAINER_NAME=${INFO#*;}
|
|
|
|
[[ -z ${CONTAINER_NAME} ]] && CONTAINER_NAME=${INFO#*;}
|
|
|
|
[[ -z ${IMAGE_NAME} ]] && IMAGE_NAME=${INFO%;*}
|
|
|
|
[[ -z ${IMAGE_NAME} ]] && IMAGE_NAME=${INFO%;*}
|
|
|
|
if [[ -z ${IMAGE_NAME} ]]
|
|
|
|
if [[ -z ${IMAGE_NAME} ]]
|
|
|
|
then
|
|
|
|
then
|
|
|
@ -234,14 +226,15 @@ function _main
|
|
|
|
|
|
|
|
|
|
|
|
if [[ -n ${CONTAINER_NAME} ]]
|
|
|
|
if [[ -n ${CONTAINER_NAME} ]]
|
|
|
|
then
|
|
|
|
then
|
|
|
|
${CRI} exec "${USE_TTY}" "${CONTAINER_NAME}" setup "${@:+$@}"
|
|
|
|
${CRI} exec "${USE_TTY}" "${CONTAINER_NAME}" setup "${@}"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
_run_in_new_container setup "${@:+$@}"
|
|
|
|
_run_in_new_container setup "${@}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
[[ ${1} == 'help' ]] && _show_local_usage
|
|
|
|
[[ ${1:-} == 'help' ]] && _show_local_usage
|
|
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_main "${@:+$@}"
|
|
|
|
[[ -z ${1:-} ]] && set 'help'
|
|
|
|
|
|
|
|
_main "${@}"
|
|
|
|