diff --git a/sympa/miaou/miaou-install-from-import-sympa b/sympa/miaou/miaou-install-from-import-sympa index 0513cb7..ddf8a50 100755 --- a/sympa/miaou/miaou-install-from-import-sympa +++ b/sympa/miaou/miaou-install-from-import-sympa @@ -47,31 +47,32 @@ function install_fake_additional { miaou-recipe "$CONTAINER" "$BASEDIR"/../recipe/sympa_ldap_auth_remote.recipe } -function fix_dmarc_dkim_local_off { - echo 'fix dmarc dkim local off...' - miaou-recipe "$CONTAINER" "$BASEDIR"/../recipe/sympa_fix_dmarc_dkim_local_off.recipe +function fix_dkim_dmarc { + echo 'fix dkim global on...' + miaou-recipe "$CONTAINER" "$BASEDIR"/../recipe/sympa_fix_dkim_dmarc.recipe } -function fix_dkim_global_on { - echo 'fix dkim global on...' - miaou-recipe "$CONTAINER" "$BASEDIR"/../recipe/sympa_fix_dkim_global_on.recipe +function import { + echo "copy the backup to container..." + import_base=$(basename $IMPORT_FILE) + echo "copy import file: $import_base" + miaou-push $CONTAINER $IMPORT_FILE + + echo "launch the import process..." + miaou-exec $CONTAINER -- /opt/miaou-sympa/tools/sympa_import.bash "/root/$import_base" } +function install { + "$BASEDIR"/miaou-install-sympa "$CONTAINER" + +} # MAIN set -Eue parse_options $* -"$BASEDIR"/miaou-install-sympa "$CONTAINER" - -import_base=$(basename $IMPORT_FILE) -echo "copy import file: $import_base" -miaou-push $CONTAINER $IMPORT_FILE /root/ - -echo "launch the import process" -miaou-exec $CONTAINER -- /opt/miaou-sympa/tools/sympa_import.bash "/root/$import_base" - -fix_dmarc_dkim_local_off -fix_dkim_global_on +install +import +fix_dkim_dmarc install_fake_additional diff --git a/sympa/miaou/miaou-migrate-sympa-from-container b/sympa/miaou/miaou-migrate-sympa-from-container index 5a386c5..93d4a98 100755 --- a/sympa/miaou/miaou-migrate-sympa-from-container +++ b/sympa/miaou/miaou-migrate-sympa-from-container @@ -67,9 +67,9 @@ function get_container_net0 { } function rename_old_container { - pct-rename $CONTAINER $CONTAINER.9 pct set $OLD_VMID --delete net0 - sleep 3 + pct-rename $CONTAINER $CONTAINER.9 + pct-reboot $OLD_VMID } function create_new_container { diff --git a/sympa/recipe/sympa_fix_dkim_dmarc.recipe b/sympa/recipe/sympa_fix_dkim_dmarc.recipe new file mode 100644 index 0000000..265f7ad --- /dev/null +++ b/sympa/recipe/sympa_fix_dkim_dmarc.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 diff --git a/sympa/recipe/sympa_fix_dkim_global_on.recipe b/sympa/recipe/sympa_fix_dkim_global_on.recipe deleted file mode 100644 index 264c75e..0000000 --- a/sympa/recipe/sympa_fix_dkim_global_on.recipe +++ /dev/null @@ -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 diff --git a/sympa/recipe/sympa_fix_dmarc_dkim_local_off.recipe b/sympa/recipe/sympa_fix_dmarc_dkim_local_off.recipe deleted file mode 100644 index 3534f6c..0000000 --- a/sympa/recipe/sympa_fix_dmarc_dkim_local_off.recipe +++ /dev/null @@ -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