2022-06-22 14:38:33 +02:00
|
|
|
#!/bin/bash
|
|
|
|
CUSTOM_DOMAIN="$1"
|
|
|
|
# Request from Lets Encrypt
|
|
|
|
certbot certonly --webroot --webroot-path="/var/www/html" \
|
|
|
|
--register-unsafely-without-email \
|
|
|
|
--domains $CUSTOM_DOMAIN \
|
|
|
|
--rsa-key-size 4096 \
|
|
|
|
--agree-tos \
|
|
|
|
--force-renewal
|
|
|
|
|
|
|
|
if (($? != 0)); then
|
|
|
|
echo "ERROR: certbot request failed for $CUSTOM_DOMAIN use http on port 80 - exiting"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
cp /app/letsencrypt/options-ssl-nginx.conf /etc/letsencrypt/options-ssl-nginx.conf
|
|
|
|
cp /app/letsencrypt/ssl-dhparams.pem /etc/letsencrypt/ssl-dhparams.pem
|
|
|
|
cp /app/letsencrypt/nginx-ssl.conf /etc/nginx/sites-available/nginx-ssl.conf
|
2022-06-23 16:03:09 +02:00
|
|
|
sed -i "s/CUSTOM_DOMAIN/$CUSTOM_DOMAIN/g" /etc/nginx/sites-available/nginx-ssl.conf
|
2022-06-22 14:38:33 +02:00
|
|
|
ln -s /etc/nginx/sites-available/nginx-ssl.conf /etc/nginx/sites-enabled/nginx-ssl.conf
|
|
|
|
|
|
|
|
echo "INFO: restart nginx after certbot request"
|
2022-06-23 16:08:56 +02:00
|
|
|
/etc/init.d/nginx restart
|
2022-06-22 14:38:33 +02:00
|
|
|
fi
|