summaryrefslogtreecommitdiff
path: root/roles/apache_server/templates/deploy_static_site_certs
blob: 4933d56563f11cb4adf73a40ef73394bc584c682 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh

set -eu


opts()
{
    cat "$1" | while read domain alias
    do
        printf "%s" "-w /srv/letsencrypt/$domain -d $domain"
        if [ -n "$alias" ]
        then
            printf "%s" " -d $alias"
        fi
        printf "\n"
    done
}


run_certbot()
{
    local list="$1"
    local certname="$2"
    certbot certonly \
            --standalone \
            --noninteractive \
            --email "{{ letsencrypt_email }}" \
            --agree-tos \
            --expand \
            --cert-name "$certname" \
            $(opts "$list")
}


systemctl stop apache2
for list in /etc/letsencrypt/*.list
do
    certname="$(basename "$list" .list)"
    run_certbot "$list" "$certname" || true
done
systemctl start apache2