mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-31 23:40:25 +02:00
Improve logging significantly – color is back! (#1758)
* improve logging significantly * now defaulting to warn * final adjustments * correcting not-escaped $ in sed
This commit is contained in:
parent
035c4de7fe
commit
324ee8eb85
6 changed files with 73 additions and 53 deletions
|
@ -97,7 +97,7 @@ for key, value in acme.items():
|
|||
|
||||
echo "${KEY}" | base64 -d >/etc/letsencrypt/live/"${HOSTNAME}"/key.pem || exit 1
|
||||
echo "${CERT}" | base64 -d >/etc/letsencrypt/live/"${HOSTNAME}"/fullchain.pem || exit 1
|
||||
echo "Cert found in /etc/letsencrypt/acme.json for ${1}"
|
||||
_notify 'inf' "Cert found in /etc/letsencrypt/acme.json for ${1}"
|
||||
|
||||
return 0
|
||||
else
|
||||
|
@ -110,22 +110,17 @@ export -f _extract_certs_from_acme
|
|||
|
||||
function _notify
|
||||
{
|
||||
local FINAL_MSG=''
|
||||
local MSG="${2:-}"
|
||||
local TYPE="${1:-}"
|
||||
{ [[ -z ${1:-} ]] || [[ -z ${2:-} ]] ; } && return
|
||||
|
||||
case "${TYPE}" in
|
||||
'none' ) FINAL_MSG=' ' ;;
|
||||
'tasklog' ) FINAL_MSG="[ \e[0;92mTASKLOG\e[0m ] ${MSG}" ;; # light green
|
||||
'warn' ) FINAL_MSG="[ \e[0;93mWARNING\e[0m ] ${MSG}" ;; # light yellow
|
||||
'err' ) FINAL_MSG="[ \e[0;31mERROR\e[0m ] ${MSG}" ;; # light red
|
||||
'fatal' ) FINAL_MSG="[ \e[0;91mFATAL\e[0m ] ${MSG}" ;; # red
|
||||
'inf' ) [[ ${DMS_DEBUG} -eq 1 ]] && FINAL_MSG="[[ \e[0;34mINFO\e[0m ]] ${MSG}" ;; # light blue
|
||||
'task' ) [[ ${DMS_DEBUG} -eq 1 ]] && FINAL_MSG="[[ \e[0;37mTASK\e[0m ]] ${MSG}" ;; # light grey
|
||||
* ) ;;
|
||||
case ${1} in
|
||||
tasklog ) echo "-e${3:-}" "[ \e[0;92mTASKLOG\e[0m ] ${2}" ;; # light green
|
||||
warn ) echo "-e${3:-}" "[ \e[0;93mWARNING\e[0m ] ${2}" ;; # light yellow
|
||||
err ) echo "-e${3:-}" "[ \e[0;31mERROR\e[0m ] ${2}" ;; # light red
|
||||
fatal ) echo "-e${3:-}" "[ \e[0;91mFATAL\e[0m ] ${2}" ;; # red
|
||||
inf ) [[ ${DMS_DEBUG} -eq 1 ]] && echo "-e${3:-}" "[[ \e[0;34mINF\e[0m ]] ${2}" ;; # light blue
|
||||
task ) [[ ${DMS_DEBUG} -eq 1 ]] && echo "-e${3:-}" "[[ \e[0;37mTASKS\e[0m ]] ${2}" ;; # light grey
|
||||
* ) ;;
|
||||
esac
|
||||
|
||||
[[ -n ${FINAL_MSG} ]] && echo "-e${3:-}" "${FINAL_MSG}"
|
||||
}
|
||||
export -f _notify
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ SPAMASSASSIN_SPAM_TO_INBOX="${SPAMASSASSIN_SPAM_TO_INBOX:=0}"
|
|||
SPOOF_PROTECTION="${SPOOF_PROTECTION:=0}"
|
||||
SRS_SENDER_CLASSES="${SRS_SENDER_CLASSES:=envelope_sender}"
|
||||
SSL_TYPE="${SSL_TYPE:=''}"
|
||||
SUPERVISOR_LOGLEVEL="${SUPERVISOR_LOGLEVEL:=warn}"
|
||||
TLS_LEVEL="${TLS_LEVEL:=modern}"
|
||||
VIRUSMAILS_DELETE_DELAY="${VIRUSMAILS_DELETE_DELAY:=7}"
|
||||
|
||||
|
@ -90,6 +91,7 @@ function register_functions
|
|||
|
||||
################### >> setup funcs
|
||||
|
||||
_register_setup_function "_setup_supervisor"
|
||||
_register_setup_function "_setup_default_vars"
|
||||
_register_setup_function "_setup_file_permissions"
|
||||
|
||||
|
@ -352,6 +354,26 @@ function setup
|
|||
done
|
||||
}
|
||||
|
||||
function _setup_supervisor
|
||||
{
|
||||
case ${SUPERVISOR_LOGLEVEL} in
|
||||
critical | error | warn | info | debug )
|
||||
sed -i -E \
|
||||
"s+loglevel.*+loglevel = ${SUPERVISOR_LOGLEVEL}+g" \
|
||||
/etc/supervisor/supervisord.conf
|
||||
;;
|
||||
* )
|
||||
_notify 'warn' \
|
||||
"SUPERVISOR_LOGLEVEL value '${SUPERVISOR_LOGLEVEL}' unknown. Defaulting to 'warn'"
|
||||
sed -i -E \
|
||||
"s+loglevel.*+loglevel = warn+g" \
|
||||
/etc/supervisor/supervisord.conf
|
||||
;;
|
||||
esac
|
||||
|
||||
supervisorctl update
|
||||
}
|
||||
|
||||
function _setup_default_vars
|
||||
{
|
||||
_notify 'task' "Setting up default variables"
|
||||
|
@ -368,9 +390,9 @@ function _setup_default_vars
|
|||
# ! needs to be a string comparison
|
||||
if [[ ${REPORT_RECIPIENT} == "0" ]]
|
||||
then
|
||||
PFLOGSUMM_TRIGGER="${PFLOGSUMM_TRIGGER:="none"}"
|
||||
PFLOGSUMM_TRIGGER="${PFLOGSUMM_TRIGGER:=none}"
|
||||
else
|
||||
PFLOGSUMM_TRIGGER="${PFLOGSUMM_TRIGGER:="logrotate"}"
|
||||
PFLOGSUMM_TRIGGER="${PFLOGSUMM_TRIGGER:=logrotate}"
|
||||
fi
|
||||
|
||||
# expand address to simplify the rest of the script
|
||||
|
@ -420,6 +442,7 @@ function _setup_default_vars
|
|||
echo "SPOOF_PROTECTION=${SPOOF_PROTECTION}"
|
||||
echo "SRS_SENDER_CLASSES=${SRS_SENDER_CLASSES}"
|
||||
echo "SSL_TYPE=${SSL_TYPE}"
|
||||
echo "SUPERVISOR_LOGLEVEL=${SUPERVISOR_LOGLEVEL}"
|
||||
echo "TLS_LEVEL=${TLS_LEVEL}"
|
||||
echo "VIRUSMAILS_DELETE_DELAY=${VIRUSMAILS_DELETE_DELAY}"
|
||||
echo "DMS_DEBUG=${DMS_DEBUG}"
|
||||
|
@ -808,7 +831,7 @@ function _setup_ldap
|
|||
fi
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
sed -i -E 's+mydestination = $myhostname, +mydestination = +' /etc/postfix/main.cf
|
||||
sed -i 's+mydestination = \$myhostname, +mydestination = +' /etc/postfix/main.cf
|
||||
|
||||
return 0
|
||||
}
|
||||
|
@ -1918,7 +1941,7 @@ function _fix_cleanup_spamassassin
|
|||
|
||||
function misc
|
||||
{
|
||||
_notify 'tasklog' 'Startin misc'
|
||||
_notify 'inf' 'Startin misc'
|
||||
|
||||
for FUNC in "${FUNCS_MISC[@]}"
|
||||
do
|
||||
|
@ -2169,28 +2192,20 @@ function _start_changedetector
|
|||
|
||||
if [[ ${DMS_DEBUG:-0} -eq 1 ]]
|
||||
then
|
||||
_notify 'none'
|
||||
_notify 'tasklog' 'ENVIRONMENT'
|
||||
_notify 'none'
|
||||
|
||||
_notify 'inf' 'ENVIRONMENT'
|
||||
printenv
|
||||
fi
|
||||
|
||||
_notify 'none'
|
||||
_notify 'tasklog' 'Welcome to docker-mailserver!'
|
||||
_notify 'none'
|
||||
_notify 'inf' 'Welcome to docker-mailserver!'
|
||||
|
||||
register_functions
|
||||
|
||||
check
|
||||
setup
|
||||
fix
|
||||
misc
|
||||
start_daemons
|
||||
|
||||
_notify 'none'
|
||||
_notify 'tasklog' "${HOSTNAME} is up and running"
|
||||
_notify 'none'
|
||||
|
||||
touch /var/log/mail/mail.log
|
||||
tail -fn 0 /var/log/mail/mail.log
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue