#!/bin/bash if [ $(id -u) -ne 0 ]; then echo "This script must be run as root." > /dev/stderr exit 1 fi domains=$(cat domains.list | grep -v -E '^[[:space:]]*(#.*)?$') docker exec -it nginx_proxy mkdir -p /var/www/certbot docker run -it --rm --name letsencrypt \ --volumes-from nginx_proxy \ -v /etc/letsencrypt:/etc/letsencrypt:rw \ --network nginxproxy \ certbot/certbot \ certonly --webroot --webroot-path /var/www/certbot \ --config-dir=/etc/letsencrypt \ --agree-tos --renew-by-default \ --force-renewal \ --cert-name typename.fr \ -d $(echo typename.fr ${domains[*]} | tr ' ' ',') for domain in ${domains[*]}; do echo "Creating symbolic links for ${domain}... " dir=/etc/letsencrypt/live/${domain} if [ -e "${dir}" ]; then rm -rf ${dir} fi mkdir ${dir} for link in /etc/letsencrypt/live/typename.fr/*.pem; do ln -s $(readlink $link) ${dir}/$(basename $link) done done docker-compose restart