#!/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 || true for list in /etc/letsencrypt/*.list do certname="$(basename "$list" .list)" run_certbot "$list" "$certname" || true done systemctl start apache2