Skip to content

Commit

Permalink
Fixing letsencrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
escopecz committed Jul 9, 2024
1 parent 38263ee commit bd0ccad
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions setup-dc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ fi
ln -s $SOURCE_PATH $TARGET_PATH
echo "Symlink created for $DOMAIN configuration."

if ! nginx -t; then
echo "Nginx configuration test failed, stopping the script."
exit 1
fi

# Check if Nginx is running and reload to apply changes
if ! pgrep -x nginx > /dev/null; then
echo "Nginx is not running, starting Nginx..."
Expand All @@ -76,15 +81,10 @@ echo "## Proceeding with Let's Encrypt configuration..."
if [ ! -f "/etc/letsencrypt/live/$DOMAIN/README" ]; then
echo "## Configuring Let's Encrypt for $DOMAIN..."

# Stop Nginx to free up port 80 for Certbot
systemctl stop nginx

# Use Certbot to obtain a certificate
certbot certonly --standalone -d $DOMAIN --non-interactive --agree-tos -m {{EMAIL_ADDRESS}}

# Start Nginx again
systemctl start nginx
# Use Certbot with the Nginx plugin to obtain and install a certificate
certbot --nginx -d $DOMAIN --non-interactive --agree-tos -m {{EMAIL_ADDRESS}}

# Nginx will be reloaded automatically by Certbot after obtaining the certificate
echo "## Let's Encrypt configured for $DOMAIN"
else
echo "## Let's Encrypt is already configured for $DOMAIN"
Expand Down

0 comments on commit bd0ccad

Please sign in to comment.