ci: fix linter errors
This commit is contained in:
parent
6daa5ebb9f
commit
07d63f74d3
1 changed files with 17 additions and 14 deletions
31
run.sh
31
run.sh
|
@ -19,23 +19,23 @@ if [ -n "${SMTP_USERNAME_FILE}" ]; then [ -e "${SMTP_USERNAME_FILE}" ] && SMTP_U
|
|||
|
||||
[ -z "${SMTP_SERVER}" ] && echo "SMTP_SERVER is not set" && exit 1
|
||||
[ -z "${SERVER_HOSTNAME}" ] && echo "SERVER_HOSTNAME is not set" && exit 1
|
||||
[ ! -z "${SMTP_USERNAME}" -a -z "${SMTP_PASSWORD}" ] && echo "SMTP_USERNAME is set but SMTP_PASSWORD is not set" && exit 1
|
||||
[ -n "${SMTP_USERNAME}" -a -z "${SMTP_PASSWORD}" ] && echo "SMTP_USERNAME is set but SMTP_PASSWORD is not set" && exit 1
|
||||
|
||||
SMTP_PORT="${SMTP_PORT:-587}"
|
||||
|
||||
#Get the domain from the server host name
|
||||
DOMAIN=`echo ${SERVER_HOSTNAME} | awk 'BEGIN{FS=OFS="."}{print $(NF-1),$NF}'`
|
||||
DOMAIN=$(echo "${SERVER_HOSTNAME}" | awk 'BEGIN{FS=OFS="."}{print $(NF-1),$NF}')
|
||||
|
||||
# Set needed config options
|
||||
add_config_value "maillog_file" "/dev/stdout"
|
||||
add_config_value "myhostname" ${SERVER_HOSTNAME}
|
||||
add_config_value "myhostname" "${SERVER_HOSTNAME}"
|
||||
add_config_value "mydomain" ${DOMAIN}
|
||||
add_config_value "mydestination" "${DESTINATION:-localhost}"
|
||||
add_config_value "myorigin" '$mydomain'
|
||||
add_config_value "append_dot_mydomain" 'no'
|
||||
add_config_value "relayhost" "[${SMTP_SERVER}]:${SMTP_PORT}"
|
||||
add_config_value "smtp_use_tls" "yes"
|
||||
if [ ! -z "${SMTP_USERNAME}" ]; then
|
||||
if [ -n "${SMTP_USERNAME}" ]; then
|
||||
add_config_value "smtp_sasl_auth_enable" "yes"
|
||||
add_config_value "smtp_sasl_password_maps" "lmdb:/etc/postfix/sasl_passwd"
|
||||
add_config_value "smtp_sasl_security_options" "noanonymous"
|
||||
|
@ -51,8 +51,10 @@ if [ "${SMTP_PORT}" = "465" ]; then
|
|||
fi
|
||||
|
||||
# Create sasl_passwd file with auth credentials
|
||||
# shellcheck disable=SC2236
|
||||
if [ ! -f /etc/postfix/sasl_passwd -a ! -z "${SMTP_USERNAME}" ]; then
|
||||
grep -q "${SMTP_SERVER}" /etc/postfix/sasl_passwd > /dev/null 2>&1
|
||||
# shellcheck disable=SC2181
|
||||
if [ $? -gt 0 ]; then
|
||||
echo "Adding SASL authentication configuration"
|
||||
echo "[${SMTP_SERVER}]:${SMTP_PORT} ${SMTP_USERNAME}:${SMTP_PASSWORD}" >> /etc/postfix/sasl_passwd
|
||||
|
@ -61,15 +63,15 @@ if [ ! -f /etc/postfix/sasl_passwd -a ! -z "${SMTP_USERNAME}" ]; then
|
|||
fi
|
||||
|
||||
#Set header tag
|
||||
if [ ! -z "${SMTP_HEADER_TAG}" ]; then
|
||||
if [ -n "${SMTP_HEADER_TAG}" ]; then
|
||||
postconf -e "header_checks = regexp:/etc/postfix/header_checks"
|
||||
echo -e "/^MIME-Version:/i PREPEND RelayTag: $SMTP_HEADER_TAG\n/^Content-Transfer-Encoding:/i PREPEND RelayTag: $SMTP_HEADER_TAG" >> /etc/postfix/header_checks
|
||||
echo "Setting configuration option SMTP_HEADER_TAG with value: ${SMTP_HEADER_TAG}"
|
||||
fi
|
||||
|
||||
#Set smtp_generic_map
|
||||
#was speziell fur posteo nötig, da ohne return-address=info@mgrote.net die mail nicht angekommen sind
|
||||
if [ ! -z "${SMTP_GENERIC_MAP}" ]; then
|
||||
#war speziell fur posteo nötig, da ohne return-address=info@mgrote.net die mail nicht angekommen sind, wenn mail -r nicht gesetzt wurde
|
||||
if [ -n "${SMTP_GENERIC_MAP}" ]; then
|
||||
echo "smtp_generic_maps = pcre:/etc/postfix/generic" >> /etc/postfix/main.cf
|
||||
echo "${SMTP_GENERIC_MAP}" > /etc/postfix/generic
|
||||
echo "Setting configuration option SMTP_GENERIC_MAP with value: ${SMTP_GENERIC_MAP}"
|
||||
|
@ -84,7 +86,7 @@ fi
|
|||
|
||||
#Check for subnet restrictions
|
||||
nets='10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16'
|
||||
if [ ! -z "${SMTP_NETWORKS}" ]; then
|
||||
if [ -n "${SMTP_NETWORKS}" ]; then
|
||||
declare ipv6re="^((([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|\
|
||||
([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|\
|
||||
([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|\
|
||||
|
@ -95,10 +97,11 @@ if [ ! -z "${SMTP_NETWORKS}" ]; then
|
|||
(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[0-9]{1,3})$"
|
||||
|
||||
for i in $(sed 's/,/\ /g' <<<$SMTP_NETWORKS); do
|
||||
if grep -Eq "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/[0-9]{1,2}" <<<$i ; then
|
||||
# shellcheck disable=SC2013,SC2001,2086
|
||||
if grep -Eq "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/[0-9]{1,2}" <<<"$i" ; then
|
||||
nets+=", $i"
|
||||
elif grep -Eq "$ipv6re" <<<$i ; then
|
||||
readarray -d \/ -t arr < <(printf '%s' "$i")
|
||||
elif grep -Eq "$ipv6re" <<<"$i" ; then
|
||||
readarray -d \/ -t arr < <(printf '%s' "$i") # shellcheck disable=SC1001
|
||||
nets+=", [${arr[0]}]/${arr[1]}"
|
||||
else
|
||||
echo "$i is not in proper IPv4 or IPv6 subnet format. Ignoring."
|
||||
|
@ -108,19 +111,19 @@ fi
|
|||
add_config_value "mynetworks" "${nets}"
|
||||
|
||||
# Set SMTPUTF8
|
||||
if [ ! -z "${SMTPUTF8_ENABLE}" ]; then
|
||||
if [ -n "${SMTPUTF8_ENABLE}" ]; then
|
||||
postconf -e "smtputf8_enable = ${SMTPUTF8_ENABLE}"
|
||||
echo "Setting configuration option smtputf8_enable with value: ${SMTPUTF8_ENABLE}"
|
||||
fi
|
||||
|
||||
# Set message_size_limit
|
||||
if [ ! -z "${MESSAGE_SIZE_LIMIT}" ]; then
|
||||
if [ -n "${MESSAGE_SIZE_LIMIT}" ]; then
|
||||
postconf -e "message_size_limit = ${MESSAGE_SIZE_LIMIT}"
|
||||
echo "Setting configuration option message_size_limit with value: ${MESSAGE_SIZE_LIMIT}"
|
||||
fi
|
||||
|
||||
# Set inet_protocol
|
||||
if [ ! -z "${INET_PROTOCOL}" ]; then
|
||||
if [ -n "${INET_PROTOCOL}" ]; then
|
||||
sed -i -e 's/inet_protocols = all/inet_protocols = ipv4/g' /etc/postfix/main.cf
|
||||
echo "Setting configuration option inet_protocols with value: ${INET_PROTOCOL}"
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue