From af763687107fee217607ce75ee41fd6a176cbf2d Mon Sep 17 00:00:00 2001 From: pvincent Date: Fri, 27 Mar 2026 14:07:14 +0400 Subject: [PATCH] certbot authenticator nginx --- sympa/recipe/sympa.recipe | 66 ++++++++++++------------- sympa/resources/tools/sympa_export.bash | 2 +- sympa/resources/tools/sympa_import.bash | 12 ++++- 3 files changed, 45 insertions(+), 35 deletions(-) diff --git a/sympa/recipe/sympa.recipe b/sympa/recipe/sympa.recipe index 4978b45..d251b65 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 << EOF > /etc/nginx/sites-available/sympa.conf server { listen 80; server_name _; @@ -80,12 +80,12 @@ 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 diff --git a/sympa/resources/tools/sympa_export.bash b/sympa/resources/tools/sympa_export.bash index 6d57ffb..3dc5780 100755 --- a/sympa/resources/tools/sympa_export.bash +++ b/sympa/resources/tools/sympa_export.bash @@ -36,7 +36,7 @@ function export_files { function export_certbot { if [[ -d /etc/letsencrypt/live/$SYMPA_DOMAIN ]]; then - tar -C / -cf "$temp_dir/certbot.tar" etc/letsencrypt + tar -C / --exclude etc/letsencrypt/cli.ini -cf "$temp_dir/certbot.tar" etc/letsencrypt fi } diff --git a/sympa/resources/tools/sympa_import.bash b/sympa/resources/tools/sympa_import.bash index ce63e2c..b98388b 100755 --- a/sympa/resources/tools/sympa_import.bash +++ b/sympa/resources/tools/sympa_import.bash @@ -111,10 +111,20 @@ function import_certbot { SYMPA_DOMAIN=$(grep '^domain' /etc/sympa/sympa/sympa.conf | cut -f2) if [[ -f "$export_tmp/certbot.tar" ]]; then - echo -n "import certbot..." + echo "certbot save previous cli.ini" + cp /etc/letsencrypt/cli.ini "$export_tmp/ + + echo "import certbot..." rm -rf /etc/letsencrypt tar -xf "$export_tmp/certbot.tar" -C / echo OK + + echo "certbot restore previous cli.ini" + mv "$export_tmp/cli.ini /etc/letsencrypt/ + + echo "convert certbot apache2 authenticator to certbotx nginx authenticator" + /opt/miaou-bash/tools/append_or_replace '^authenticator =.*$' "authenticator = nginx" /etc/letsencrypt/renewal/$SYMPA_DOMAIN.conf + /opt/miaou-bash/tools/append_or_replace '^installer =.*$' "installer = nginx" /etc/letsencrypt/renewal/$SYMPA_DOMAIN.conf fi # add options-ssl-nginx.conf