5 changed files with 79 additions and 80 deletions
-
35sympa/miaou/miaou-install-from-import-sympa
-
4sympa/miaou/miaou-migrate-sympa-from-container
-
59sympa/recipe/sympa_fix_dkim_dmarc.recipe
-
27sympa/recipe/sympa_fix_dkim_global_on.recipe
-
34sympa/recipe/sympa_fix_dmarc_dkim_local_off.recipe
@ -0,0 +1,59 @@ |
|||
#!/usr/bin/env miaou-recipe |
|||
|
|||
# CONSTANTS |
|||
|
|||
GLOBAL_CONF=/etc/sympa/sympa/sympa.conf |
|||
FOUND=false |
|||
|
|||
# FUNCTIONS |
|||
|
|||
function fix_dkim_dmarc_global { |
|||
if ! grep -q "^dkim_feature[[:space:]]*on" $GLOBAL_CONF; then |
|||
local sympa_domain=$(grep '^domain' "$GLOBAL_CONF" | cut -f2) |
|||
/opt/miaou-bash/tools/append_or_replace '^dkim_feature.*$' 'dkim_feature on' $GLOBAL_CONF |
|||
/opt/miaou-bash/tools/append_or_replace '^dkim_signature_apply_on.*$' 'dkim_signature_apply_on any' $GLOBAL_CONF |
|||
/opt/miaou-bash/tools/append_or_replace '^dkim_parameters.private_key_path.*$' 'dkim_parameters.private_key_path /etc/dkimkeys/mail.private' $GLOBAL_CONF |
|||
/opt/miaou-bash/tools/append_or_replace '^dkim_parameters.selector.*$' 'dkim_parameters.selector mail' $GLOBAL_CONF |
|||
/opt/miaou-bash/tools/append_or_replace '^dkim_parameters.signer_domain.*$' "dkim_parameters.signer_domain $sympa_domain" $GLOBAL_CONF |
|||
|
|||
/opt/miaou-bash/tools/append_or_replace '^arc_feature.*$' 'arc_feature on' $GLOBAL_CONF |
|||
/opt/miaou-bash/tools/append_or_replace '^remove_dkim_headers.*$' 'remove_dkim_headers on' $GLOBAL_CONF |
|||
/opt/miaou-bash/tools/append_or_replace '^dmarc_protection.mode*$' 'dmarc_protection.mode dmarc_reject' $GLOBAL_CONF |
|||
|
|||
echo 'dkim feature now enabled' |
|||
FOUND=true |
|||
else |
|||
echo 'dkim feature already enabled globally!' |
|||
fi |
|||
} |
|||
|
|||
function fix_dkim_dmarc_local { |
|||
config_files=$(find $LIST_DATA_DIR -name "config" -type f) |
|||
for i in $config_files; do |
|||
if grep -q -e ^dmarc -e ^dkim $i; then |
|||
FOUND=true |
|||
echo "found problematic configuration in $i" |
|||
remove_section_from_file $i dkim |
|||
remove_section_from_file $i dmarc |
|||
fi |
|||
done |
|||
} |
|||
|
|||
function remove_section_from_file { |
|||
local file=$1 |
|||
local section=$2 |
|||
awk "/^$section/{found=1} !found{print} /^$/{found=0}" $file > $file.new |
|||
mv $file.new $file |
|||
chown sympa:sympa $file |
|||
} |
|||
|
|||
function restart_services { |
|||
$FOUND && systemctl restart sympa wwsympa.socket || true |
|||
} |
|||
|
|||
# MAIN |
|||
|
|||
set -Eue |
|||
fix_dkim_dmarc_global |
|||
fix_dkim_dmarc_local |
|||
restart_services |
|||
@ -1,27 +0,0 @@ |
|||
#!/usr/bin/env miaou-recipe |
|||
|
|||
# CONSTANTS |
|||
|
|||
GLOBAL_CONF=/etc/sympa/sympa/sympa.conf |
|||
|
|||
# FUNCTIONS |
|||
|
|||
function fix_dkim_global_on { |
|||
if ! grep -q "^dkim_feature[[:space:]]*on" $GLOBAL_CONF; then |
|||
local sympa_domain=$(grep '^domain' "$GLOBAL_CONF" | cut -f2) |
|||
/opt/miaou-bash/tools/append_or_replace '^dkim_feature.*$' 'dkim_feature on' $GLOBAL_CONF |
|||
/opt/miaou-bash/tools/append_or_replace '^dkim_signature_apply_on.*$' 'dkim_signature_apply_on any' $GLOBAL_CONF |
|||
/opt/miaou-bash/tools/append_or_replace '^dkim_parameters.private_key_path.*$' 'dkim_parameters.private_key_path /etc/dkimkeys/mail.private' $GLOBAL_CONF |
|||
/opt/miaou-bash/tools/append_or_replace '^dkim_parameters.selector.*$' 'dkim_parameters.selector mail' $GLOBAL_CONF |
|||
/opt/miaou-bash/tools/append_or_replace '^dkim_parameters.signer_domain.*$' "dkim_parameters.signer_domain $sympa_domain" $GLOBAL_CONF |
|||
echo 'dkim feature now enabled' |
|||
else |
|||
echo 'dkim feature already enabled globally!' |
|||
fi |
|||
} |
|||
|
|||
# MAIN |
|||
|
|||
set -Eue |
|||
fix_dkim_global_on |
|||
systemctl restart sympa wwsympa.socket |
|||
@ -1,34 +0,0 @@ |
|||
#!/usr/bin/env miaou-recipe |
|||
|
|||
# CONSTANTS |
|||
|
|||
LIST_DATA_DIR=/var/lib/sympa/list_data |
|||
FOUND=false |
|||
|
|||
# FUNCTIONS |
|||
|
|||
function fix_for_local_config { |
|||
config_files=$(find $LIST_DATA_DIR -name "config" -type f) |
|||
for i in $config_files; do |
|||
if grep -q -e ^dmarc -e ^dkim $i; then |
|||
FOUND=true |
|||
echo "found problematic configuration in $i" |
|||
remove_section_from_file $i dkim |
|||
remove_section_from_file $i dmarc |
|||
fi |
|||
done |
|||
} |
|||
|
|||
function remove_section_from_file { |
|||
local file=$1 |
|||
local section=$2 |
|||
awk "/^$section/{found=1} !found{print} /^$/{found=0}" $file > $file.new |
|||
mv $file.new $file |
|||
chown sympa:sympa $file |
|||
} |
|||
|
|||
# MAIN |
|||
|
|||
set -Eue |
|||
fix_for_local_config |
|||
systemctl restart sympa wwsympa.socket |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue