mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
1e20e7c332
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
179 lines
6 KiB
Bash
Executable file
179 lines
6 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -euE -o pipefail
|
|
|
|
# shellcheck source=../scripts/helpers/index.sh
|
|
source /usr/local/bin/helpers/index.sh
|
|
|
|
function _usage
|
|
{
|
|
# shellcheck disable=SC2059
|
|
printf '%s' "${PURPLE}SETUP${RED}(${YELLOW}1${RED})
|
|
|
|
${ORANGE}NAME${RESET}
|
|
setup - 'docker-mailserver' Administration & Configuration CLI
|
|
|
|
${ORANGE}SYNOPSIS${RESET}
|
|
setup [ OPTIONS${RED}...${RESET} ] COMMAND [ help ${RED}|${RESET} ARGUMENTS${RED}...${RESET} ]
|
|
|
|
COMMAND ${RED}:=${RESET} { email ${RED}|${RESET} alias ${RED}|${RESET} quota ${RED}|${RESET} dovecot-master ${RED}|${RESET} config ${RED}|${RESET} relay ${RED}|${RESET} debug } SUBCOMMAND
|
|
|
|
${ORANGE}DESCRIPTION${RESET}
|
|
This is the main administration command that you use for all your interactions with
|
|
'docker-mailserver'. Initial setup, configuration, and much more is done with this CLI tool.
|
|
|
|
Most subcommands can provide additional information and examples by appending 'help'.
|
|
For example: 'setup email add help'
|
|
|
|
${RED}[${ORANGE}SUB${RED}]${ORANGE}COMMANDS${RESET}
|
|
${LBLUE}COMMAND${RESET} email ${RED}:=${RESET}
|
|
setup email ${CYAN}add${RESET} <EMAIL ADDRESS> [<PASSWORD>]
|
|
setup email ${CYAN}update${RESET} <EMAIL ADDRESS> [<PASSWORD>]
|
|
setup email ${CYAN}del${RESET} [ OPTIONS${RED}...${RESET} ] <EMAIL ADDRESS> [ <EMAIL ADDRESS>${RED}...${RESET} ]
|
|
setup email ${CYAN}restrict${RESET} <add${RED}|${RESET}del${RED}|${RESET}list> <send${RED}|${RESET}receive> [<EMAIL ADDRESS>]
|
|
setup email ${CYAN}list${RESET}
|
|
|
|
${LBLUE}COMMAND${RESET} alias ${RED}:=${RESET}
|
|
setup alias ${CYAN}add${RESET} <EMAIL ADDRESS> <RECIPIENT>
|
|
setup alias ${CYAN}del${RESET} <EMAIL ADDRESS> <RECIPIENT>
|
|
setup alias ${CYAN}list${RESET}
|
|
|
|
${LBLUE}COMMAND${RESET} quota ${RED}:=${RESET}
|
|
setup quota ${CYAN}set${RESET} <EMAIL ADDRESS> [<QUOTA>]
|
|
setup quota ${CYAN}del${RESET} <EMAIL ADDRESS>
|
|
|
|
${LBLUE}COMMAND${RESET} dovecot-master ${RED}:=${RESET}
|
|
setup dovecot-master ${CYAN}add${RESET} <USERNAME> [<PASSWORD>]
|
|
setup dovecot-master ${CYAN}update${RESET} <USERNAME> [<PASSWORD>]
|
|
setup dovecot-master ${CYAN}del${RESET} [ OPTIONS${RED}...${RESET} ] <USERNAME> [ <USERNAME>${RED}...${RESET} ]
|
|
setup dovecot-master ${CYAN}list${RESET}
|
|
|
|
${LBLUE}COMMAND${RESET} config ${RED}:=${RESET}
|
|
setup config ${CYAN}dkim${RESET} [ ARGUMENTS${RED}...${RESET} ]
|
|
|
|
${LBLUE}COMMAND${RESET} relay ${RED}:=${RESET}
|
|
setup relay ${CYAN}add-auth${RESET} <DOMAIN> <USERNAME> [<PASSWORD>]
|
|
setup relay ${CYAN}add-domain${RESET} <DOMAIN> <HOST> [<PORT>]
|
|
setup relay ${CYAN}exclude-domain${RESET} <DOMAIN>
|
|
|
|
${LBLUE}COMMAND${RESET} fail2ban ${RED}:=${RESET}
|
|
setup fail2ban ${RESET}
|
|
setup fail2ban ${CYAN}ban${RESET} <IP>
|
|
setup fail2ban ${CYAN}unban${RESET} <IP>
|
|
|
|
${LBLUE}COMMAND${RESET} debug ${RED}:=${RESET}
|
|
setup debug ${CYAN}fetchmail${RESET}
|
|
setup debug ${CYAN}login${RESET} <COMMANDS>
|
|
setup debug ${CYAN}show-mail-logs${RESET}
|
|
|
|
${ORANGE}EXAMPLES${RESET}
|
|
${LWHITE}setup email add test@example.com${RESET}
|
|
Add the email account ${LWHITE}test@example.com${RESET}. You will be prompted
|
|
to input a password afterwards since no password was supplied.
|
|
|
|
${LWHITE}setup config dkim keysize 2048 domain 'example.com,not-example.com'${RESET}
|
|
Creates keys of length 2048 for the domains in comma-seperated list.
|
|
This is necessary when using LDAP as the required domains cannot be inferred.
|
|
|
|
${LWHITE}setup config dkim help${RESET}
|
|
This will provide you with a detailed explanation on how to use the ${LWHITE}
|
|
config dkim${RESET} command, showing what arguments can be passed and what they do.
|
|
|
|
"
|
|
}
|
|
function _invalid_command
|
|
{
|
|
echo "The command '${*}' is invalid.
|
|
Use \`setup help\` to get an overview of all commands." >&2
|
|
exit 2
|
|
}
|
|
|
|
function _main
|
|
{
|
|
case ${1:-} in
|
|
|
|
( email )
|
|
case ${2:-} in
|
|
( add ) shift 2 ; addmailuser "${@}" ;;
|
|
( update ) shift 2 ; updatemailuser "${@}" ;;
|
|
( del ) shift 2 ; delmailuser "${@}" ;;
|
|
( restrict ) shift 2 ; restrict-access "${@}" ;;
|
|
( list ) listmailuser ;;
|
|
( * ) _invalid_command "${@}" ;;
|
|
esac
|
|
;;
|
|
|
|
( alias )
|
|
case ${2:-} in
|
|
( add ) shift 2 ; addalias "${@}" ;;
|
|
( del ) shift 2 ; delalias "${@}" ;;
|
|
( list ) shift 2 ; listalias ;;
|
|
( * ) _invalid_command "${@}" ;;
|
|
esac
|
|
;;
|
|
|
|
( quota )
|
|
case ${2:-} in
|
|
( set ) shift 2 ; setquota "${@}" ;;
|
|
( del ) shift 2 ; delquota "${@}" ;;
|
|
( * ) _invalid_command "${@}" ;;
|
|
esac
|
|
;;
|
|
|
|
( dovecot-master )
|
|
case ${2:-} in
|
|
( add ) shift 2 ; adddovecotmasteruser "${@}" ;;
|
|
( update ) shift 2 ; updatedovecotmasteruser "${@}" ;;
|
|
( del ) shift 2 ; deldovecotmasteruser "${@}" ;;
|
|
( list ) listdovecotmasteruser ;;
|
|
( * ) _invalid_command "${@}" ;;
|
|
esac
|
|
;;
|
|
|
|
( config )
|
|
case ${2:-} in
|
|
( dkim ) shift 2 ; open-dkim "${@}" ;;
|
|
( * ) _invalid_command "${@}" ;;
|
|
esac
|
|
;;
|
|
|
|
( relay )
|
|
case ${2:-} in
|
|
( add-domain ) shift 2 ; addrelayhost "${@}" ;;
|
|
( add-auth ) shift 2 ; addsaslpassword "${@}" ;;
|
|
( exclude-domain ) shift 2 ; excluderelaydomain "${@}" ;;
|
|
( * ) _invalid_command "${@}" ;;
|
|
esac
|
|
;;
|
|
|
|
( fail2ban ) shift 1 ; fail2ban "${@}" ;;
|
|
|
|
( debug )
|
|
case ${2:-} in
|
|
( fetchmail ) debug-fetchmail ;;
|
|
( show-mail-logs ) cat /var/log/mail/mail.log ;;
|
|
( login )
|
|
shift 2
|
|
if [[ -z ${1:-} ]]
|
|
then
|
|
/bin/bash
|
|
else
|
|
/bin/bash -c "${@}"
|
|
fi
|
|
;;
|
|
( * ) _invalid_command "${*}" ;;
|
|
esac
|
|
;;
|
|
|
|
( help ) _usage ;;
|
|
( * ) _invalid_command "${*}" ;;
|
|
esac
|
|
}
|
|
|
|
if [[ -z ${1:-} ]]
|
|
then
|
|
_usage
|
|
else
|
|
_main "${@}"
|
|
fi
|