<commit_before>#!/bin/bash

set -e

if [ -z "$MC_MAIL_OPENDKIM_DOMAIN" ]; then
    echo "MC_MAIL_OPENDKIM_DOMAIN (top-level domain to use for signing emails) is not set."
    exit 1
fi

if [ -z "$MC_MAIL_OPENDKIM_HOSTNAME" ]; then
    echo "MC_MAIL_OPENDKIM_HOSTNAME (mail server hostname) is not set."
    exit 1
fi

set -u

# (Re)generate dynamic configuration
rm -f /etc/opendkim/KeyTable
echo "${MC_MAIL_OPENDKIM_HOSTNAME}._domainkey.${MC_MAIL_OPENDKIM_DOMAIN} ${MC_MAIL_OPENDKIM_DOMAIN}:${MC_MAIL_OPENDKIM_HOSTNAME}:/etc/opendkim/keys/${MC_MAIL_OPENDKIM_HOSTNAME}.private" \
    > /etc/opendkim/KeyTable
rm -f /etc/opendkim/SigningTable
echo "*@${MC_MAIL_OPENDKIM_DOMAIN} ${MC_MAIL_OPENDKIM_HOSTNAME}._domainkey.${MC_MAIL_OPENDKIM_DOMAIN}" \
    > /etc/opendkim/SigningTable

# Generate keys if those are missing
if [ ! -f "/etc/opendkim/keys/${MC_MAIL_OPENDKIM_HOSTNAME}.private" ]; then
    opendkim-genkey \
        -s "${MC_MAIL_OPENDKIM_HOSTNAME}" \
        -d "${MC_MAIL_OPENDKIM_DOMAIN}" \
        -D /etc/opendkim/keys/
    chown opendkim:opendkim "/etc/opendkim/keys/${MC_MAIL_OPENDKIM_HOSTNAME}.private"
fi

# Print public key before every run
echo
echo "Add the following DNS record to ${MC_MAIL_OPENDKIM_DOMAIN} domain if you haven't already:"
echo
cat "/etc/opendkim/keys/${MC_MAIL_OPENDKIM_HOSTNAME}.txt"
echo

# Set up rsyslog for logging
source /rsyslog.inc.sh

# Start OpenDKIM
exec opendkim \
    -f \
    -v \
    -x /etc/opendkim.conf \
    -u opendkim \
    -P /var/run/opendkim/opendkim.pid \
    -p inet:12301@localhost<commit_msg>Update OpenDKIM's command too<commit_after>#!/bin/bash

set -e

if [ -z "$MC_MAIL_OPENDKIM_DOMAIN" ]; then
    echo "MC_MAIL_OPENDKIM_DOMAIN (top-level domain to use for signing emails) is not set."
    exit 1
fi

if [ -z "$MC_MAIL_OPENDKIM_HOSTNAME" ]; then
    echo "MC_MAIL_OPENDKIM_HOSTNAME (mail server hostname) is not set."
    exit 1
fi

set -u

# (Re)generate dynamic configuration
rm -f /etc/opendkim/KeyTable
echo "${MC_MAIL_OPENDKIM_HOSTNAME}._domainkey.${MC_MAIL_OPENDKIM_DOMAIN} ${MC_MAIL_OPENDKIM_DOMAIN}:${MC_MAIL_OPENDKIM_HOSTNAME}:/etc/opendkim/keys/${MC_MAIL_OPENDKIM_HOSTNAME}.private" \
    > /etc/opendkim/KeyTable
rm -f /etc/opendkim/SigningTable
echo "*@${MC_MAIL_OPENDKIM_DOMAIN} ${MC_MAIL_OPENDKIM_HOSTNAME}._domainkey.${MC_MAIL_OPENDKIM_DOMAIN}" \
    > /etc/opendkim/SigningTable

# Generate keys if those are missing
if [ ! -f "/etc/opendkim/keys/${MC_MAIL_OPENDKIM_HOSTNAME}.private" ]; then
    opendkim-genkey \
        -s "${MC_MAIL_OPENDKIM_HOSTNAME}" \
        -d "${MC_MAIL_OPENDKIM_DOMAIN}" \
        -D /etc/opendkim/keys/
    chown opendkim:opendkim "/etc/opendkim/keys/${MC_MAIL_OPENDKIM_HOSTNAME}.private"
fi

# Print public key before every run
echo
echo "Add the following DNS record to ${MC_MAIL_OPENDKIM_DOMAIN} domain if you haven't already:"
echo
cat "/etc/opendkim/keys/${MC_MAIL_OPENDKIM_HOSTNAME}.txt"
echo

# Set up rsyslog for logging
source /rsyslog.inc.sh

# Start OpenDKIM
exec opendkim \
    -f \
    -v \
    -x /etc/opendkim.conf \
    -u opendkim \
    -P /var/run/opendkim/opendkim.pid \
    -p inet:12301
{'fraction_non_alphanumeric': 0.12099871959026888, 'fraction_numerical': 0.004481434058898848, 'mean_word_length': 3.867601246105919, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5988871', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1288, 'n_words': 246}