[Watchdog] smtp-cli 3.10 (yay) and a new check for IPv6 configuration problems
parent
d7af6c38e7
commit
9998a9ef28
|
@ -20,6 +20,7 @@ RUN apk add --update \
|
||||||
bind-tools \
|
bind-tools \
|
||||||
redis \
|
redis \
|
||||||
perl \
|
perl \
|
||||||
|
perl-net-dns \
|
||||||
perl-io-socket-ssl \
|
perl-io-socket-ssl \
|
||||||
perl-io-socket-inet6 \
|
perl-io-socket-inet6 \
|
||||||
perl-socket \
|
perl-socket \
|
||||||
|
@ -29,7 +30,7 @@ RUN apk add --update \
|
||||||
tini \
|
tini \
|
||||||
tzdata \
|
tzdata \
|
||||||
whois \
|
whois \
|
||||||
&& curl https://raw.githubusercontent.com/mludvig/smtp-cli/v3.9/smtp-cli -o /smtp-cli \
|
&& curl https://raw.githubusercontent.com/mludvig/smtp-cli/v3.10/smtp-cli -o /smtp-cli \
|
||||||
&& chmod +x smtp-cli
|
&& chmod +x smtp-cli
|
||||||
|
|
||||||
COPY watchdog.sh /watchdog.sh
|
COPY watchdog.sh /watchdog.sh
|
||||||
|
|
|
@ -30,9 +30,30 @@ until [[ $(redis-cli -h redis-mailcow PING) == "PONG" ]]; do
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# One-time check
|
||||||
|
if grep -qi "$(echo ${IPV6_NETWORK} | cut -d: -f1-3)" <<< "$(ip a s)"; then
|
||||||
|
if [[ -z "$(get_ipv6)" ]]; then
|
||||||
|
mail_error "ipv6-config" "enable_ipv6 is true in docker-compose.yml, but an IPv6 link could not be established. Please verify your IPv6 connection."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
redis-cli -h redis-mailcow DEL F2B_RES > /dev/null
|
redis-cli -h redis-mailcow DEL F2B_RES > /dev/null
|
||||||
|
|
||||||
# Common functions
|
# Common functions
|
||||||
|
get_ipv6(){
|
||||||
|
local IPV6=
|
||||||
|
local IPV6_SRCS=
|
||||||
|
local TRY=
|
||||||
|
IPV6_SRCS[0]="ip6.korves.net"
|
||||||
|
IPV6_SRCS[1]="ip6.mailcow.email"
|
||||||
|
until [[ ! -z ${IPV6} ]] || [[ ${TRY} -ge 10 ]]; do
|
||||||
|
IPV6=$(curl --connect-timeout 3 -m 10 -L6s ${IPV6_SRCS[$RANDOM % ${#IPV6_SRCS[@]} ]} | grep "^\([0-9a-fA-F]\{0,4\}:\)\{1,7\}[0-9a-fA-F]\{0,4\}$")
|
||||||
|
[[ ! -z ${TRY} ]] && sleep 1
|
||||||
|
TRY=$((TRY+1))
|
||||||
|
done
|
||||||
|
echo ${IPV6}
|
||||||
|
}
|
||||||
|
|
||||||
array_diff() {
|
array_diff() {
|
||||||
# https://stackoverflow.com/questions/2312762, Alex Offshore
|
# https://stackoverflow.com/questions/2312762, Alex Offshore
|
||||||
eval local ARR1=\(\"\${$2[@]}\"\)
|
eval local ARR1=\(\"\${$2[@]}\"\)
|
||||||
|
@ -79,13 +100,14 @@ function mail_error() {
|
||||||
IFS=',' read -r -a MAIL_RCPTS <<< "${WATCHDOG_NOTIFY_EMAIL}"
|
IFS=',' read -r -a MAIL_RCPTS <<< "${WATCHDOG_NOTIFY_EMAIL}"
|
||||||
for rcpt in "${MAIL_RCPTS[@]}"; do
|
for rcpt in "${MAIL_RCPTS[@]}"; do
|
||||||
RCPT_DOMAIN=
|
RCPT_DOMAIN=
|
||||||
RCPT_MX=
|
#RCPT_MX=
|
||||||
RCPT_DOMAIN=$(echo ${rcpt} | awk -F @ {'print $NF'})
|
RCPT_DOMAIN=$(echo ${rcpt} | awk -F @ {'print $NF'})
|
||||||
RCPT_MX=$(dig +short ${RCPT_DOMAIN} mx | sort -n | awk '{print $2; exit}')
|
# Latest smtp-cli looks up mx via dns
|
||||||
if [[ -z ${RCPT_MX} ]]; then
|
#RCPT_MX=$(dig +short ${RCPT_DOMAIN} mx | sort -n | awk '{print $2; exit}')
|
||||||
log_msg "Cannot determine MX for ${rcpt}, skipping email notification..."
|
#if [[ -z ${RCPT_MX} ]]; then
|
||||||
return 1
|
# log_msg "Cannot determine MX for ${rcpt}, skipping email notification..."
|
||||||
fi
|
# return 1
|
||||||
|
#fi
|
||||||
[ -f "/tmp/${1}" ] && BODY="/tmp/${1}"
|
[ -f "/tmp/${1}" ] && BODY="/tmp/${1}"
|
||||||
timeout 10s ./smtp-cli --missing-modules-ok \
|
timeout 10s ./smtp-cli --missing-modules-ok \
|
||||||
--charset=UTF-8 \
|
--charset=UTF-8 \
|
||||||
|
@ -93,8 +115,9 @@ function mail_error() {
|
||||||
--body-plain="${BODY}" \
|
--body-plain="${BODY}" \
|
||||||
--to=${rcpt} \
|
--to=${rcpt} \
|
||||||
--from="watchdog@${MAILCOW_HOSTNAME}" \
|
--from="watchdog@${MAILCOW_HOSTNAME}" \
|
||||||
--server="${RCPT_MX}" \
|
--hello-host=${MAILCOW_HOSTNAME} \
|
||||||
--hello-host=${MAILCOW_HOSTNAME}
|
--ipv4
|
||||||
|
#--server="${RCPT_MX}"
|
||||||
log_msg "Sent notification email to ${rcpt}"
|
log_msg "Sent notification email to ${rcpt}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue