From b8bb3f22eff3b2bfe873ac892906ae6935e852e1 Mon Sep 17 00:00:00 2001 From: pvincent Date: Thu, 18 Dec 2025 10:23:29 +0400 Subject: [PATCH] export dkimkeys --- sympa/recipe/sympa.recipe | 76 ++++++++++++++----------- sympa/resources/tools/sympa_export.bash | 37 ++++++------ sympa/resources/tools/sympa_import.bash | 15 ++++- 3 files changed, 75 insertions(+), 53 deletions(-) diff --git a/sympa/recipe/sympa.recipe b/sympa/recipe/sympa.recipe index cf5d412..dae9111 100644 --- a/sympa/recipe/sympa.recipe +++ b/sympa/recipe/sympa.recipe @@ -7,33 +7,33 @@ FORCE=${FORCE:-false} # FUNCTIONS function install_postfix { - if $FORCE || ! systemctl is-active postfix.service --quiet; then - debconf-set-selections </etc/nginx/sites-available/sympa.conf + if $FORCE || [[ ! -f /etc/nginx/sites-available/sympa.conf ]]; then + cat </etc/nginx/sites-available/sympa.conf server { listen 80; server_name _; @@ -80,16 +89,17 @@ server { } } EOF - cd /etc/nginx/sites-enabled && rm -f default && ln -sf ../sites-available/sympa.conf && cd - systemctl reload nginx - echo host for nginx installed successfully! - else - echo host for nginx already installed! - fi + cd /etc/nginx/sites-enabled && rm -f default && ln -sf ../sites-available/sympa.conf && cd + systemctl reload nginx + echo host for nginx installed successfully! + else + echo host for nginx already installed! + fi } # MAIN install_postfix +install_opendkim install_sympa install_nginx_host diff --git a/sympa/resources/tools/sympa_export.bash b/sympa/resources/tools/sympa_export.bash index 21a6376..29de311 100755 --- a/sympa/resources/tools/sympa_export.bash +++ b/sympa/resources/tools/sympa_export.bash @@ -8,33 +8,34 @@ SYMPA_DOMAIN=$(grep '^domain' "$SYMPA_CONF" | cut -f2) ### FUNCTIONS function create_temp_dir { - temp_name="$SYMPA_DOMAIN-$(date '+%F')" - temp_dir="/tmp/$temp_name" - mkdir "$temp_dir" + temp_name="$SYMPA_DOMAIN-$(date '+%F')" + temp_dir="/tmp/$temp_name" + mkdir "$temp_dir" } function export_database { - db_name=sympa - db_user=sympa - db_passwd=$(grep '^db_passwd' /etc/sympa/sympa/sympa.conf | cut -f2) - PGPASSWORD=$db_passwd pg_dump -h localhost -U "$db_user" "$db_name" | gzip >"$temp_dir/database.psql.gz" + db_name=sympa + db_user=sympa + db_passwd=$(grep '^db_passwd' /etc/sympa/sympa/sympa.conf | cut -f2) + PGPASSWORD=$db_passwd pg_dump -h localhost -U "$db_user" "$db_name" | gzip >"$temp_dir/database.psql.gz" } function export_files { - tar -C / -cf "$temp_dir/files.tar" etc/sympa/sympa/sympa.conf - tar -C / -uf "$temp_dir/files.tar" etc/sympa/data_structure.version - tar -C / -uf "$temp_dir/files.tar" etc/sympa/auth.conf - tar -C / -uf "$temp_dir/files.tar" var/lib/sympa - tar -C / -uf "$temp_dir/files.tar" var/spool/sympa - gzip "$temp_dir/files.tar" + tar -C / -cf "$temp_dir/files.tar" etc/sympa/sympa/sympa.conf + tar -C / -uf "$temp_dir/files.tar" etc/sympa/data_structure.version + tar -C / -uf "$temp_dir/files.tar" etc/sympa/auth.conf + tar -C / -uf "$temp_dir/files.tar" var/lib/sympa + tar -C / -uf "$temp_dir/files.tar" var/spool/sympa + [[ -d etc/dkimkeys ]] && tar -C / -uf "$temp_dir/files.tar" etc/dkimkeys/mail.{private,txt} + gzip "$temp_dir/files.tar" } function export { - create_temp_dir - export_database - export_files - tar -C "$temp_dir" -cf "$temp_name.sympa" . - rm "$temp_dir" -rf + create_temp_dir + export_database + export_files + tar -C "$temp_dir" -cf "$temp_name.sympa" . + rm "$temp_dir" -rf } ### MAIN diff --git a/sympa/resources/tools/sympa_import.bash b/sympa/resources/tools/sympa_import.bash index 48f51d3..456afcf 100755 --- a/sympa/resources/tools/sympa_import.bash +++ b/sympa/resources/tools/sympa_import.bash @@ -53,7 +53,7 @@ function replace_conf_entry_from_export { sed -i "s/$pattern/$ksh93/" "$final_conf" } -function import_files_etc { +function import_files_etc_sympa { mv etc/sympa/auth.conf /etc/sympa/ mv etc/sympa/data_structure.version /etc/sympa/ @@ -62,6 +62,16 @@ function import_files_etc { replace_conf_entry_from_export lang } +function import_files_etc_dkimkeys { + mkdir -p /etc/dkimkeys + mv etc/dkimkeys/* /etc/dkimkeys/ + /opt/miaou-bash/tools/append_or_replace "^Domain\t.*" "Domain\t\t\t\t$(hostname -f)" /etc/opendkim.conf + /opt/miaou-bash/tools/append_or_replace "^KeyFile\t.*" "KeyFile\t\t\t\t/etc/dkimkeys/mail.private" /etc/opendkim.conf + /opt/miaou-bash/tools/append_or_replace "^Selector\t.*" "Selector\t\t\tmail" /etc/opendkim.conf + /opt/miaou-bash/tools/append_or_replace "^Socket\t.*" "Socket\t\t\tinet:12345@localhost" /etc/opendkim.conf + systemctl reload opendkim.service +} + function import_files_lib { rm -rf /var/lib/sympa mv var/lib/sympa /var/lib @@ -79,7 +89,8 @@ function import_files { cd "$files_temp" tar -xf "$export_tmp/files.tar.gz" - import_files_etc + import_files_etc_sympa + [[ -d etc/dkimkeys ]] && import_files_etc_dkimkeys import_files_lib import_files_spool