Fix: Fix broken postfix-install.sh script, move other spaces to tabs as well

This commit is contained in:
Bojan Čekrlić 2025-02-28 19:17:01 +01:00
parent b43c3d9582
commit bd3a68c4f5
5 changed files with 102 additions and 103 deletions

View file

@ -2,41 +2,41 @@
set -e set -e
if [ -f /etc/os-release ]; then if [ -f /etc/os-release ]; then
. /etc/os-release . /etc/os-release
fi fi
# Installs postfix, opendkim, and other required packages using the # Installs postfix, opendkim, and other required packages using the
# Alpine package manager. This function is called when the image is # Alpine package manager. This function is called when the image is
# built on an Alpine base image. # built on an Alpine base image.
do_alpine() { do_alpine() {
architecture_specific_packages="" architecture_specific_packages=""
apk update apk update
if [ "$(apk info postfix-pgsql | grep -R '^postfix-pgsql')" != "" ]; then if [ "$(apk info postfix-pgsql | grep -R '^postfix-pgsql')" != "" ]; then
architecture_specific_packages="${architecture_specific_packages} postfix-pgsql" architecture_specific_packages="${architecture_specific_packages} postfix-pgsql"
fi fi
if [ "$(apk info postfix-mysql | grep -R '^postfix-mysql')" != "" ]; then if [ "$(apk info postfix-mysql | grep -R '^postfix-mysql')" != "" ]; then
architecture_specific_packages="${architecture_specific_packages} postfix-mysql" architecture_specific_packages="${architecture_specific_packages} postfix-mysql"
fi fi
apk add --upgrade cyrus-sasl cyrus-sasl-static cyrus-sasl-digestmd5 cyrus-sasl-crammd5 cyrus-sasl-login cyrus-sasl-ntlm libsasl apk add --upgrade cyrus-sasl cyrus-sasl-static cyrus-sasl-digestmd5 cyrus-sasl-crammd5 cyrus-sasl-login cyrus-sasl-ntlm libsasl
apk add postfix postfix-pcre postfix-ldap ${architecture_specific_packages} apk add postfix postfix-pcre postfix-ldap ${architecture_specific_packages}
apk add opendkim apk add opendkim
apk add --upgrade \ apk add --upgrade \
bash \ bash \
bind-tools \ bind-tools \
ca-certificates \ ca-certificates \
jsoncpp \ jsoncpp \
libcurl \ libcurl \
lmdb \ lmdb \
logrotate \ logrotate \
musl \ musl \
musl-utils \ musl-utils \
netcat-openbsd \ netcat-openbsd \
opendkim-utils \ opendkim-utils \
rsyslog \ rsyslog \
supervisor \ supervisor \
tzdata tzdata
} }
@ -44,54 +44,54 @@ do_alpine() {
# ubuntu/debian package manager. This function is called when the # ubuntu/debian package manager. This function is called when the
# image is built on a ubuntu/debian base image. # image is built on a ubuntu/debian base image.
do_ubuntu() { do_ubuntu() {
architecture_specific_packages="" architecture_specific_packages=""
RELEASE_SPECIFIC_PACKAGES="" RELEASE_SPECIFIC_PACKAGES=""
export DEBCONF_NOWARNINGS=yes export DEBCONF_NOWARNINGS=yes
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
echo "Europe/Berlin" > /etc/timezone echo "Europe/Berlin" > /etc/timezone
apt-get update -y -q apt-get update -y -q
if [ "$(apt-cache search --names-only '^postfix-pgsql$')" != "" ]; then
architecture_specific_packages="${architecture_specific_packages} postfix-pgsql"
fi
if [ "$(apt-cache search --names-only '^postfix-mysql$')" != "" ]; then
architecture_specific_packages="${architecture_specific_packages} postfix-mysql"
fi
apt-get install -y libsasl2-modules sasl2-bin if [ "$(apt-cache search --names-only '^postfix-pgsql$')" != "" ]; then
apt-get install -y postfix postfix-pcre postfix-ldap ${architecture_specific_packages} architecture_specific_packages="${architecture_specific_packages} postfix-pgsql"
apt-get install -y opendkim fi
local libcurl="libcurl4" if [ "$(apt-cache search --names-only '^postfix-mysql$')" != "" ]; then
if [ "$(apt-cache search --names-only '^libcurl4t64$')" != "" ]; then architecture_specific_packages="${architecture_specific_packages} postfix-mysql"
libcurl="libcurl4t64" fi
fi
apt-get install -y \ apt-get install -y libsasl2-modules sasl2-bin
${libcurl} ${RELEASE_SPECIFIC_PACKAGES} \ apt-get install -y postfix postfix-pcre postfix-ldap ${architecture_specific_packages}
bash \ apt-get install -y opendkim
ca-certificates \ local libcurl="libcurl4"
colorized-logs \ if [ "$(apt-cache search --names-only '^libcurl4t64$')" != "" ]; then
cron \ libcurl="libcurl4t64"
curl \ fi
dnsutils \ apt-get install -y \
libjsoncpp25 \ ${libcurl} ${RELEASE_SPECIFIC_PACKAGES} \
logrotate \ bash \
net-tools \ ca-certificates \
netcat-openbsd \ colorized-logs \
opendkim-tools \ cron \
postfix-lmdb \ curl \
procps \ dnsutils \
rsyslog \ libjsoncpp25 \
sasl2-bin \ logrotate \
supervisor \ net-tools \
tzdata \ netcat-openbsd \
apt-get clean opendkim-tools \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* postfix-lmdb \
procps \
rsyslog \
sasl2-bin \
supervisor \
tzdata
apt-get clean
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
} }
if [ -f /etc/alpine-release ]; then if [ -f /etc/alpine-release ]; then
do_alpine do_alpine
else else
do_ubuntu do_ubuntu
fi fi
# Some services (eg. cron) will complain if this file does not exists, even if it's empty. # Some services (eg. cron) will complain if this file does not exists, even if it's empty.

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
if [ -f /usr/sbin/cron ]; then # Ubuntu if [ -f /usr/sbin/cron ]; then # Ubuntu
exec /usr/sbin/cron -f exec /usr/sbin/cron -f
else # Alpine / Busybox cron else # Alpine / Busybox cron
exec /usr/sbin/crond -f -S exec /usr/sbin/crond -f -S
fi fi

View file

@ -9,5 +9,5 @@ SCRIPT_DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
# are sent straight to the terminal # are sent straight to the terminal
## ##
while ! env PYTHONUNBUFFERED=1 python3 "$SCRIPT_DIR/email-anonymizer.py" "$@"; do while ! env PYTHONUNBUFFERED=1 python3 "$SCRIPT_DIR/email-anonymizer.py" "$@"; do
sleep 1 sleep 1
done done

View file

@ -1,34 +1,33 @@
#!/bin/sh #!/bin/sh
set -e set -e
if [ -f /tmp/container_is_terminating ]; then if [ -f /tmp/container_is_terminating ]; then
exit 0 exit 0
fi fi
check_postfix() { check_postfix() {
local proxy_protocol="$(postconf postscreen_upstream_proxy_protocol | cut -f2- -d= | tr -d '[:blank:]')" local proxy_protocol="$(postconf postscreen_upstream_proxy_protocol | cut -f2- -d= | tr -d '[:blank:]')"
check_string="EHLO healthcheck\nquit\n"
check_string="EHLO healthcheck\nquit\n" if [ -n "$proxy_protocol" ]; then
check_string="PROXY TCP4 127.0.0.1 127.0.0.1 587 587\n${check_string}"
# ^--- proxied internet protocol and family
# ^--- source address
# ^--- destination address
# ^--- source port
# ^--- destination port
fi
if [ -n "$proxy_protocol" ]; then printf "${check_string}" | \
check_string="PROXY TCP4 127.0.0.1 127.0.0.1 587 587\n${check_string}" { while read l ; do sleep 1; echo $l; done } | \
# ^--- proxied internet protocol and family nc -w 2 127.0.0.1 587 | \
# ^--- source address grep -qE "^220.*ESMTP Postfix"
# ^--- destination address
# ^--- source port
# ^--- destination port
fi
printf "${check_string}" | \
{ while read l ; do sleep 1; echo $l; done } | \
nc -w 2 127.0.0.1 587 | \
grep -qE "^220.*ESMTP Postfix"
} }
check_dkim() { check_dkim() {
if [ -f /tmp/no_open_dkim ]; then if [ -f /tmp/no_open_dkim ]; then
return return
fi fi
printf '\x18Clocalhost\x004\x00\x00127.0.0.1\x00' | nc -w 2 127.0.0.1 8891 printf '\x18Clocalhost\x004\x00\x00127.0.0.1\x00' | nc -w 2 127.0.0.1 8891
} }
echo "Postfix check..." echo "Postfix check..."

View file

@ -1,21 +1,21 @@
#!/bin/sh #!/bin/sh
noop() { noop() {
while true; do while true; do
# 2147483647 = max signed 32-bit integer # 2147483647 = max signed 32-bit integer
# 2147483647 s ≅ 70 years # 2147483647 s ≅ 70 years
sleep infinity || sleep 2147483647 sleep infinity || sleep 2147483647
done done
} }
if [ ! -d /etc/opendkim/keys ]; then if [ ! -d /etc/opendkim/keys ]; then
touch /tmp/no_open_dkim touch /tmp/no_open_dkim
noop noop
elif [ -z "$(find /etc/opendkim/keys -type f ! -name .)" ]; then elif [ -z "$(find /etc/opendkim/keys -type f ! -name .)" ]; then
touch /tmp/no_open_dkim touch /tmp/no_open_dkim
noop noop
else else
exec /usr/sbin/opendkim -D -f -x /etc/opendkim/opendkim.conf exec /usr/sbin/opendkim -D -f -x /etc/opendkim/opendkim.conf
fi fi